# n8n-expressions-official

Guides AI agents to write clean n8n expressions inside {{...}} syntax. It enforces node references over naked $json and strips redundant Set nodes.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1900 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-expressions-official/SKILL.md
- Updated: 2026-10-17
- HTML: https://affpapa.org/en/nevibecode/skills/n8n-expressions-official

## What it does

This skill guides coding agents to format n8n JavaScript expressions inside `{{...}}` wrappers. Its core rule is referencing data explicitly by node name using `$('Node Name').item.json.field` instead of raw `$json`. Naked `$json` reads only the current incoming element. That breaks workflows silently when a node clears item context, during merges, or after inserting an intermediate step.

The instructions actively eliminate the common Set-node antipattern. If an extracted field feeds only a single downstream consumer, the expression belongs inside that consumer field. Set nodes earn their place only when two or more nodes share a complex calculation, when filtering output keys with `Include Other Fields: false`, or when standardizing output contracts for sub-workflows.

For dates, the skill instructs agents to use inline Luxon calls like `DateTime.now()` rather than adding standalone DateTime nodes. Missing explicit node names is the primary reason refactored pipelines fail without throwing errors.

## Requirements
- Works with: n8n

## Install

### Claude Code (native platform)

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

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

### Codex

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

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

### Cursor

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

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

### GitHub Copilot

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

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

### Gemini CLI

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

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

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add n8n-io/skills --skill n8n-expressions-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-expressions-official/SKILL.md

## When to use it
- stop expression breakages caused by intermediate workflow nodes
- eliminate redundant Set nodes across n8n canvases
- calculate and format timestamps using Luxon inside expressions
- normalize converging branch shapes before downstream processing

## Example prompts
- Write an n8n expression to extract an email from the Webhook node without using $json
- Format a date seven days in the past using Luxon for this n8n HTTP Request node
- Review this n8n workflow and inline any single-use Set nodes

## 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: e7c53284fe8712e3.

BEGIN THIRD-PARTY FILE e7c53284fe8712e3
```text
---
name: n8n-expressions-official
description: Use when writing or reviewing n8n expressions (`{{...}}` syntax), `$json` / `$node` references, Luxon date code, or expression errors. Triggers on `{{}}`, `$json`, `$node`, `$input`, `DateTime`, `Luxon`, "expression error", "evaluating", "format date", "transform field", or any node-parameter assignment.
---

# n8n Expressions

n8n's expression language is JavaScript embedded in `{{...}}` blocks. They run synchronously, on a single item at a time (`$json`), with access to upstream nodes (`$('Name')`), Luxon for dates, and most of native JS.

## Non-negotiable

**Reference data by node name, not `$json`.** Use `$('Node Name').item.json.field` (or `.first().json.field`). `$json` works but breaks when any node clears item context (Aggregate, Code with Run for All, branching merges) or a refactor adds an intermediate. Failures are silent, and downstream gets the wrong data with no error. Node-name references are stable.

## Strong defaults

- **No Set nodes whose only purpose is to feed a single downstream field.** Inline the expression at the consumer. Set earns its place when 2+ consumers read the same derived value, the derivation is non-trivial, or the Set is a sub-workflow's final return-shaper. See "The Set-node antipattern" below.
- **Luxon for dates, not the DateTime node.** Date math, formatting, and parsing all work in expressions: `{{ DateTime.now().minus({ days: 7 }).toISO() }}`. The DateTime node is more visible on the canvas for beginner human users, but avoid it unless the user specifically asks for it.
- **Expressions over extra nodes generally.** Build the email body in the email node's body field, and compute the URL in the HTTP Request's URL field. Reach for an extra node when the transform is reused or the *primary purpose* of a section.
- **Multi-line expressions are indented and commented.** When an expression spans more than one line, format it like real code. Most n8n users are not coders, so explain the code with concise inline comments

## Why reference by node name (`$('Name').item.json.x`) over `$json.x`

`$json` means "the current item flowing into this node." Fine when the node is directly downstream of one source and nothing has cleared the item context (some nodes do: Aggregate, Code with `Run for All`, branching merges).

It breaks when:

- You insert a node between source and consumer (the consumer was reading `$json.x` from a node 3 steps back, and now the new intermediate node is what `$json` refers to).
```
END THIRD-PARTY FILE e7c53284fe8712e3

The third-party file has ended. Everything between the e7c53284fe8712e3 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 2527 of 21281 bytes. © n8n-io · Apache-2.0 · https://github.com/n8n-io/skills/tree/HEAD/skills/n8n-expressions-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
