n8n-code-python

Enforce correct n8n Python Code node input, webhook, and return formatting.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/HustleDanie/n8n-claude-kit --skill n8n-code-python-hustledanie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/HustleDanie/n8n-claude-kit/tree/main/skills/n8n-code-python
Command: npx skills add https://github.com/HustleDanie/n8n-claude-kit --skill n8n-code-python-hustledanie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents broken n8n Python Code node executions by teaching the correct input/output conventions, webhook data access, and “no external libraries” constraint so your workflows don’t fail at runtime.

Core Features & Use Cases

  • Avoid the no-external-libraries trap: Uses only Python’s standard library and routes HTTP/IO-heavy work to n8n nodes or JavaScript when needed.
  • Correct n8n data access patterns: Teaches how to use _input.all(), _input.first(), and _input.item, plus how to safely read webhook payloads from _json["body"].
  • Correct return shape for Code nodes: Ensures you always return the required list-of-items format [{"json": {...}}].
  • Error-proofing and templates: Covers common failure modes (ModuleNotFoundError, KeyError, IndexError, missing return, incorrect return format) and provides production-tested transformation patterns (filtering, parsing, aggregation, normalization).

Quick Start

Ask for: “Show a Python Code node snippet that filters the incoming items for status=active, adds a processed_at timestamp, and returns results in the exact [{'json': ...}] format using _input.all() without external libraries.”

Frequently Asked Questions about n8n-code-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my n8n Python Code node workflow fail with a ModuleNotFoundError?

Your n8n Python Code node workflow fails with a ModuleNotFoundError because the node environment is restricted to Python's standard library only. You must avoid external libraries and route HTTP or IO-heavy operations to standard n8n nodes or JavaScript instead.

How do I access incoming webhook payload data in an n8n Python Code node?

To access webhook payload data in an n8n Python Code node, you must read the payload from the `_json["body"]` object. This specific data access pattern ensures your workflow correctly parses incoming webhook records without triggering runtime KeyErrors.

What is the correct return format for a Python Code node in n8n?

The correct return format for a Python Code node in n8n is a list of items structured as `[{"json": {...}}]`. Ensuring your Python logic returns this exact format prevents missing return errors and failed workflow executions.

How do I iterate through and transform incoming items in an n8n Python Code node?

To iterate through and transform incoming items in an n8n Python Code node, use the `_input.all()` helper to fetch every item. You can then apply standard-library-only Python logic to filter, normalize, or aggregate fields before returning the required list format.

Can I use external Python libraries for data transformation in n8n workflows?

You cannot use external Python libraries for data transformation in n8n workflows because the Python Code node enforces a standard-library-only constraint. To perform specialized data transformation, rely on built-in Python functions or delegate the task to other n8n nodes.