Claude Code Engine
The Claude Code engine invokes Anthropic's claude CLI.
Prerequisites
- Install Claude Code:
~/.local/bin/claudeor available on PATH - Authenticate:
claude auth loginor setANTHROPIC_API_KEYenvironment variable
Configuration
# golem.yaml
name: my-bot
engine: claude-code
model: claude-sonnet-4-6 # optional, see below
skipPermissions: true # default: trueChoosing a Model
Model names are Anthropic model IDs, passed directly as --model to the claude CLI.
List available models:
claude modelsLatest models:
| Model ID | Alias | Description |
|---|---|---|
claude-opus-4-6 | claude-opus-4-6 | Most capable, best for complex tasks |
claude-sonnet-4-6 | claude-sonnet-4-6 | Balanced speed and intelligence — recommended |
claude-haiku-4-5-20251001 | claude-haiku-4-5 | Fastest, lightweight |
See the full and up-to-date list at Anthropic model documentation.
Override at runtime — pass model to createAssistant():
const bot = createAssistant({ dir: './my-bot', model: 'claude-opus-4-5' })How It Works
CLI Invocation
claude -p "<prompt>" \
--output-format stream-json \
--verbose \
--dangerously-skip-permissionsOptional flags:
--resume <sessionId>— resume a previous session--model <model>— specify model
The --verbose flag is required for intermediate stream events (tool calls, tool results).
Permission Bypass
skipPermissions defaults to true. When enabled, --dangerously-skip-permissions is passed to the CLI. A one-time warning is emitted to stderr. Set skipPermissions: false in golem.yaml to disable this behavior (the agent will prompt for permission on certain actions).
Skill Injection
Skills are symlinked into .claude/skills/:
my-bot/
├── .claude/
│ └── skills/
│ ├── general -> ../../skills/general
│ └── im-adapter -> ../../skills/im-adapter
├── CLAUDE.md -> AGENTS.md
└── skills/
├── general/
└── im-adapter/Additionally, CLAUDE.md is created as a symlink to AGENTS.md, allowing Claude Code to read the auto-generated assistant context.
Output Parsing
Claude Code emits clean JSON (no ANSI codes). The parser handles:
assistantmessages — text content blocks andtool_useblocksusermessages —tool_resultblocksresultmessages — final result withcostUsd(total_cost_usd) andnumTurns(num_turns)
Cost & Turn Tracking
Claude Code is the only engine that provides per-conversation cost and turn count in the done event:
{ type: 'done', sessionId: '...', durationMs: 12345,
costUsd: 0.042, numTurns: 3 }Environment
GolemBot deletes CLAUDECODE and CLAUDE_CODE_ENTRYPOINT environment variables before spawning, to allow nested invocations of Claude Code.
Notes
- The
CLAUDE.mdsymlink is the standard way Claude Code discovers project instructions — by pointing it toAGENTS.md, the agent sees the full skill list and conventions on startup - Session resume failures are automatically handled with a fresh session fallback