Summary
Implement an AgentAdapter for Claude Code CLI, allowing CodeFrame to delegate code writing to Claude Code as a subprocess while retaining orchestration control.
Parent issue: #408
Motivation
Claude Code is Anthropic's dedicated coding agent with sophisticated tool use, file editing, and project understanding. Rather than replicating its capabilities in CodeFrame's built-in ReactAgent, delegate to it directly and let CodeFrame handle what it does best: orchestration, verification, and lifecycle management.
Scope
New module: core/engines/claude_code.py
ClaudeCodeAdapter implementing AgentAdapter:
class ClaudeCodeAdapter:
name = "claude-code"
requires_api_key = {"ANTHROPIC_API_KEY": "Anthropic API key"}
def execute(self, task_prompt, workspace_path, context, timeout_ms):
# 1. Write task prompt to temp file
# 2. Launch: claude --print --dangerously-skip-permissions -p <prompt>
# with cwd=workspace_path
# 3. Stream stdout, capture file changes
# 4. Parse exit code and output into AgentResult
...
-
Subprocess management:
- Launch Claude Code CLI with appropriate flags
--print mode for non-interactive output
--dangerously-skip-permissions for automated execution (configurable)
- Set
cwd to workspace path
- Capture stdout/stderr
- Enforce timeout via
timeout_ms
-
Output parsing:
- Detect file modifications from Claude Code's output
- Parse success/failure from exit code
- Extract summary from final output
- Detect if Claude Code created a blocker-like question
-
Event streaming:
- Parse Claude Code's streaming output into
AgentEvents
- Forward progress messages to CodeFrame's event system
-
Configuration:
claude_code_path: path to Claude Code binary (default: claude)
claude_code_flags: additional CLI flags
approval_mode: skip (default for automation) or interactive
Key Design Decisions
- Subprocess, not API: Claude Code is a CLI tool, so we launch it as a subprocess. This is the same pattern Symphony uses for Codex.
- Non-interactive by default: For automated batch execution, use
--dangerously-skip-permissions. For single-task interactive use, can be configured otherwise.
- File change detection: After Claude Code exits, diff the workspace to detect what changed (using
git diff or filesystem timestamps).
Acceptance Criteria
Dependencies
Summary
Implement an
AgentAdapterfor Claude Code CLI, allowing CodeFrame to delegate code writing to Claude Code as a subprocess while retaining orchestration control.Parent issue: #408
Motivation
Claude Code is Anthropic's dedicated coding agent with sophisticated tool use, file editing, and project understanding. Rather than replicating its capabilities in CodeFrame's built-in ReactAgent, delegate to it directly and let CodeFrame handle what it does best: orchestration, verification, and lifecycle management.
Scope
New module:
core/engines/claude_code.pyClaudeCodeAdapterimplementingAgentAdapter:Subprocess management:
--printmode for non-interactive output--dangerously-skip-permissionsfor automated execution (configurable)cwdto workspace pathtimeout_msOutput parsing:
Event streaming:
AgentEventsConfiguration:
claude_code_path: path to Claude Code binary (default:claude)claude_code_flags: additional CLI flagsapproval_mode:skip(default for automation) orinteractiveKey Design Decisions
--dangerously-skip-permissions. For single-task interactive use, can be configured otherwise.git diffor filesystem timestamps).Acceptance Criteria
ClaudeCodeAdapterimplementsAgentAdapterprotocol--print -pflagAgentResultStatusAgentEventscf work start <id> --execute --engine claude-codeDependencies
claudebinary)