claude-code-cli

n8n community node for Claude Code CLI integration - execute AI-assisted coding tasks

Package Information

Downloads: 216 weeklyΒ /Β 1,191 monthly
Latest Version: 1.2.0

Documentation

   _____ _                 _         _____          _
  / ____| |               | |       / ____|        | |
 | |    | | __ _ _   _  __| | ___  | |     ___   __| | ___
 | |    | |/ _` | | | |/ _` |/ _ \ | |    / _ \ / _` |/ _ \
 | |____| | (_| | |_| | (_| |  __/ | |___| (_) | (_| |  __/
  \_____|_|\__,_|\__,_|\__,_|\___|  \_____\___/ \__,_|\___|

           ⚑ for n8n ⚑

n8n-nodes-claude-code-cli

CI
npm
License: MIT
n8n

πŸ€– Bring the power of Claude Code AI directly into your n8n workflows

Automate code reviews β€’ Generate documentation β€’ Fix bugs β€’ Build coding bots

Getting Started β€’
Use Cases β€’
Documentation


✨ Features

🐳 Docker Execution - Run Claude Code in isolated containers πŸ”„ Session Management - Multi-turn conversations across executions
🎯 Tool Permissions - Fine-grained control over allowed tools πŸ“ Context Files - Include files and directories for analysis
🧠 Multiple Models - Opus, Sonnet, Haiku support πŸ“Š Rich Output - Costs, tokens, and session IDs

⚑ Quick Start

1. Install the n8n node

In n8n: Settings > Community Nodes > Install > n8n-nodes-claude-code-cli

2. Deploy Claude Code Runner

n8n installed on host (not in Docker)? Use the standalone setup:

mkdir -p claude-code-runner && cd claude-code-runner && \
curl -fsSL https://raw.githubusercontent.com/ThomasTartrau/n8n-nodes-claude-code-cli/main/docker/production/claude-code/docker-compose.yml -o docker-compose.yml && \
curl -fsSL https://raw.githubusercontent.com/ThomasTartrau/n8n-nodes-claude-code-cli/main/docker/production/claude-code/Dockerfile -o Dockerfile && \
docker compose up -d --build
n8n also running in Docker? Use the complete stack instead

The node uses docker exec to communicate with claude-code-runner. This requires:

  1. Docker CLI installed inside the n8n container
  2. Docker socket mounted to access the Docker daemon

The standard n8nio/n8n image doesn't include Docker CLI, so we provide a custom setup:

mkdir -p n8n-claude-code && cd n8n-claude-code && \
curl -fsSL https://raw.githubusercontent.com/ThomasTartrau/n8n-nodes-claude-code-cli/main/docker/production/n8n-with-claude-code/docker-compose.yml -o docker-compose.yml && \
curl -fsSL https://raw.githubusercontent.com/ThomasTartrau/n8n-nodes-claude-code-cli/main/docker/production/n8n-with-claude-code/Dockerfile.n8n -o Dockerfile.n8n && \
curl -fsSL https://raw.githubusercontent.com/ThomasTartrau/n8n-nodes-claude-code-cli/main/docker/production/n8n-with-claude-code/Dockerfile.claude-code -o Dockerfile.claude-code && \
docker compose up -d --build

This builds a custom n8n image with Docker CLI and deploys both n8n and claude-code-runner together. Access n8n at http://localhost:5678

Already have n8n running in Docker? You can modify your existing setup:

  1. Create a custom Dockerfile for n8n:
FROM docker:29-cli AS docker-cli
FROM n8nio/n8n
USER root
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
RUN chmod +x /usr/local/bin/docker
USER node
  1. Update your docker-compose.yml:
services:
  n8n:
    build: .  # Use the custom Dockerfile above
    user: root  # Required for Docker socket access
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      # ... your other volumes
  1. Deploy claude-code-runner separately using the standalone setup above

Important: Both containers must be managed by the same Docker daemon.

3. Authenticate

docker exec -it claude-code-runner claude login

Follow the browser prompts to complete authentication.

4. Configure n8n credentials

Parameter Value
Connection Type Docker
Container Name claude-code-runner
Working Directory /workspace

5. Start automating πŸš€

Search "Claude Code" in n8n node panel and create your first workflow.


🐳 Configuration

Workspace Setup

You have two options to work with your code:

Option 1: Clone repos inside container (recommended for isolation)

docker exec -it claude-code-runner git clone <repo-url>
# Or use git worktree for multiple branches

Option 2: Mount existing projects

volumes:
  - /path/to/your/project:/workspace/project-name

MCP Servers

Mount your MCP configuration to enable additional tools:

volumes:
  # MCP servers directory
  - ./mcp-servers:/root/.mcp
  # Or mount your local .mcp.json (avoids versioning credentials)
  - ~/.mcp.json:/root/.mcp.json:ro
πŸ” Alternative: SSH deployment

For dedicated VM deployments (AWS EC2, GCP, etc.):

curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt-get install -y nodejs git
npm install -g @anthropic-ai/claude-code
claude login

n8n Credentials:

Parameter Value
Connection Type SSH
Host Your VM IP
Port 22
Auth Method privateKey

βš™οΈ Node Operations

Operation Description Use Case
Execute Prompt Send a prompt and get a response Direct AI interaction
Execute with Context Include files as context Code review, analysis
Continue Session Continue last conversation Multi-turn interactions
Resume Session Resume specific session by ID Continue after interruption
πŸ“ Detailed Parameters

Execute Prompt

  • Prompt (required): Instruction for Claude Code
  • Model: Claude model to use
  • Options: Working directory, timeout, system prompt

Execute with Context

  • Prompt (required): Instruction for Claude Code
  • Context Files: File paths to include
  • Additional Directories: Directory paths

Continue / Resume Session

  • Prompt (required): Follow-up message
  • Session ID (resume only): Previous session ID

πŸ’‘ Use Cases

πŸ” MR/PR Code Review Agent

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GitLab    │────▢│  Get Diff &  │────▢│ Claude Code │────▢│    Post      β”‚
β”‚   Webhook   β”‚     β”‚    Files     β”‚     β”‚   Review    β”‚     β”‚   Comments   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Workflow Steps
  1. Trigger: GitLab/GitHub webhook on new MR/PR
  2. Fetch: Get changed files and diff via API
  3. Review: Claude Code with executeWithContext
    • "Review this code. Check for bugs, security issues, suggest improvements."
  4. Post: Send review comments back to GitLab/GitHub
  5. Notify: Alert team via Slack/Discord (optional)

🎧 Support Assistant

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Support   │────▢│   Analyze    │────▢│ Claude Code │────▢│   Respond    β”‚
β”‚   Ticket    β”‚     β”‚    Issue     β”‚     β”‚   Solution  β”‚     β”‚   or Route   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Workflow Steps
  1. Trigger: Webhook from support system (Zendesk, Intercom)
  2. Analyze: Claude Code understands the issue
    • "User reports: [issue]. Analyze and suggest solution."
  3. Respond: Send AI response back via API
  4. Escalate: Route complex issues to humans

πŸ“š Auto Documentation

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Code     │────▢│  Get Changed │────▢│ Claude Code │────▢│   Commit     β”‚
β”‚    Push     β”‚     β”‚    Files     β”‚     β”‚  Gen Docs   β”‚     β”‚    Docs      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Workflow Steps
  1. Trigger: Webhook on code push to main
  2. Identify: Get list of changed files
  3. Generate: Claude Code generates documentation
    • "Generate docs for this code. Include descriptions, params, examples."
  4. Commit: Create commit with updated docs
  5. PR: Optionally create a PR for review

πŸ› Auto Bug Fixing

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Sentry    │────▢│    Parse     │────▢│ Claude Code │────▢│  Create PR   β”‚
β”‚   Alert     β”‚     β”‚ Stack Trace  β”‚     β”‚   Fix Bug   β”‚     β”‚   + Notify   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Workflow Steps
  1. Trigger: Webhook from error monitoring (Sentry, Datadog)
  2. Analyze: Parse error stack trace
  3. Fix: Claude Code analyzes and fixes
    • "Error: [stack trace]. Analyze code and provide a fix."
  4. Test: Run tests to validate
  5. PR: Create pull request with fix
  6. Notify: Alert team about automated fix

πŸ€– Cloud Coding Bots

Build AI coding assistants on Telegram, Slack, Discord, or GitLab/GitHub.

Examples

πŸ“± Telegram Bot

  1. Trigger: Telegram trigger on new message
  2. Process: Claude Code handles coding question
  3. Reply: Send response via Telegram node

πŸ’¬ Slack Bot

  1. Trigger: Slack mention or slash command
  2. Context: Fetch relevant code from repos (optional)
  3. Respond: Post response to channel

🦊 GitLab/GitHub Bot

  1. Trigger: Issue comment with keyword (e.g., /claude)
  2. Analyze: Fetch issue context and code
  3. Comment: Post Claude's analysis

πŸ“€ Output Structure

{
  "success": true,
  "sessionId": "550e8400-e29b-41d4-a716-446655440000",
  "output": "Here's my analysis of the code...",
  "exitCode": 0,
  "duration": 15234,
  "cost": 0.0523,
  "numTurns": 3,
  "usage": {
    "inputTokens": 1250,
    "outputTokens": 890
  }
}
Field Description
success βœ… Execution completed successfully
sessionId πŸ”— ID for continuing conversations
output πŸ“ Response text from Claude Code
cost πŸ’° Estimated cost in USD
usage πŸ“Š Token breakdown

πŸ”’ Security

πŸ›‘οΈ Tool Permissions

Control what Claude Code can do:

βœ… Allowed: Read, Glob, Grep
❌ Blocked: Bash(rm:*), Write(.env)

🐳 Isolation Best Practices

  • Always set specific working directory
  • Avoid / or home directories
  • Create dedicated workspace per project
πŸ” Recommended Security Settings

Disallow dangerous operations:

  • Bash(rm:*) - Prevent file deletion
  • Bash(sudo:*) - No sudo access
  • Write(.env) - Protect secrets
  • Bash(curl:*) - Block network (if not needed)

🀝 Contributing

Development Setup

git clone https://github.com/ThomasTartrau/n8n-nodes-claude-code-cli.git
cd n8n-nodes-claude-code-cli
npm install && npm run build

# Start n8n + claude-code-runner for testing
docker compose -f docker/development/docker-compose.yml up -d --build

# Authenticate claude-code-runner
docker exec -it claude-code-runner claude login

# Access n8n at http://localhost:5678

Docker Files Structure

docker/
β”œβ”€β”€ development/
β”‚   β”œβ”€β”€ Dockerfile          # n8n with docker CLI (dev)
β”‚   └── docker-compose.yml  # n8n + claude-code-runner (mounts dist/)
└── production/
    β”œβ”€β”€ claude-code/
    β”‚   β”œβ”€β”€ Dockerfile          # Standalone claude-code-runner
    β”‚   └── docker-compose.yml  # For n8n on host (not Docker)
    └── n8n-with-claude-code/
        β”œβ”€β”€ Dockerfile.n8n          # n8n with Docker CLI
        β”œβ”€β”€ Dockerfile.claude-code  # claude-code-runner
        └── docker-compose.yml      # Complete stack (both services)

Submit Changes

git checkout -b feature/amazing-feature
git commit -m 'feat: add amazing feature'
git push origin feature/amazing-feature

πŸ“„ License

MIT License - see LICENSE for details.


GitHub β€’
npm β€’
n8n Community


Made with ❀️ for the n8n community

Discussion