# Build Reliable Python Code Nodes for n8n

Python Code nodes require n8n-specific data access and return formats. This skill provides patterns for transformations, validation, aggregation, webhooks, and standard-library tasks.

## Install

```bash
npx skillstore add sickn33/n8n-code-python
```

## Metadata

- Status: approved
- Slug: sickn33-n8n-code-python
- Skillstore revision: r2
- Version status: missing
- Tree hash: a731f6a979c6776f5f2e3e63b7df32e44ee37f7c8c67256f404f1b514abfa31d
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/n8n-code-python
- Ref: 81e05e636292629114b76cbb3922fbe57672fc02
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 77
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/sickn33-n8n-code-python
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-n8n-code-python/manifest

## Capabilities

- Creates Python templates for all-items and per-item Code node modes.
- Explains n8n input helpers, node references, and webhook body access.
- Provides patterns for transformation, filtering, aggregation, validation, regex, and statistics.
- Produces the list and json wrapper structure required by downstream n8n nodes.
- Identifies unsupported external libraries and suggests suitable n8n alternatives.
- Reviews common return, import, dictionary access, and null-handling errors.

## Use Cases

- Transform Workflow Items: Create a Code node that cleans, maps, and enriches incoming records while preserving n8n output structure.
- Summarize Operational Data: Filter records and calculate totals, counts, averages, or basic statistics without external packages.
- Repair Failing Code Nodes: Diagnose input access, webhook nesting, missing keys, unsupported imports, and invalid return formats.

## Prompt Templates

### Create a Basic Transformation

```
Write an n8n Python Code node that reads all items, maps [fields], adds [new field], and returns the required structure.
```

### Normalize Webhook Data

```
Create Python for an n8n webhook workflow. Read fields from the body safely, normalize [fields], and report missing values.
```

### Validate and Aggregate Records

```
Build an n8n Python Code node that validates [rules], separates invalid records, and calculates [metrics] from valid records.
```

### Design an Advanced Processing Step

```
Review this n8n processing requirement: [requirement]. Select the execution mode, design robust Python logic, and explain limitations and edge cases.
```

## Limitations

- The guidance does not enable external Python packages in n8n.
- It focuses on Code nodes rather than complete workflow design or deployment.
- Generated logic still requires testing with representative workflow data and the installed n8n version.
- Referenced companion guides are not included in this skill package.

## Best Practices

- Test with empty, incomplete, and representative input before deploying the workflow.
- Use safe dictionary access and explicit defaults for optional fields.
- Choose all-items mode for batch work and return a consistent n8n item structure.

## Anti Patterns

- Do not import external packages that the n8n Python runtime does not provide.
- Do not return plain values or dictionaries without the required item wrapper.
- Do not assume webhook fields exist at the top level or are always present.

## Security Audit

- Audited at: 2026-08-04T15:21:08.132\+00:00
- Summary: All 91 static findings are false positives caused by Markdown backticks, documentation links, and benign Python examples. The skill contains no command invocation, suspicious network behavior, obfuscated payload, reconnaissance, or prompt injection.

## Stats

- Views: 176
- Downloads: 11
- Favorites: 0
- Popularity score: 0
