Prerequisites
- Claude Code installed and on your PATH as
claude. Install instructions at claude.com/claude-code. - An Anthropic API key exported as
ANTHROPIC_API_KEY, or sign into Claude Code once withclaudeso the adapter can reuse your session. - Company Agents orchestrator running and the MCP server
reachable at
http://localhost:4200.
Hiring a Claude Code agent
In the dashboard: Agents → Hire → Claude Code. Fill in the form:- Name — what this agent is called in your company
- Role — the team role (IC engineer, head of design, etc.)
- Team — the team they belong to
- Model — the Anthropic model to use (
claude-sonnet-4-6by default; pick another for specific tasks) - Budget policy — per-task and daily ceilings
- Approval policy — which actions require a human yes
What the adapter does at run time
When the orchestrator assigns a task to the agent, the adapter:- Creates the workspace under
~/.company-agents/instances/default/runs/{run-id}/ - Writes the agent’s role files (
AGENTS.md,TOOLS.md,MEMORY.md) into.company-agents/agent/inside the workspace - Launches the
claudebinary with the workspace as cwd, passing the lease token and MCP server URL in the environment - Pipes Claude Code’s stdout/stderr into the orchestrator’s log collector
- Parses Claude Code’s structured tool-call events and relays them through the MCP server
- Renews the lease on the configured cadence
- On Claude Code’s normal exit, reads the final progress report
and calls
mark_completeormark_failed - On any other exit (crash, kill, timeout), tears down the process group and releases the lease
Environment variables
The adapter reads these from the orchestrator’s environment:| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | Auth for Claude Code |
CLAUDE_CODE_BIN | Binary name (default claude) |
CLAUDE_CODE_MODEL | Default model if the agent didn’t pick one |
CLAUDE_CODE_EXTRA_ARGS | Extra args passed verbatim to claude |
| Variable | Purpose |
|---|---|
MCP_SERVER_URL | Where Claude Code can reach the MCP server |
CA_LEASE_TOKEN | The current lease token |
CA_FENCING_TOKEN | The fencing token for this run |
CA_TASK_ID | The task being worked on |
CA_RUN_ID | The run identifier |
ANTHROPIC_API_KEY, etc.) are
passed through as well.
MCP tools
Claude Code is configured with an MCP server on every run, which gives it access to the orchestrator’s tool set:read_task/update_taskreport_progresspost_commentrequest_approvaldelegate_subtaskmark_complete/mark_failedread_memory/write_memory/promote_memoryget_budget/report_costrequest_human_help
Cost accounting
Claude Code reports token counts in its tool-call events, and the adapter forwards those to the orchestrator’s cost layer after applying the current pricing table. The dashboard shows the run’s token spend in real time while the agent runs. If you use a proxy like OpenRouter viaLLM_BASE_URL, the
adapter still captures the tokens from Claude Code’s events;
pricing is based on the model name, not on the provider.
Known quirks
- Context compaction: Claude Code compacts its own context
when it gets long. The compaction step is its own LLM call and
is counted toward the task budget. The adapter’s progress
report includes a
compactedflag so the reviewer can see when compaction happened. - Auto-accept vs. ask: Claude Code has its own auto-accept
setting for tool calls. The adapter forces
auto-acceptoff for any tool taggedrequires_approvalin the agent’s policy, so the orchestrator’s approval flow always wins. /bashin the workspace: Claude Code’s bash tool runs inside the workspace, which is what you want. The adapter confines it to the workspace via the filesystem sandbox runtime service.
Debugging
- Agent not starting: check that
claude --versionworks as the user running the orchestrator. The adapter does not escalate privileges. - “Lease expired” in logs: the task took longer than the lease window and the renewal failed. Check MCP server reachability and the orchestrator log.
- Tool calls rejected: check the agent’s policy against the
tool being called. A
permission_deniederror is almost always a policy mismatch.
Next
- Codex adapter for the OpenAI equivalent
- Process adapter for other CLI runtimes that follow the same pattern
- Creating an adapter if you want to write a custom one