# thenetworkchuck/n8n-claude-code-guide architecture

> Architecture diagram of the GitHub repository thenetworkchuck/n8n-claude-code-guide, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thenetworkchuck/n8n-claude-code-guide
- Repository: https://github.com/thenetworkchuck/n8n-claude-code-guide

## Overview

1. **Repository purpose**
   - This repo is not an application implementation; it is an integration guide for wiring **n8n** to a remote AI terminal tool, specifically **Claude Code**.
   - The architecture is therefore operational: n8n orchestrates work, and Claude Code runs as a remote command-line agent over SSH.

2. **Primary control plane**
   - **n8n** is the workflow engine and main orchestrator.
   - It owns triggers, branching, retries/timeouts, credential management, and the overall automation graph.
   - In architecture diagrams, n8n should be shown as the central controller coordinating all downstream actions.

3. **Execution boundary**
   - The actual AI execution happens on a **Linux server** reached via **SSH**.
   - Claude Code is installed on that server and invoked as a CLI process, not as an API service.
   - This means the runtime boundary is between n8n’s workflow environment and the remote shell environment.

4. **Remote AI worker**
   - **Claude Code** is the worker process that interprets prompts, accesses local context, and can run tools or agents.
   - It is called in headless mode using `-p` for prompt/response execution.
   - The guide also implies compatibility with other terminal AI tools, but Claude Code is the reference implementation.

5. **Context and file access**
   - The remote server provides Claude with access to **local project files, skills, and context** by running commands in a chosen working directory.
   - This is a key architectural feature: the AI is not just answering from text input; it can inspect the server-side filesystem context.

6. **Workflow data flow**
   - The basic flow is: **n8n trigger or node input → SSH command → Claude response → back to n8n**.
   - n8n passes the prompt into the SSH node, which executes the Claude CLI command remotely and returns stdout/stderr as workflow output.
   - This makes the SSH connection the transport layer for all AI interactions.

7. **State management**
   - Conversation continuity is handled through a **session ID** generated inside n8n, typically by a Code node.
   - The session ID is then forwarded to Claude using `--session-id`, and follow-up requests use `-r` to resume the same session.
   - State is therefore split across n8n-generated identifiers and Claude’s session persistence.

8. **Advanced tool/agent mode**
   - The guide includes an optional “dangerous mode” using `--dangerously-skip-permissions`.
   - This expands the remote worker’s capabilities to run tools, scripts, agents, and external integrations.
   - Architecturally, this is a trust boundary escalation: Claude moves from read/answer mode to tool-execution mode.

9. **Human-facing interface via Slack**
   - A more advanced workflow uses **Slack** as the user interface and n8n as the bridge to the SSH-backed Claude worker.
   - Flow: Slack trigger → session creation → Claude via SSH → response back to Slack → optional resume loop.
   - Slack is an optional presentation layer, not the compute layer.

10. **Operational constraints and failure boundaries**
   - The guide calls out practical issues that shape the architecture: SSH auth, PATH/profile loading, file permissions, command timeouts, and Slack message length limits.
   - These constraints matter because the system depends on shell execution over SSH rather than a native integration API.
   - In diagrams, these should be shown as edge conditions around the SSH/remote-shell boundary.

11. **Infrastructure options**
   - Claude Code can run on the same VPS as n8n, on a dedicated Ubuntu server, on a Raspberry Pi, or on another hosted machine.
   - The important architectural point is that compute is decoupled from orchestration: n8n and the AI worker can be colocated or separate.

12. **What to diagram**
   - The key boxes are: **n8n workflow engine**, **SSH transport**, **remote Linux host with Claude Code**, **local files/context**, and optionally **Slack**.
   - The key arrows are: prompt/context into SSH, Claude output back to n8n, and session IDs flowing through successive runs.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_n8n["n8n<br/>workflow engine"]
  node_slack(("Slack<br/>chat interface"))
  node_session["Session ID<br/>state token"]
end

subgraph group_remote["Remote Execution"]
  node_ssh["SSH<br/>transport"]
  node_host["Linux host<br/>remote shell"]
  node_claude["Claude Code<br/>CLI agent"]
  node_context["Local files<br/>filesystem context"]
  node_tools{{"Dangerous mode<br/>tool access"}}
end

node_slack -->|"trigger/input"| node_n8n
node_n8n -->|"create"| node_session
node_session -.->|"resume token"| node_n8n
node_n8n -->|"prompt + session"| node_ssh
node_ssh -->|"remote command"| node_host
node_host -->|"launch"| node_claude
node_claude -->|"read context"| node_context
node_tools -.->|"escalate"| node_claude
node_claude -->|"stdout/stderr"| node_ssh
node_ssh -->|"result"| node_n8n
node_n8n -->|"reply"| node_slack

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n8n,node_slack,node_session toneBlue
class node_ssh,node_host,node_claude,node_context,node_tools toneAmber
```

## Components

### Orchestration

Workflow control plane and user-facing automation entry points.

- **n8n**: workflow engine · Central orchestrator that triggers workflows, manages branching, retries, credentials, and overall automation flow.
- **Slack**: chat interface · Optional human-facing entry point for conversations and responses.
- **Session ID**: state token · n8n-generated conversation identifier used to resume Claude sessions across runs.

### Remote Execution

SSH-backed Linux host where Claude Code runs as a CLI worker.

- **SSH**: transport · Command transport layer that carries prompts and returns stdout/stderr between n8n and the remote host.
- **Linux host**: remote shell · Remote machine reached over SSH; provides the execution boundary and working directory context.
- **Claude Code**: CLI agent · Headless Claude Code process invoked remotely with prompt/response execution and optional resume support.
- **Local files**: filesystem context · Project files, skills, and other server-side context available to the CLI through the working directory.
- **Dangerous mode**: tool access · Optional permission-escalated mode that allows tool, script, and agent execution on the remote host.

## Connections

- Slack → n8n: trigger/input · Slack messages can start or continue a workflow.
- n8n → Session ID: create · A workflow step generates or updates the conversation session identifier.
- Session ID → n8n: resume token · The session ID is reused by later workflow runs to continue the same conversation.
- n8n → SSH: prompt + session · n8n sends the prompt, session ID, and command parameters into the SSH node.
- SSH → Linux host: remote command · SSH executes the Claude CLI on the remote Linux host.
- Linux host → Claude Code: launch · The host starts Claude Code as a headless CLI process.
- Claude Code → Local files: read context · Claude inspects local files and working-directory context on the remote machine.
- Dangerous mode → Claude Code: escalate · Dangerous mode expands Claude's ability to run tools, scripts, and agents.
- Claude Code → SSH: stdout/stderr · Claude's response is returned through the SSH transport.
- SSH → n8n: result · n8n receives the remote output for branching, retries, formatting, or downstream delivery.
- n8n → Slack: reply · Optional workflow step posts the Claude response back to Slack.
