Anthropic — Claude Code
Spawn Anthropic's Claude Code from inside agent loops with budget caps, schema-bound output, and the official claude_agent_sdk.
Spawn Anthropic's Claude Code from inside agent loops. The Python harness uses the official claude_agent_sdk package directly, so plan-mode reasoning and multi-turn refactors run with no CLI sitting in your container.
Reach for Claude Code when the work needs careful reasoning — code reviews, surgical refactors, multi-step planning, or anything that benefits from the agent thinking before it edits.
Quickstart
Install the official Claude SDK alongside AgentField. The TypeScript and Go harnesses drive the claude CLI as a subprocess, so install that path instead if you're not on Python.
Call the harness
Attach a HarnessConfig to the agent so every .harness(...) call inherits sensible defaults — provider, model, budget, permission mode — without re-specifying them. Override per call when a specific task needs something different.
Composition pattern — plan-then-implement
Claude Code is a strong planner. Pair it with a faster implementer like Codex for the actual edits — same loop, one field flipped.
Options
| Option | Type | Default | What it does |
|---|---|---|---|
provider | string | required | "claude-code" for this provider. |
model | string | "sonnet" | Any model alias the claude_agent_sdk accepts ("sonnet", "opus", "haiku"). |
permission_mode | string | null | "plan" (plan-first, then execute) or "auto" (bypass permissions). Maps to bypassPermissions on the SDK. |
tools | string[] | ["Read","Write","Edit","Bash","Glob","Grep"] | Allowed tool names — gates what Claude Code is allowed to invoke. |
max_turns | int | 30 | Hard cap on agent iterations. |
max_budget_usd | float | null | Cost ceiling. The SDK aborts when total spend would exceed this. |
system_prompt | string | null | Custom system prompt prepended to the loop. |
env | dict | {} | Extra environment variables forwarded to the subprocess. |
cwd | string | working dir | Working directory the agent treats as the repository root. |
schema | model | null | Pydantic class / Zod schema / Go struct. Forces JSON output validated against the schema. |
Authentication
- Set
ANTHROPIC_API_KEYin the harness's environment. The SDK picks it up automatically; you do not need to pass it throughapp.harness. - For Anthropic Vertex or Bedrock routing, follow the official
claude_agent_sdkconfiguration.
When to choose Claude Code
- Code review and audits — plan mode lets the agent enumerate findings before changing any files.
- Multi-turn refactors where intermediate reasoning matters more than throughput.
- Surgical edits in a known codebase — Claude excels at minimal, targeted diffs.
- Reasoning-heavy tasks where stepping through the problem beats brute iteration.
Pairs well with
- Codex — Claude reviews, Codex implements. Run them in sequence.
- Gemini CLI — let Gemini ingest the whole repo first, then hand findings to Claude for surgical edits.
- OpenCode — adversarial pattern: Claude proposes, an open-weight OpenCode loop verifies.