Tooluck logoTooluck
SKILL.md

n8n-code-python

Agent skill fromczlonkowski/n8n-skills

Write Python in n8n Code nodes (native Python, `language` pythonNative, n8n 2.x). Use when the user explicitly wants Python in a Code node, when migrating old Pyodide/"Python (Beta)" code that used _input/_json/_node/_now, or when a Python Code node fails with NameError, "Security violations detected", "Import of standard library module … is disallowed", "__build_class__ not found", "A 'json' property isn't a dictionary", or "Python runner unavailable". Covers the only two variables (_items/_item), dict-only access, imports blocked by default, the sandbox's denied builtins, accepted return shapes, and how errors interact with onError. JavaScript is the default for Code nodes — native Python has no n8n helpers and, by default, no imports. EXCEPTION — for Python in the AI-agent-callable Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode), use the n8n-code-tool skill instead (input is _query, return must be a string).

How to install n8n-code-python

install n8n-code-python
# install the n8n-skills pack with the skills CLI
npx skills add czlonkowski/n8n-skills

# or add only this skill to Claude Code: copy the folder

skills/n8n-code-python/

# into

~/.claude/skills/n8n-code-python/ (all projects)

.claude/skills/n8n-code-python/ (one project)

skills/n8n-code-python/SKILL.md

MITFull file
1# Python Code Node (native)
2
3Since n8n 2.0 the Code node's Python runs as **native Python in a task runner** (`language:
4"pythonNative"`). The old Pyodide "Python (Beta)" is gone, and with it every n8n helper it had:
5`_input`, `_json`, `_node`, `_now`, `_today` and `_jmespath` all raise `NameError` now. Code copied
6from old templates, forum posts or older docs usually breaks on this.
7
8---
9
10## JavaScript first — stronger than before
11
12Native Python gives you two variables and plain Python, and **by default no imports**: no
13`json`, `datetime` or `re`. Everything n8n-specific (`$('Node')`, `$jmespath`, Luxon,
14`this.helpers.httpRequest`, static data) exists only in JavaScript. Use Python only when the user
15explicitly asks for it. Even then, first check whether an expression, Edit Fields, or a native
16node (Crypto, Date & Time, HTML, XML) does the job. See **n8n-code-javascript** and the transform
17gatekeeper in **n8n-expression-syntax**.
18
19---
20
21## Quick start
22
23```python
24# Run Once for All Items (default mode)
25return [
26 {"json": {"name": it["json"]["name"], "revenue": it["json"]["revenue"]}}
27 for it in _items
28 if it["json"].get("active")
29]
30```
31
32```python
33# Run Once for Each Item
34row = _item["json"]
35return {"json": {**row, "name_upper": (row.get("name") or "").upper()}}
36```
37
38Node config: `{"language": "pythonNative", "mode": "runOnceForAllItems" | "runOnceForEachItem",
39"pythonCode": "..."}` on `n8n-nodes-base.code` typeVersion 2.
40
41---
42
43## The only inputs: `_items` and `_item`
44…

Excerpt shown under the repository's MIT license.

More skills in n8n-skills

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates