用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill n8n命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| title | n8n: Develop workflows, custom nodes, and integrations for n8n automation platform |
| name | n8n |
| description | Develop workflows, custom nodes, and integrations for n8n automation platform |
| tags | ["sdd-workflow","shared-architecture","domain-specific"] |
| custom_fields | {"layer":null,"artifact_type":null,"architecture_approaches":["ai-agent-based","traditional-8layer"],"priority":"shared","development_status":"active","skill_category":"domain-specific","upstream_artifacts":[],"downstream_artifacts":[]} |
Provide specialized guidance for developing workflows, custom nodes, and integrations on the n8n automation platform. Enable AI assistants to design workflows, write custom code nodes, build TypeScript-based custom nodes, integrate external services, and implement AI agent patterns.
Invoke this skill when:
Do NOT use this skill for:
Runtime Environment:
Workflow Execution Models:
Fair-code License:
Core Nodes (Data manipulation):
Trigger Nodes (Workflow initiation):
Action Nodes (500+ integrations):
AI Nodes (LangChain integration):
Connection Types:
Data Structure:
// Input/output format for all nodes
[
{
json: { /* Your data object */ },
binary: { /* Optional binary data (files, images) */ },
pairedItem: { /* Reference to source item */ }
}
]
Data Access Patterns:
{{ $json.field }} (current node output){{ $('NodeName').item.json.field }} (specific node){{ $input.all() }} (entire dataset){{ $input.first() }} (single item){{ $itemIndex }} (current iteration)Credential Types:
Security Practices:
Step 1: Define Requirements
Step 2: Map Data Flow
Step 3: Select Nodes
Decision criteria:
Workflow Structure Pattern:
[Trigger] → [Validation] → [Branch (If/Switch)] → [Processing] → [Error Handler]
↓ ↓
[Path A nodes] [Path B nodes]
↓ ↓
[Merge/Output] [Output]
Modular Design:
Error Handling Strategy:
Local Testing:
Production Validation:
Available APIs:
fs, path, crypto, https_.groupBy(), _.sortBy(), etc.$input, $json, $binaryBasic Structure:
// Access input items
const items = $input.all();
// Process data
const processedItems = items.map(item => {
const inputData = item.json;
return {
json: {
// Output fields
processed: inputData.field.toUpperCase(),
timestamp: new Date().toISOString()
}
};
});
// Return transformed items
return processedItems;
Data Transformation Patterns:
Filtering:
const items = $input.all();
return items.filter(item => item.json.status === 'active');
Aggregation:
const items = $input.all();
const grouped = _.groupBy(items, item => item.json.category);
return [{
json: {
summary: Object.keys(grouped).map(category => ({
category,
count: grouped[category].length
}))
}
}];
API calls (async):
const items = $input.all();
const results = [];
for (const item of items) {
const response = await fetch(`https://api.example.com/data/${item.json.id}`);
const data = await response.json();
results.push({
json: {
original: item.json,
enriched: data
}
});
}
return results;
Error Handling in Code:
const items = $input.all();
return items.map(item => {
try {
// Risky operation
const result = JSON.parse(item.json.data);
return { json: { parsed: result } };
} catch (error) {
return {
json: {
error: error.message,
original: item.json.data
}
};
}
});
Available Libraries:
json, datetime, re, requestsBasic Structure:
# Access input items
items = _input.all()
# Process data
processed_items = []
for item in items:
input_data = item['json']
processed_items.append({
'json': {
'processed': input_data['field'].upper(),
'timestamp': datetime.now().isoformat()
}
})
# Return transformed items
return processed_items
Complexity Rating: Code Nodes
Build custom node when:
Use Code node when:
[See Code Examples: examples/n8n_custom_node.ts]
1. Programmatic Style (Full control)
Use for:
[See: CustomNode class in examples/n8n_custom_node.ts]
2. Declarative Style (Simplified)
Use for:
[See: operations and router exports in examples/n8n_custom_node.ts]
Additional Examples:
customApiCredentials in examples/n8n_custom_node.tsvalidateCredentials() in examples/n8n_custom_node.tsPollingTrigger class in examples/n8n_custom_node.tsStep 1: Initialize Node
# Create from template
npm create @n8n/node my-custom-node
# Directory structure created:
# ├── nodes/
# │ └── MyCustomNode/
# │ └── MyCustomNode.node.ts
# ├── credentials/
# │ └── MyCustomNodeApi.credentials.ts
# └── package.json
Step 2: Implement Logic
Step 3: Build and Test
# Build TypeScript
npm run build
# Link locally for testing
npm link
# In n8n development environment
cd ~/.n8n/nodes
npm link my-custom-node
# Restart n8n to load node
n8n start
Step 4: Publish
# Community node (npm package)
npm publish
# Install in n8n
Settings → Community Nodes → Install → Enter package name
Complexity Rating: Custom Nodes
Decision Tree:
Has native node? ──Yes──> Use native node
│
No
├──> Simple REST API? ──Yes──> HTTP Request node
├──> Complex auth (OAuth2)? ──Yes──> Build custom node
├──> Reusable across workflows? ──Yes──> Build custom node
└──> One-off integration? ──Yes──> Code node with fetch()
GET with query parameters:
URL: https://api.example.com/users
Method: GET
Query Parameters:
- status: active
- limit: 100
Authentication: Header Auth
- Name: Authorization
- Value: Bearer {{$credentials.apiKey}}
POST with JSON body:
URL: https://api.example.com/users
Method: POST
Body Content Type: JSON
Body:
{
"name": "={{ $json.name }}",
"email": "={{ $json.email }}"
}
Pagination handling (Code node):
let allResults = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await this.helpers.request({
method: 'GET',
url: `https://api.example.com/data?page=${page}`,
json: true,
});
allResults = allResults.concat(response.results);
hasMore = response.hasNext;
page++;
}
return allResults.map(item => ({ json: item }));
Receiving webhooks:
Responding to webhooks:
// In Code node after webhook trigger
const webhookData = $input.first().json;
// Process data
const result = processData(webhookData);
// Return response (synchronous webhook)
return [{
json: {
status: 'success',
data: result
}
}];
Webhook URL structure:
Production: https://your-domain.com/webhook/workflow-id
Test: https://your-domain.com/webhook-test/workflow-id
Common patterns:
Query with parameters:
-- PostgreSQL node
SELECT * FROM users
WHERE created_at > $1
AND status = $2
ORDER BY created_at DESC
-- Parameters from previous node
Parameters: ['{{ $json.startDate }}', 'active']
Batch insert:
// Code node preparing data for database
const items = $input.all();
const values = items.map(item => ({
name: item.json.name,
email: item.json.email,
created_at: new Date().toISOString()
}));
return [{ json: { values } }];
// Next node: PostgreSQL
// INSERT INTO users (name, email, created_at)
// VALUES {{ $json.values }}
Upload to S3:
Workflow: File Trigger → S3 Upload
- File Trigger: Monitor directory for new files
- S3 node:
- Operation: Upload
- Bucket: my-bucket
- File Name: {{ $json.fileName }}
- Binary Data: true (from file trigger)
Download and process:
HTTP Request (download) → Code (process) → Google Drive (upload)
- HTTP Request: Binary response enabled
- Code: Process $binary.data
- Google Drive: Upload with binary data
AI Agent Node Configuration:
Basic Agent Pattern:
Manual Trigger → AI Agent → Output
- AI Agent:
- Prompt: "You are a helpful assistant that {{$json.task}}"
- Tools: [Calculator, HTTP Request]
- Memory: Conversation Buffer Window
Use case: Human approval before agent actions
Webhook → AI Agent → If (requires approval) → Send Email → Wait for Webhook → Execute Action
↓ (auto-approve)
Execute Action
Implementation:
Use case: Multi-step problem solving with state
Loop Start → AI Agent → Tool Execution → State Update → Loop End (condition check)
↑______________________________________________________________|
State management:
// Code node - Initialize state
return [{
json: {
task: 'Research topic',
iteration: 0,
maxIterations: 5,
context: [],
completed: false
}
}];
// Code node - Update state
const state = $json;
state.iteration++;
state.context.push($('AI Agent').item.json.response);
state.completed = state.iteration >= state.maxIterations || checkGoalMet(state);
return [{ json: state }];
Query Input → Vector Store Search → Format Context → LLM → Response Output
Vector Store setup:
Complexity Rating: AI Workflows
[See Code Examples: examples/n8n_deployment.yaml]
Docker (Recommended):
[See: docker-compose configurations in examples/n8n_deployment.yaml]
npm (Development):
npm install n8n -g
n8n start
# Access: http://localhost:5678
Environment Configuration:
[See: Complete environment variable reference in examples/n8n_deployment.yaml]
Essential variables:
N8N_HOST - Public URL for webhooksWEBHOOK_URL - Webhook endpoint baseN8N_ENCRYPTION_KEY - Credential encryption (must persist)DB_TYPE - Database (SQLite/PostgreSQL/MySQL/MariaDB)EXECUTIONS_DATA_SAVE_ON_ERROR - Error loggingEXECUTIONS_DATA_SAVE_ON_SUCCESS - Success loggingPerformance tuning variables documented in examples/n8n_deployment.yaml
Queue Mode (High volume):
# Separate main and worker processes
# Main process (UI + queue management)
N8N_QUEUE_MODE=main n8n start
# Worker processes (execution only)
N8N_QUEUE_MODE=worker n8n worker
Database:
Resource Requirements:
| Workflow Volume | CPU | RAM | Database |
|---|---|---|---|
| <100 exec/day | 1 core | 512MB | SQLite |
| 100-1000/day | 2 cores | 2GB | PostgreSQL |
| 1000-10000/day | 4 cores | 4GB | PostgreSQL |
| >10000/day | 8+ cores | 8GB+ | PostgreSQL + Queue mode |
Monitoring:
1. Modularity:
2. Error Resilience:
3. Performance:
4. Security:
5. Maintainability:
1. Data validation:
// Always validate input structure
const items = $input.all();
for (const item of items) {
if (!item.json.email || !item.json.name) {
throw new Error(`Invalid input: missing required fields at item ${item.json.id}`);
}
}
2. Error context:
// Provide debugging information
try {
const result = await apiCall(item.json.id);
} catch (error) {
throw new Error(`API call failed for ID ${item.json.id}: ${error.message}`);
}
3. Idempotency:
// Check existence before creation
const exists = await checkExists(item.json.uniqueId);
if (!exists) {
await createRecord(item.json);
}
Use case: Sync data between two systems
Schedule Trigger (hourly) → Fetch Source Data → Transform → If (record exists) → Update Target
↓ (new)
Create in Target
Complexity: 2
Use case: Retry failed operations with exponential backoff
Main Workflow → Process → Error → Error Trigger Workflow
↓
Wait (delay) → Retry → If (max retries) → Alert
Complexity: 3
Use case: Augment data with external sources
Webhook → Split In Batches → For Each Item:
↓
API Call (enrich) → Code (merge) → Batch Results
↓
Database Insert
Complexity: 3
Use case: Process events from message queue
SQS Trigger → Parse Message → Switch (event type) → [Handler A, Handler B, Handler C] → Confirm/Delete Message
Complexity: 3
Use case: Approval workflow
Trigger → Generate Request → Send Email (approval link) → Webhook (approval response) → If (approved) → Execute Action
↓ (rejected)
Send Rejection Notice
Complexity: 4
Use case: Complex data pipeline
Schedule → Extract (API) → Validate → Transform → Load (Database) → Success Notification
↓ ↓
Error Handler ────────────────────> Error Notification
Complexity: 3
A workflow is production-ready when:
Functionality:
Error Handling:
Security:
Documentation:
Performance:
A custom node is production-ready when:
Functionality:
Code Quality:
Documentation:
Distribution:
Issue: Workflow fails with "Invalid JSON"
// Ensure return format
return [{ json: { your: 'data' } }];
// NOT: return { your: 'data' };
Issue: "Cannot read property of undefined"
// Check existence before access
const value = $json.field?.subfield ?? 'default';
Issue: Webhook not receiving data
curl -X POST https://your-n8n.com/webhook/test \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
Issue: Custom node not appearing
# Check installation
npm list -g | grep n8n-nodes-
# Reinstall if needed
npm install -g n8n-nodes-your-node
# Restart n8n
Issue: High memory usage
Issue: Credentials not working
1. Inspect node output:
2. Add debug Code nodes:
// Log intermediate values
const data = $json;
console.log('Debug data:', JSON.stringify(data, null, 2));
return [{ json: data }];
3. Use If node for validation:
// Expression to check data quality
{{ $json.email && $json.email.includes('@') }}
4. Enable execution logging:
docker logs n8n -f5. Test in isolation:
cloud-devops-expert skilldatabase-specialist skillapi-design-architect skillVersion: 1.0.0 Last Updated: 2025-11-13 Complexity Rating: 3 (Moderate - requires platform-specific knowledge) Estimated Learning Time: 8-12 hours for proficiency