No slash command · from n8n-autopilot
Provides expert guidance for writing JavaScript in n8n Code nodes, covering data access patterns, mode selection, and when to use native nodes instead. Helps avoid OOM risks and common pitfalls.
Ships in n8n-autopilot. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Expert guidance for writing JavaScript code in n8n Code nodes.
// Basic template for Code nodes
const items = $input.all();
// Process data
const processed = items.map(item => ({
json: {
...item.json,
processed: true,
timestamp: new Date().toISOString()
}
}));
return processed;
$input.all(), $input.first(), or $input.item[{json: {...}}] format$json.body (not $json directly)Reach for a native node before writing JavaScript — Code nodes are harder to read, review, and they run V8 in-process (OOM risk on large data, see below). In a real production audit, Code nodes outnumbered native conditional nodes ~2.5:1 — much of it avoidable:
| If you are doing… | Use this native node, NOT Code |
|---|---|
| Branching on a condition | IF (2 branches) / Switch (n branches) |
| Dropping items by a rule | Filter |
| Setting / renaming / mapping fields | Set (Edit Fields) |
| Merging / combining streams | Merge |
| Aggregating into one item | Aggregate / Summarize |
| Looping over large batches | Loop Over Items (SplitInBatches) |
Memory / OOM (real production incident): a Code node that loads or iterates a large dataset — especially a full DB result set (>~10k rows), binary, or file contents — can spike the V8 heap (~3 GB cap) and crash the n8n pod (OOM). For large data: page/limit at the source, process in
SplitInBatches, or push the work into the database/native node instead of materializing it all in JS.
Use a Code node when the logic genuinely has no native equivalent (custom parsing, multi-field computation, shaping a bespoke payload).
Use for: aggregation, batch processing, transformations that have no native-node equivalent
const allItems = $input.all();
const total = allItems.reduce((sum, item) => sum + (item.json.amount || 0), 0);
return [{
json: { total, count: allItems.length, average: total / allItems.length }
}];
Use for: Specialized cases — per-item validation, independent operations
const item = $input.item;
return [{
json: { ...item.json, processed: true, processedAt: new Date().toISOString() }
}];
Decision: Need to compare multiple items? → All Items. Each item independent? → Each Item. Not sure? → All Items.
// Most common: all items
const allItems = $input.all();
// Single result
const firstItem = $input.first();
const data = firstItem.json;
// Reference other nodes
const webhookData = $node["Webhook"].json;
const httpData = $node["HTTP Request"].json;
Webhook data is nested under .body:
// ❌ WRONG
const name = $json.name;
// ✅ CORRECT
const name = $json.body.name;
const webhookData = $input.first().json.body;
// ✅ Single result
return [{ json: { field1: value1 } }];
// ✅ Multiple results
return items.map(item => ({ json: { id: item.json.id, processed: true } }));
// ✅ Empty result
return [];
WRONG: return {json: {...}} (no array), return [{field: value}] (no json key)
const response = await $helpers.httpRequest({
method: 'GET',
url: 'https://api.example.com/data',
headers: { 'Authorization': 'Bearer token' }
});
return [{ json: { data: response } }];
const now = DateTime.now();
const formatted = now.toFormat('yyyy-MM-dd');
const tomorrow = now.plus({ days: 1 });
const adults = $jmespath(data, 'users[?age >= `18`]');
const names = $jmespath(data, 'users[*].name');
const items = $input.all();
const total = items.reduce((sum, item) => sum + (item.json.amount || 0), 0);
return [{ json: { total, count: items.length, average: total / items.length } }];
return $input.all()
.filter(item => item.json.status === 'active')
.map(item => ({ json: { id: item.json.id, name: item.json.name } }));
try {
const response = await $helpers.httpRequest({ url: 'https://api.example.com/data' });
return [{ json: { success: true, data: response } }];
} catch (error) {
return [{ json: { success: false, error: error.message } }];
}
$env and require() (#97)Production instances commonly run with N8N_BLOCK_ENV_ACCESS_IN_NODE=true and an empty
NODE_FUNCTION_ALLOW_BUILTIN / NODE_FUNCTION_ALLOW_EXTERNAL. There, $env.SECRET throws
access to env vars denied and require('crypto') throws Module crypto is disallowed — at
runtime, after every gate was green. Do not build on either:
httpHeaderAuth, …), never $env.n8n-nodes-base.crypto), not require('crypto').code-env-access) so the reviewer checks the target instance allows it.return items.map(item => ({json: item.json}));{{ }} in Code node → Use $json.field directly (no braces)[{json: {...}}], not {json: {...}}item.json?.user?.email || 'fallback'$json.email ❌ → $json.body.email ✅if (!items || items.length === 0) return [];map/filter over manual loopsconsole.log()✅ Complex transformations, custom calculations, API response parsing, multi-step conditionals, data aggregation
❌ Simple field mapping → Set node | Basic filtering → Filter node | HTTP requests → HTTP Request node
What SKILL.md sets; muted values are Claude Code's defaults
25 skills in this plugin
/build-stack-v2EXPERIMENTAL deterministic builder for a whole n8n workflow STACK (multiple sub-workflows wired via Execute Workflow), JS-orchestrated. Takes a PRP-style end-to-end use case, decomposes it into sub-workflows along known rules, fixes the handover contracts between them, documents the architecture (mermaid) in one central file, then builds each sub-workflow bottom-up via build-workflow-v2. Two modes: GREENFIELD (new stack) and EXTEND (change an existing one). Decomposition rules, build order (topological), and per-sub-WF gates are JS control flow the model cannot skip. Use for multi-workflow use cases; for a single workflow use build-workflow-v2./build-workflowFull 3-phase pipeline (Research → Write+Validate → Deploy+Test) for shipping an n8n workflow end-to-end. Wraps Etienne's `n8n-as-code:n8n-architect` skill for schema research + authoring, adds repo-scoped orchestration — community-template lookup, validate-push-test loop, mcpTrigger publish gate, execution inspection, Completion Report./build-workflow-v2EXPERIMENTAL deterministic variant of build-workflow + deploy, JS-orchestrated. Two modes: GREENFIELD (new workflow) and EDIT (change an existing one). Phase ordering, gate-checks (validate / drift-safe push --verify), and fix-loop limits are enforced by a Claude Code JS Workflow script instead of prose — gates become if/while control flow the model cannot skip or short-circuit. Subagent roles live in agents/n8n-*.md. Use when you want hard-enforced discipline over the soft prose pipelines.npx claudepluginhub neurawork-git/n8n-autopilot --plugin n8n-autopilotOther plugins' skills for the same job