Description
@oden-kun/n8n-nodes-claude-code
Run the local Claude Code CLI from n8n workflows.
This is an unofficial n8n community node that wraps claude -p. It does not use the Anthropic SDK and it does not provide a hosted Claude Code runtime. The claude executable must be installed, authenticated, and available in the same environment where n8n runs.
This project is not affiliated with, endorsed by, or sponsored by Anthropic. Anthropic and Claude are trademarks of Anthropic.
Features
- Run prompts through
claude -pfrom an n8n workflow. - Return plain text, raw stream JSON events, or a parsed structured summary.
- Configure model, working directory, continuation mode, system prompt mode, and permission mode.
- Pass Claude Code CLI options such as allowed tools, disallowed tools, MCP config, settings, additional directories, max turns, and budget limits.
- Capture stderr and process failures as n8n node errors.
- n8n with community nodes enabled.
- Node.js 20.15 or newer.
- Claude Code CLI installed where n8n runs.
- Claude Code CLI authenticated for the same OS user or container user that runs n8n.
Requirements
From the n8n runtime environment, this command should work:
claude --help
Installation
Install the package from n8n’s Community Nodes settings:
@oden-kun/n8n-nodes-claude-code
For manual self-hosted installs, install it into the n8n environment:
npm install @oden-kun/n8n-nodes-claude-code
Restart n8n if your deployment does not reload community nodes automatically.
Quick Start
Add a Claude Code node to a workflow and choose Run Prompt.
Common settings:
Prompt: the instruction passed to Claude Code.Output Format: choose Structured, Text, or Raw Stream JSON.Working Directory: used as the spawned claude process cwd.Continuation Mode: start a new conversation, continue the most recent conversation, or resume by session ID.System Prompt Mode: use the default prompt, append to it, or replace it.Permission Mode: forwarded to Claude Code CLI.For most workflows, start with Structured output. It gives downstream nodes stable fields without forcing them to parse Claude Code stream JSON events directly.
Output Formats
Structured returns a parsed object with fields such as:
finalResult: the final response text.sessionId: the Claude Code session ID when available.model, stopReason, usage, modelUsage, and isError: run metadata.numTurns, durationMs, durationApiMs, and totalCostUsd: execution metrics when available.messages: extracted assistant and user message events.toolUses: extracted tool use events.toolResults: extracted tool result events.permissionDenials, rateLimit, and terminalReason: additional metadata when available.Text returns the final CLI stdout as text.
Raw Stream JSON returns every parsed stream JSON event as events.
Docker and Self-Hosted Notes
When n8n runs in Docker, this node runs inside the n8n container too. The container needs:
claude binary available on PATH, or a custom binary path set in the node options;For example, if a workflow sets Working Directory to /data/project, that path must exist inside the n8n container, not only on the host.
Security
This node executes claude -p on the n8n server or inside the n8n container. Treat it like any workflow step that can run commands or modify files in its execution environment.
Bypass All Permissions unless n8n already runs in a separate locked-down environment.Allowed Tools rules, writable directories, MCP config, and settings files.Environment Variables parameter. Prefer host or container environment configuration, mounted Claude Code configuration, or your platform’s secret management.Development
Install dependencies:
npm install
Run checks:
npm run lint
npm run build
npm run check
Run the smoke test only in an environment where claude is installed and authenticated:
npm run smoke
License
MIT