n8n-code-javascript
하는 일
이 스킬은 n8n 워크플로 안의 작은 JavaScript 코드를 작성하거나 고치는 것을 돕습니다. 자동화 작업에서 맞춤 데이터 처리가 필요한 n8n 사용자를 위한 스킬입니다.
사용하는 경우
- ✓n8n 워크플로에 이미 Code 노드가 있고 편집이나 수정이 필요할 때.
- ✓Code 노드가 필요하지만 내장 n8n 노드로는 작업할 수 없을 때.
- ✓n8n Code 노드가 느리거나 워크플로가 많은 항목을 더 빠르게 처리해야 할 때.
스킬 링크
https://github.com/czlonkowski/n8n-skills/blob/main/skills/n8n-code-javascript/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“필드가 비어 있으면 내 n8n Code 노드에서 오류가 나요. JavaScript를 고쳐 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
내장 노드나 짧은 표현식으로 충분한지 먼저 확인하고, 정말 필요한 작업에만 JavaScript를 작성하도록 에이전트에게 요청합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
JavaScript Code Node
Expert guidance for writing JavaScript code in n8n Code nodes.
Before you write a Code node
A new Code node has to pass this gate first:
- Is there a native node for the job? Check the job-to-node table in
using-n8n-mcp-skills: Filter, IF / Switch, Summarize, Aggregate, Split Out, Merge, Compare Datasets, Remove Duplicates, Sort + Limit, Date & Time, XML / HTML / Extract From File / Convert To File, HTTP Request (pagination, batching) and Crypto cover most reaches for Code. Their configs are inn8n-node-configuration→ NATIVE_NODES.md. - Would a short expression in that node do? One expression, no function body — the helper methods (
.pluck(),.sum(),.unique(),$ifEmpty(),.diffTo()) are inn8n-expression-syntaxand, on n8n-mcp 2.97.0+, intools_documentation({topic: "expression_helpers"}). Several statements inside{{ }}count as code, so they belong here rather than in an Edit Fields field. - Is the job on the closed list? Loops or recursion no node expresses, state across runs
(
$getWorkflowStaticData), parsing no node handles, an allowlisted library, heavy all-items work (thousands of items, stated or measured), or one short Code node (~15 lines) replacing 4+ glue nodes that only reshape data.
If it passes, write the Code node and give it a note, so the next reader (and the review hooks) can see why:
{ "name": "Flatten category tree", "type": "n8n-nodes-base.code", "notes": "Why Code: Split Out considered — the tree has arbitrary depth (recursion)", "notesInFlow": true }
Editing or debugging a Code node that is already there doesn't need the gate, but if the node does a native-node job, say so and offer the native replacement.
Quick Start
// Basic template for Code nodes
const items = $input.all();
// Process data
const processed = items.map(item => ({
json: {
...item.json,
processed: true,
timestamp: new Date().toISOString()
}
}));
return processed;
Essential Rules
- Choose "Run Once for All Items" mode (recommended for most use cases)
- Access data:
$input.all(),$input.first(), or$input.item - Return
[{json: {...}}]— the canonical, mode-portable form. In Run Once for All Items mode n8n also auto-wraps a barereturn {…}object, so that runs too; what genuinely fails is returning a primitive (string/number) ornull. - CRITICAL: Webhook data is under
$json.body(not$jsondirectly) - Built-ins available:
this.helpers.httpRequest()(no auth — the bare$helpersglobal is undefined in the task-runner sandbox, so$helpers.httpRequest()throwsReferenceError: $helpers is not defined), DateTime (Luxon), $jmespath(). Not available:this.helpers.httpRequestWithAuthentication(deny-listed), $env (when N8N_BLOCK_ENV_ACCESS_IN_NODE=true), require() (unless allowlisted). For anything beyond a trivial unauthenticated GET (auth, pagination, retries), prefer the HTTP Request node and keep Code nodes for pure logic. - Instance-allowlisted libraries: Self-hosted instances can allowlist modules via
N8N_RUNNERS_ALLOWED_BUILT_IN_MODULESandN8N_RUNNERS_ALLOWED_EXTERNAL_MODULES(legacy:NODE_FUNCTION_ALLOW_BUILTIN/NODE_FUNCTION_ALLOW_EXTERNAL). If the user says their instance allows specific modules (e.g.axios,lodash,crypto), use them viarequire()— don't refuse. If unsure, ask or default to built-ins only. - Wrong skill? If you're writing code for a Custom Code Tool attached to an AI Agent (
@n8n/n8n-nodes-langchain.toolCode), stop — that node has a different contract (input viaquery, must return a string, no$input/$helpers). Use the n8n-code-tool skill.
Mode Selection Guide
The Code node offers two execution modes. Choose based on your use case:
Run Once for All Items (Recommended - Default)
Use this mode for: 95% of use cases
- How it works: Code executes once regardless of input count
- Data access:
$input.all()oritemsarray - Best for: logic that needs every item at once and passed the gate above
- Performance: Faster for multiple items (single execution)
// Example: running balance — each item depends on the ones before it,
// which no native node expresses (Summarize gives one total per group, not a running one)
let balance = 0;
return $input.all().map(item => {
balance += item.json.amount |
자주 묻는 질문
항상 Code 노드를 써야 하나요?
아니요. 이 스킬은 내장 노드와 간단한 표현식을 먼저 써 보라고 말합니다.
다른 n8n 노드에도 도움이 되나요?
네. 이미 처리하는 작업에는 Filter, Merge, Summarize 같은 내장 노드를 가리킵니다.
Code 노드에 메모를 추가하나요?
네. 이 스킬은 새 Code 노드에 메모를 붙여서 다음 사람이 이해할 수 있게 하라고 요청합니다.
상세 정보
작성자의 원본 설명
Write, review, or debug JavaScript in an n8n Code node. Use when a Code node is already in the workflow (editing it, fixing an error, choosing its mode, making it faster), or when a new one is justified: no native node fits (check the job-to-node table in using-n8n-mcp-skills first) and the job is on the closed list — loops or recursion no node expresses, state across runs, parsing no node handles, an allowlisted library, heavy all-items work, or one short node replacing 4+ glue nodes. Covers $input/$json/$node in code, this.helpers, Luxon, SplitInBatches loops, cross-iteration data, pairedIte
repo: czlonkowski/n8n-skills
인기도
- GitHub 스타
- 6.6k
- 순위
- #13868
- 라이선스
- MIT
- 업데이트
- 2026. 10. 24.
댓글
- …