# n8n-code-nodes-official

Guides AI coding agents to prioritize expressions and Edit Fields over Code nodes in n8n workflows, reserving custom scripts for true edge cases.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2000 installs · ★ 554
- Author: n8n-io
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/n8n-io/skills/tree/HEAD/skills/n8n-code-nodes-official/SKILL.md
- Updated: 2026-10-17
- HTML: https://affpapa.org/en/nevibecode/skills/n8n-code-nodes-official

## What it does

The skill introduces a strict decision order for n8n workflows. Code nodes run inside a sandboxed JavaScript runtime, creating execution overhead around 600ms compared to roughly 2ms for in-process expressions. Because of that performance gap, the skill treats the Code node as a last resort behind inline expressions and arrow functions in Edit Fields.

JavaScript is the default choice. The runtime includes an allowlist with `lodash`, `crypto`, and `luxon`. Python is only used when explicitly requested.

Code nodes remain valid for aggregating data across multiple upstream nodes with `$('Node').all()` or calculating group averages. For standard cryptographic tasks like hashing or HMAC, the skill instructs the agent to use the native Crypto node (`n8n-nodes-base.crypto`) instead of custom scripts.

## Requirements
- Works with: n8n

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-code-nodes-official -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/n8n-code-nodes-official/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/n8n-code-nodes-official/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-code-nodes-official -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/n8n-code-nodes-official/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-code-nodes-official -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/n8n-code-nodes-official/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install n8n-io/skills n8n-code-nodes-official
```

2. **Manually: put the files in place**
- File: `.github/skills/n8n-code-nodes-official/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-code-nodes-official -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/n8n-io/skills --path skills/n8n-code-nodes-official
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/n8n-code-nodes-official/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-code-nodes-official -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/n8n-io/skills/tree/HEAD/skills/n8n-code-nodes-official/SKILL.md

## When to use it
- prevent unnecessary Code nodes for simple field transformations
- write inline arrow functions in Edit Fields for multi-line logic
- aggregate data across multiple upstream n8n nodes at once
- route cryptographic operations to the native Crypto node

## Example prompts
- Transform the items array into a comma-separated string using Edit Fields
- Aggregate items from two upstream nodes using a JavaScript Code node
- Format this date field using an n8n expression instead of writing custom code

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: e53c962189533228.

BEGIN THIRD-PARTY FILE e53c962189533228
````text
---
name: n8n-code-nodes-official
description: Use when the user reaches for a Code node, mentions writing JavaScript or Python in n8n, or any custom logic comes up in workflow design. Triggers on "Code node", "Code", "JavaScript", "Python", "custom logic", "transform data", "$input", "$json transformation", "loop in code", "write a function", or any time the obvious answer seems to be "just put it in code."
---

# n8n Code Nodes

The Code node is powerful and often the wrong tool. The n8n equivalent of dropping into raw SQL when an ORM would do: real cases exist, but the moment a Code node handles logic an expression could, the workflow is harder to read, debug, and maintain. There's also a real perf gap: Code runs in a sandboxed JS runtime, expressions and Edit Fields run in-process, and the per-invocation overhead can be hundreds of times higher in Code (anecdotally ~2ms vs ~600ms for equivalent logic). For hot paths and large item counts, that compounds.

## Strong defaults

1. **Code node is a last resort.** Decision order: expression (`{{...}}`) → arrow function inside Edit Fields → Code node. The first two paths cover most "transform this data" tasks. Code earns its place for multi-source aggregation, external libraries, and a few specific patterns documented below.

2. **Default to JavaScript.** Write JS unless the user explicitly asked for Python ("use Python here," "I'm a Python shop," pasted Python code). Everywhere else in n8n (expressions, Edit Fields) is JS, JS has a curated library allowlist (`lodash`, `crypto`, `luxon`).

## Decision tree

```
Need custom logic?
├── Is it a transformation of one or two fields?
│   └── Expression: {{ $json.foo.toUpperCase() }} or {{ $json.items.map(item => item.name).join(', ') }}
│       Most "just transform this" cases land here.
│
├── Is it multi-line, but pure data shaping (map, filter, reduce, conditional)?
│   └── Edit Fields with arrow function expression. See references/ARROW_FUNCTIONS_IN_EDIT_FIELDS.md
│
├── Does it need full statements, multiple data sources, or external libs?
│   ├── Are you SURE the above two don't work?
│   │   └── Re-read the parent. The bar is high.
│   └── Yes, genuinely needs it
│       └── Code node. See references/JAVASCRIPT_PATTERNS.md
│
└── Is it actually two separate transformations stitched together?
    └── Use two nodes (Edit Fields → Edit Fields, or Edit Fields → IF). Composability beats one big Code block.
```

For the full decision logic with examples for each branch, see `references/DECISION_TREE.md`.

## What expressions can do that people forget

Common reaches-for-Code-node that should be expressions:

```ts
// ❌ Code node
return { name: $input.first().json.name.toUpperCase() }
````
END THIRD-PARTY FILE e53c962189533228

The third-party file has ended. Everything between the e53c962189533228 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2821 of 12238 bytes. © n8n-io · Apache-2.0 · https://github.com/n8n-io/skills/tree/HEAD/skills/n8n-code-nodes-official/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
