Skip to main content

Claude Code

Claude Code is Anthropic's agentic coding tool that runs in your terminal. It connects to AgentXchain via the local_cli adapter, running claude as a subprocess for each governed turn.

Before you wire Claude Code into a governed role, read the Authority Model. write_authority, local_cli, and Claude's own permission mode are separate axes.

Which adapter?

local_cli — AgentXchain spawns claude as a subprocess, pipes the governed prompt via stdin, and reads the turn result from the staged output.

Prerequisites

  • Claude Code installed and available on your PATH (claude --version)
  • agentxchain CLI installed (npm install -g agentxchain)
  • An ANTHROPIC_API_KEY set in your environment (Claude Code uses this for model access)

Configuration

Add a runtime to your agentxchain.json:

{
"runtimes": {
"claude-dev": {
"type": "local_cli",
"command": ["claude", "--print", "--dangerously-skip-permissions", "--bare"],
"cwd": ".",
"prompt_transport": "stdin"
}
},
"roles": {
"dev": {
"runtime": "claude-dev",
"mandate": "Implement features and fix bugs",
"write_authority": "authoritative"
}
}
}

Key fields

FieldValueWhy
command["claude", "--print", "--dangerously-skip-permissions", "--bare"]--print outputs to stdout (non-interactive). --dangerously-skip-permissions lets Claude write files without confirmation prompts. --bare avoids non-interactive macOS keychain auth hangs; provide ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN in the parent environment.
prompt_transport"stdin"The governed prompt is piped to Claude Code's stdin.
cwd"."Run in the project root so Claude Code sees your repo.

Authority mapping

  • write_authority: use authoritative when Claude Code is expected to write directly into the repo.
  • Runtime type: local_cli.
  • Downstream CLI authority: --dangerously-skip-permissions is the flag that makes unattended local writes possible.

Verify the connection

agentxchain connector check
agentxchain connector validate claude-dev

This probes that the claude binary exists on your PATH. If it fails, check your Claude Code installation.

Minimal working example

agentxchain init --governed --template cli-tool --goal "Build a markdown linter" --dir my-project -y
cd my-project
agentxchain doctor
agentxchain connector check
agentxchain connector validate claude-dev
agentxchain run

Or use the guided interactive path (prompts for template, name, goal, and folder):

agentxchain init --governed

Then update agentxchain.json with the Claude Code runtime above, run agentxchain doctor, agentxchain connector check, and agentxchain connector validate claude-dev, then start agentxchain run.

The governed run will dispatch turns to Claude Code via subprocess. Each turn receives the full dispatch bundle (prompt, context, assignment) via stdin.

Gotchas

  • --dangerously-skip-permissions is required for non-interactive governed runs. Without it, Claude Code will prompt for file-write confirmation and the subprocess will hang.
  • --print is required to get stdout output instead of the interactive TUI.
  • Token budgets: Claude Code manages its own context window internally. AgentXchain's budget.max_tokens_per_turn controls the prompt size sent to Claude Code, not Claude Code's internal context management.
  • Long-running turns: Claude Code may take several minutes for complex tasks. Set timeouts.turn_timeout_ms appropriately (default is 300000ms / 5 minutes).