n8n-code-python

n8n-code-python is a skill for Claude Code from czlonkowski/n8n-skills. It costs 228 tokens per session (3,001 once invoked), scanned A, a copy of n8n-code-python, MIT.

Guidance for writing Python in n8n Code nodes, which are steps in an n8n workflow that transform data. It covers n8n's Python input and output format and its limitations, while recommending JavaScript for many cases.

In plain words
What is it for?
Use it to transform workflow data, access incoming items, handle webhook data, and return correctly formatted results from an n8n Python Code node.
Why use it?
Python Code nodes do not use the same data access and return rules as ordinary Python scripts. Following the expected structure helps avoid invalid workflow results.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the n8n-mcp-skills plugin — 15 skills shipped together , and of n8n-mcp-skills

Good fit Use it to transform workflow data, access incoming items, handle webhook data, and return correctly formatted results from an n8n Python Code node.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/czlonkowski/n8n-skills/n8n-code-python
About the project

n8n-skills is a collection of Claude Code skills and hooks that guide AI assistants in creating, validating, and deploying n8n workflows through the n8n-mcp server. Developers use it to automate workflow construction, configure nodes and expressions, resolve validation errors, and operate self-hosted n8n. The catalogue entries are its skills, hooks, plugins, and instruction.

czlonkowski/n8n-skills · 6,444 stars · on GitHub · n8n-skills.com

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add czlonkowski/n8n-skills --skill n8n-code-python
Clone the repo
git clone --depth 1 https://github.com/czlonkowski/n8n-skills

Made for: Claude Code.

Or install n8n-mcp-skills, the plugin that ships this one along with the rest of its 15 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for n8n-code-python

README.md
[![agentmods](https://agentmods.dev/badge/skills/czlonkowski/n8n-skills/n8n-code-python/github.svg)](https://agentmods.dev/skills/czlonkowski/n8n-skills/n8n-code-python)
Your own site
<a href="https://agentmods.dev/skills/czlonkowski/n8n-skills/n8n-code-python"><img src="https://agentmods.dev/badge/skills/czlonkowski/n8n-skills/n8n-code-python/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for n8n-code-python

Your own site · 80×15
<a href="https://agentmods.dev/skills/czlonkowski/n8n-skills/n8n-code-python"><img src="https://agentmods.dev/badge/skills/czlonkowski/n8n-skills/n8n-code-python.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 228 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,001 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 17 Sept 2026
  • Snyk pass 17 Sept 2026
How audits are shown
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00228 $0.03001
Opus 5.5 $0.00091 $0.01200
Sonnet 5.5 $0.00046 $0.00600
Haiku 4.5 $0.00023 $0.00300

Measured 1mo ago against content hash 11f673926b25, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

n8n-code-python scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to n8n-code-python — 572 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/n8n-code-python/SKILL.md · 214 lines

How it starts

The opening of the file, as written. The whole thing — 214 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Code Node (native)

Since n8n 2.0 the Code node's Python runs as native Python in a task runner (language: "pythonNative"). The old Pyodide "Python (Beta)" is gone, and with it every n8n helper it had: _input, _json, _node, _now, _today and _jmespath all raise NameError now. Code copied from old templates, forum posts or older docs usually breaks on this.


JavaScript first — stronger than before

Native Python gives you two variables and plain Python, and by default no imports: no json, datetime or re. Everything n8n-specific ($('Node'), $jmespath, Luxon, this.helpers.httpRequest, static data) exists only in JavaScript. Use Python only when the user explicitly asks for it. Even then, first check whether an expression, Edit Fields, or a native node (Crypto, Date & Time, HTML, XML) does the job. See n8n-code-javascript and the transform gatekeeper in n8n-expression-syntax.


Quick start

# Run Once for All Items (default mode)
return [
    {"json": {"name": it["json"]["name"], "revenue": it["json"]["revenue"]}}
    for it in _items
    if it["json"].get("active")
]
# Run Once for Each Item
row = _item["json"]
return {"json": {**row, "name_upper": (row.get("name") or "").upper()}}

Node config: {"language": "pythonNative", "mode": "runOnceForAllItems" | "runOnceForEachItem", "pythonCode": "..."} on n8n-nodes-base.code typeVersion 2.


The only inputs: _items and _item

Mode Variable Shape
Run Once for All Items _items list of plain dicts {"json": {...}, "pairedItem": {...}}
Run Once for Each Item _item one plain dict {"json": {...}, "pairedItem": {...}}
  • Each variable exists only in its own mode. _items in each-item mode (or _item in all-items mode) raises NameError.
  • Dict access only. it["json"]["name"] or it["json"].get("name"). it.json.name raises AttributeError: 'dict' object has no attribute 'json'.
  • No other nodes. There is no _node / $('Node') equivalent. If you need data from another branch, bring it in with Merge first, or read it in JavaScript.
  • Webhook payloads are under ["body"]: _items[0]["json"].get("body", {}).get("email").
  • Binary data isn't covered here. Read and write binary in JavaScript (see n8n-binary-and-data).
  • pairedItem: returning _items / _item keeps it. When you build new dicts and downstream uses $('Node').item, add "pairedItem": {"item": i} to each returned item. That isn't verified on native Python yet, so test-run before relying on it.
  • Missing keys: prefer .get(key, default). row["missing"] raises KeyError.

Read the full file on GitHub · 214 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -288 lines · +71 tokens per session scan C → A 11f673926b25
  2. 1mo ago First seen · 502 lines · 157 tokens per session scan C cae740351f90

Subscribe to this mod's changes

n8n-code-python is a skill published in the GitHub repository czlonkowski/n8n-skills (6,444 stars, last pushed yesterday), licensed MIT. It adds 228 tokens to every session and 3,001 once invoked, about $0.0009 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to n8n-code-python, differing in 572 lines, and is treated as a copy.

Related

Other skills, from other repositories

n8n-code-python

Write Python code in n8n Code nodes. Use when writing Python in n8n, using input/json/node syntax, working with standard library, or need to understand Python limitations in n8n Code nodes.

neurawork-git/n8n-autopilot · 52 tokens

n8n-code-python

Write Python code in n8n Code nodes. Use when writing Python in n8n, using input/json/node syntax, working with standard library, or need to understand Python limitations in n8n Code nodes. Use this skill when the user specifically requests Python for an n8n Code node. Note — JavaScript is recommended for 95% of use…

czlonkowski/n8n-mcp · 157 tokens

n8n-code-javascript

Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.

neurawork-git/n8n-autopilot · 63 tokens

n8n-code-python

Write correct Python for n8n Code nodes. Use Python when you need libraries or prefer Python syntax.

walidboulanouar/n8n-claude-code-template · 0 tokens

matlab

Builds, reviews, migrates, and plans MATLAB or GNU Octave numerical workflows. Use for arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 44 tokens

pennylane

Builds and differentiates PennyLane quantum circuits, hybrid PyTorch or JAX models, molecular VQE and QAOA workflows. Use for variational quantum algorithms, quantum machine learning, simulator validation, and moving validated circuits to provider plugins. For hardware-specific compilation use qiskit or cirq; for…

K-Dense-AI/scientific-agent-skills · 74 tokens