n8n-workflow-sdk
БесплатноБез исполняемых скриптовНе проверенBuild n8n workflows as TypeScript code with the official @n8n/workflow-sdk package: define nodes and connections, validate them, convert between n8n JSON and…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
n8n Workflow SDK
Overview
@n8n/workflow-sdk is n8n's own TypeScript SDK (it lives in packages/@n8n/workflow-sdk of the n8n monorepo). You declare nodes with a few factory functions, wire them with .add() / .to(), and get standard n8n workflow JSON. It validates workflows, turns existing JSON into SDK code (generateWorkflowCode) and parses SDK code back into JSON (parseWorkflowCode). Checked against 0.39.5 (5 November 2026: the npm latest and stable tags; beta is 0.40.0 and rc 1.1.0). The package is pre-1.0 and changes weekly, so pin an exact version.
The API is generic: there are no per-node helpers such as httpRequest() or code() and no new WorkflowBuilder(). Every node is node({ type, version, config }), and the node's type and version come from n8n (copy them from an exported workflow or generateWorkflowCode).
Instructions
Install
npm install --save-exact @n8n/[email protected]
Building blocks
import {
workflow, node, trigger, ifElse, switchCase, merge, splitInBatches, nextBatch,
languageModel, memory, tool, outputParser, newCredential, fromAi,
expr, nodeJson, sticky,
} from '@n8n/workflow-sdk';
trigger({ type, version, config })starts a workflow;node(...)is any other node;configholdsname,parameters,credentials,position, flags such asexecuteOnce.workflow('id', 'Name').add(trigger).to(nodeA).to(nodeB)builds the graph; call.add(otherTrigger)again for another entry point.ifElse({ version, config })gives.onTrue(x)/.onFalse(y);switchCase(...)gives.onCase(0, x);merge(...)takes branches via.input(0)/.input(1);splitInBatches(...)gives.onEachBatch(...)and.onDone(...), and the loop body ends withnextBatch(loopNode).expr('{{ $json.email }}')marks an n8n expression;nodeJson(someNode, 'body.userId')reads a field from a specific earlier node.- AI nodes: build
languageModel,memory,tool,outputParserinstances and attach them insubnodes: { model, memory, tools: [...], outputParser }on the agent node. - Credentials are never embedded:
newCredential('OpenAI account')is a placeholder you bind in n8n.
A branching workflow
// workflows/lead-routing.ts
import { workflow, node, trigger, ifElse, expr } from '@n8n/workflow-sdk';
const intake = trigger({
type: 'n8n-nodes-base.webhook',
version: 2.1,
config: { name: 'New Lead', parameters: { httpMethod: 'POST', path: 'new-lead', responseMode: 'onReceived' } },
});
const isHot = ifElse({
version: 2.2,
config: {
name: 'Score >= 80?',
parameters: {
conditions: {
options: { caseSensitive: true, leftValue: '', typeValidation: 'strict' },
conditions: [{ leftValue: expr('{{ $json.body.score }}'), operator: { type: 'number', operation: 'gte' }, rightValue: 80 }],
combinator: 'and',
},
},
},
});
const notifySales = node({
type: 'n8n-nodes-base.httpRequest',
version: 4.3,
config: { name: 'Notify Sales', parameters: { method: 'POST', url: 'https://hooks.acme-crm.io/sales', sendBody: true, specifyBody: 'json', jsonBody: expr('{{ JSON.stringify($json.body) }}') } },
});
const addToNurture = node({
type: 'n8n-nodes-base.httpRequest',
version: 4.3,
config: { name: 'Add To Nurture', parameters: { method: 'POST', url: 'https://hooks.acme-crm.io/nurture' } },
});
export const leadRouting = workflow('lead-routing', 'Lead Routing')
.add(intake)
.to(isHot.onTrue!(notifySales).onFalse!(addToNurture));
(onTrue! and onFalse! are only there because the SDK's TypeScript types mark them optional on the node instance; they exist at runtime. The same goes for onCase!.) leadRouting.validate() returns { valid, errors, warnings }; leadRouting.toJSON() returns { id, name, nodes, connections, settings }. The ifElse conditions object must include options, conditions and combinator.
An AI agent with memory and a tool
const support = trigger({ type: 'n8n-nodes-base.webhook', version: 2.1,
config: { name: 'Support Message', parameters: { httpMethod: 'POST', path: 'support', responseMode: 'lastNode' } } });
const model = languageModel({ type: '@n8n/n8n-nodes-langchain.lmChatOpenAi', version: 1.3,
config: { name: 'OpenAI Chat Model', parameters: { model: { __rl: true, mode: 'list', value: 'gpt-4o-mini' } },
credentials: { openAiApi: newCredential('OpenAI account') } } });
const mem = memory({ type: '@n8n/n8n-nodes-langchain.memoryBufferWindow', version: 1.3,
config: { name: 'Window Memory',
parameters: { sessionIdType: 'customKey', sessionKey: nodeJson(support, 'body.userId'), contextWindowLength: 20 } } });
const lookup = tool({ type: 'n8n-nodes-base.httpRequestTool', version: 4.3,
config: { name: 'Lookup Account',
parameters: { toolDescription: 'Look up a customer account by email',
url: expr('htt
Установить n8n-workflow-sdk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл n8n-workflow-sdk?
Build n8n workflows as TypeScript code with the official @n8n/workflow-sdk package: define nodes and connections, validate them, convert between n8n JSON and SDK code, and push the result to an n8n instance. Use when a user asks to create n8n workflows programmatically, generate workflow JSON, version-control workflows, or let an AI agent write n8n workflows.
Как установить скилл n8n-workflow-sdk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл n8n-workflow-sdk запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic