n8n-code-python
Skill18 starsChanged 42 days agoMITView on GitHub
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.
24 other projects use a version of this, 17 of them edited.
Adopted by
Most recently taken up by
- delorenj/skillstheir own version, first seen Nov 7, 2026
- Mfrostbutter/n8n-workflow-harnesstheir own version, first seen Nov 1, 2026
- xfstudio/skillsedited, first seen Oct 13, 2026
- WilkoMarketing/antigravity-n8n-skillstheir own version, first seen Oct 6, 2026
- nomdedev/agent-manager-templatetheir own version, first seen Sep 30, 2026
- jawwad-ali/claude-code-skillsedited, first seen Sep 5, 2026
Used with
Projects with it also use n8n-code-tool, n8n-multi-instance and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
czlonkowskiSkilln8n-code-tool
Write JavaScript or Python for the n8n Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode) — the AI-agent-callable tool, NOT the workflow Code node. Use when building a Code Tool attached to an AI Agent, writing code that an LLM will invoke, parsing the `query` input, returning a string result, defining an input schema for structured arguments (specifyInputSchema, jsonSchemaExample, DynamicStructuredTool), or troubleshooting errors like \"Wrong output type returned\", \"No execution data available\", \"The response property should be a string, but it is an object\", \"Cannot assign to read only property 'name'\", or an AI agent that refuses to call the tool. Covers the critical differences between Code node and Code Tool: return format (string vs `[{json:{...}}]`), unavailability of `$fromAI`/`$input`/`$helpers` in the Code Tool sandbox, naming rules for AI invocation, and when to use `toolWorkflow`/HTTP Request Tool instead.
Also in 3 projects that use this
czlonkowskiSkilln8n-multi-instance
Use when an n8n-mcp account targets more than one n8n instance — i.e. the `n8n_instances` tool is available, the user mentions multiple n8n instances or environments (prod vs staging, several teams or clients), several agents or chats work on one account in parallel, a workflow / datatable / credential / execution call returns an unexpected NOT_FOUND or reads data you don't recognize, or a call is refused with `INSTANCE_AMBIGUOUS` or `INSTANCE_NOT_FOUND`. Covers naming the target instance on each call with the `instance` argument, setting the default with `switch`, verifying the target before high-stakes work — credential writes above all — and recovering from misroutes and fail-closes. Always consult this skill before operating on a specific instance, before any credential create/update/delete on a multi-instance account, or when a call hits the wrong/empty data or an instance error.
Also in 3 projects that use this
tmolaviSkilln8n-agents
Use when building n8n AI Agent / LangChain clusters — tools, memory, RAG, structured output, system prompts, sub-workflow-as-tool, or fixing agent connection topology (ai_languageModel, ai_tool, ai_memory).
Also in 3 projects that use this
tmolaviSkilln8n-error-handling
Use for production n8n workflows, webhook APIs, retries, error outputs, error workflows, dead-letter patterns, and correct HTTP response status shapes for callers.
Also in 3 projects that use this
BlockSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Also in 4 projects that use this
- +3 more from czlonkowski
- +1 more from tmolavi
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 17
- leadgenjay/claude-skills★ 2211% same
- eugenepyvovarov/mcpbundler-agent-skills-marketplace★ 1211% same
- CarbeneAI/Forge★ 911% same
- promptadvisers/n8n-powerhouse★ 911% same
- reachmeshailesh-boop/codex-skill-pack★ 911% same
- xfstudio/skills★ 911% same
- echoleesong/claude-skills-plugin★ 411% same
- jawwad-ali/claude-code-skills★ 411% same
- ai4brands-design/claude-skills★ 211% same
- Wagner-Emden-IT-Services/n8n-project-template★ 111% same
7 more not listed
Wrote their own version · 7
- czlonkowski/n8n-skills★ 6.5ksame name
- WilkoMarketing/antigravity-n8n-skills★ 106same name
- walidboulanouar/n8n-claude-code-template★ 19same name
- delorenj/skills★ 17same name
- nomdedev/agent-manager-template★ 2same name
- tygwan/skills★ 1same name
- Mfrostbutter/n8n-workflow-harness★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository25 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- build-stack-v2Skill
- build-workflowSkill
- build-workflow-v2Skill
- check-mcpsSkill
- data-tablesSkill
- deploySkill
- feedbackSkill
- find-credentialSkill
- find-projectSkill
- init-repoSkill
- inventorySkill
- mirror-syncSkill
- n8nac-cheatsheetSkill
- n8nac-referenceSkill
- n8n-code-javascriptSkill
- n8n-modeSkill
- n8n-orchestration-patternsSkill
- n8n-structured-extractionSkill
- plugin-testingSkill
- pull-schemasSkill
- session-envSkill
- stack-intakeSkill
- sync-credentialsSkill
- test-manualSkill
The file
We split this skill into the rules it gives an agent
4 rules. 2 are common, 1 is distinctive, and 1 is very specific to this project.
2
Common
Most of the 24 edited versions we read keep these.
1
Distinctive
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
- Common: line 15
Use JavaScript for 95% of use cases: Only use Python when:
- Common: line 149
Use Python (Beta) for better n8n integration.
- Very specific: line 205
Always use .get() for dictionary access
- Distinctive: line 207
Use list comprehensions for filtering
“Common” is measured: kept by at least 6 in 10 of the 24 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Code Node (Beta)
Expert guidance for writing Python code in n8n Code nodes.
JavaScript First
Use JavaScript for 95% of use cases. Only use Python when:
- You need specific Python standard library functions (e.g.
statistics) - You're significantly more comfortable with Python syntax
- You're doing data transformations better suited to Python
JavaScript has $helpers.httpRequest(), Luxon DateTime, and better n8n docs.
Quick Start
# Basic template for Python Code nodes
items = _input.all()
processed = []
for item in items:
processed.append({
"json": {
**item["json"],
"processed": True,
"timestamp": datetime.now().isoformat()
}
})
return processedEssential Rules
- Consider JavaScript first
- Access data:
_input.all(),_input.first(),_input.item - CRITICAL: Return
[{"json": {...}}]format - CRITICAL: Webhook data is under
_json["body"] - CRITICAL LIMITATION: No external libraries — no requests, pandas, numpy
CRITICAL: No External Libraries
# ❌ NOT AVAILABLE
import requests # ModuleNotFoundError
import pandas # ModuleNotFoundError
# ✅ AVAILABLE (standard library only)
import json
import datetime
import re
import base64
import hashlib
import urllib.parse
import math
import random
import statisticsWorkarounds:
- Need HTTP requests? → Use HTTP Request node before Code node (or switch to JavaScript)
- Need pandas? → Use
statisticsmodule for basic stats, or switch to JavaScript
Data Access
# All items
all_items = _input.all()
# First item
first_item = _input.first()
data = first_item["json"]
# Each item mode
current_item = _input.item
# Other nodes
webhook_data = _node["Webhook"]["json"]
http_data = _node["HTTP Request"]["json"]CRITICAL: Webhook Data
# ❌ WRONG
name = _json["name"] # KeyError!
# ✅ CORRECT
name = _json["body"]["name"]
# ✅ SAFER
name = _json.get("body", {}).get("name", "Unknown")Return Format
# ✅ Single result
return [{"json": {"field": value}}]
# ✅ List comprehension
return [{"json": item["json"]} for item in _input.all()]
# ✅ Empty
return []WRONG: return {"json": {...}} (no list), return [{"field": value}] (no json key)
Python Modes
Python (Beta) — Recommended
Uses _input, _json, _node, _now helpers.
items = _input.all()
now = _now # Built-in datetime
return [{"json": {"count": len(items), "timestamp": now.isoformat()}}]Python (Native) (Beta)
Uses _items, _item only — no helpers.
return [{"json": item["json"]} for item in _items]Use Python (Beta) for better n8n integration.
Common Patterns
Filtering + Aggregation
items = _input.all()
total = sum(item["json"].get("amount", 0) for item in items)
valid = [item for item in items if item["json"].get("amount", 0) > 0]
return [{"json": {"total": total, "count": len(valid)}}]String Processing with Regex
import re
all_emails = []
for item in _input.all():
emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', item["json"].get("text", ""))
all_emails.extend(emails)
return [{"json": {"emails": list(set(all_emails)), "count": len(set(all_emails))}}]Statistical Analysis
from statistics import mean, median, stdev
values = [item["json"].get("value", 0) for item in _input.all() if "value" in item["json"]]
if values:
return [{"json": {"mean": mean(values), "median": median(values), "stdev": stdev(values) if len(values) > 1 else 0}}]
else:
return [{"json": {"error": "No values found"}}]Top 5 Mistakes
- Importing external libraries → Use HTTP Request node or switch to JavaScript
- No return statement → Always return a list
- Wrong return format → Must be
[{"json": {...}}] - Direct dict access → Use
.get()to avoid KeyError - Webhook body →
_json["email"]❌ →_json["body"]["email"]✅
Best Practices
- Always use
.get()for dictionary access - Handle None explicitly:
value = item["json"].get("x") or 0 - Use list comprehensions for filtering
- Return consistent structure from all code paths
- Debug with
print()(appears in browser console)
Standard Library Quick Reference
import json # json.loads(), json.dumps()
from datetime import datetime, timedelta # datetime.now(), timedelta(days=1)
import re # re.findall(), re.sub()
import base64 # base64.b64encode(), b64decode()
import hashlib # hashlib.sha256(text.encode()).hexdigest()
import urllib.parse # urllib.parse.urlencode(), urlparse()
from statistics import mean, median, stdevDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

