agentleFS
tmolavitmolavi/n8n-agent-skills/skills/n8n-expressions/SKILL.md

n8n-expressions

Skill1 starsChanged 3 months agoMITView on GitHub

Use when writing or debugging n8n expressions (`{{ }}`), `$json`, `$('Node')`, `$input`, Luxon/DateTime, field mapping, or "expression error" / wrong data after Merge.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Expressions over extra nodes: when the transform is local to one parameter.

    line 24
  2. Very specific:

    When branches converge and downstream needs a stable ref, insert a NoOp named e.g.

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

n8n Expressions

Author: Taghi Molavi

Non-negotiable

Prefer $('Node Name').item.json.field (or .first() / .last() / .all()) over bare $json for anything that must survive refactors.
$json breaks silently when intermediates, Aggregate, certain Code modes, or Merge change item context.

Strong defaults

  1. No single-consumer Set nodes — inline the expression at the destination unless 2+ consumers share a heavy derivation or the Set is a sub-workflow output shaper.
  2. Luxon in expressions for dates — {{ DateTime.now().minus({ days: 7 }).toISO() }} — avoid DateTime node unless the user wants it visible.
  3. Expressions over extra nodes when the transform is local to one parameter.
  4. Multi-line expressions: indent + short comments (many n8n users are not engineers).

Core APIs

{{ $json.email }}
{{ $('Fetch User').item.json.id }}
{{ $input.all() }}
{{ $input.first().json }}
{{ $now }}  {{ $today }}
{{ DateTime.fromISO($json.created).toFormat('yyyy-LL-dd') }}
{{ $json.items.map(i => i.name).join(', ') }}

Merge / branch stability

When branches converge and downstream needs a stable ref, insert a NoOp named e.g. Combine Inputs and reference $('Combine Inputs').

Common failures

SymptomLikely cause
undefined fieldWrong node name, or used $json after context clear
Works in test, fails in prodDifferent item counts / empty branch
Expression error luxonInvalid ISO string; guard with ternary
Array treated as objectNeed .first() or explicit index

Pair with

  • n8n-code-nodes when expression length/complexity explodes
  • n8n-debugging for silent wrong values

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.