n8n Code JavaScript is a skill for Claude that covers writing, reviewing and debugging JavaScript in an n8n Code node. It opens with a gate: check for a native node, then a short expression, and only then write code for a closed list of jobs such as recursion, state across runs or heavy all-items work.
It then covers the two execution modes and their cost, the four ways to read upstream data, the return shape n8n expects, the webhook body nesting, the sandbox rules and the production traps around loops and pairedItem.
What You Get
- A three-step gate: native node, short expression, then the closed list of jobs that justify code
- A guide to Run Once for All Items versus Each Item, with the per-item cost it adds
- Data access patterns for $input.all(), first(), item and named nodes
- The return format n8n accepts, and the primitive or null returns that fail
- Notes on this.helpers.httpRequest, Luxon, JMESPath, blocked helpers and allowlisted modules
- Reference files for data access, ten production patterns, errors and built-in functions
Common Use Cases
- Fixing a Code node that returns undefined for webhook fields
- Deciding whether a transform needs code or a Summarize, Sort or Remove Duplicates node
- Writing a running total or recursive flatten that no native node covers
- Accumulating results across SplitInBatches loop iterations
- Speeding up a slow Code node that runs once per item
What Makes It Unique
It is written around n8n’s task-runner sandbox: the bare $helpers global is undefined, authenticated helpers are denied and $env can be blocked. It also holds a measured cost table for per-item execution and pushes Claude to a native node first, leaving a Why Code note on each Code node that stays. It sends Custom Code Tool work to a separate skill with a different contract.
Under The Hood
The skill is instructions and four reference markdown files, with no scripts. It tells Claude to look up the Code node and validate its configuration through the n8n-mcp tools, which call your n8n server. The code it teaches runs inside n8n’s sandboxed task runner, where it can read workflow items, call this.helpers.httpRequest for unauthenticated web requests and keep data between runs with workflow static data.