Skip to content

abbibo/N8N-Workflow-Builder-Agent-skills-N8N / skills/04-code-nodes-javascript-python

n8n-code-nodes-javascript-python

Verified

Best practices for writing JavaScript and Python in n8n Code nodes, data access methods, and return contracts.

FileKindSize
JAVASCRIPT_PATTERNS.mdmarkdown606 B
SKILL.mdskill md593 B

JAVASCRIPT_PATTERNS.md

View on GitHub
# N8N JavaScript Code Node Best Practices

## Data Access Syntax
- In `runOnceForAllItems`:
  - Input: `$input.all()` -> returns `Array<{ json: Object, binary?: Object }>`
  - Previous Nodes: `$('Node Name').all()` or `$('Node Name').first().json`
  - Output contract: Must return `Array<{ json: Object }>`
- In `runOnceForEachItem`:
  - Input: `$input.item` -> returns `{ json: Object }`
  - Output contract: Must return `{ json: Object }` or `$input.item`

## Error Handling
Always wrap `JSON.parse` or external string manipulations in a `try / catch` block to avoid unhandled runtime crashes (Rule 72).
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 319kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 319kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 319kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 319kUpdated Claude CodeCodexVerifiedInstall