---
title: Claude Code
description: Anthropic's CLI coding agent. The default agent in AO.
---
import { Callout } from "fumadocs-ui/components/callout";
Slot: agent · Name: claude-code · Binary: claude
[Claude Code](https://docs.anthropic.com/en/docs/claude-code) is Anthropic's CLI coding agent. It's AO's default because it has first-class session resume, rich JSONL event logs, and a native hook system AO can register against.
## Install
```bash
npm install -g @anthropic-ai/claude-code
```
Then sign in once:
```bash
claude
```
## Use
```yaml title="agent-orchestrator.yaml"
agent: claude-code
```
That's it — there are no plugin-level config keys.
## How it works
- **Launch:** `claude` runs inside the worktree. AO sets `CLAUDECODE=""`, `AO_SESSION_ID`, and `AO_ISSUE_ID` in the environment.
- **Activity tracking:** AO registers a PostToolUse hook in `.claude/settings.json` on workspace setup. The hook writes an AO activity entry each time Claude calls a tool, so the dashboard's `active/ready/idle` states stay accurate.
- **Session resume:** `claude --resume ` rehydrates the previous chat. AO maps its session ID to Claude's via the JSONL at `~/.claude/projects//...jsonl`.
- **Cost reporting:** AO reads Claude's per-message cost field from the JSONL — visible on the dashboard card.
## Environment variables
| Variable | Set by AO | Purpose |
|---|---|---|
| `AO_SESSION_ID` | ✓ | Unique AO session identifier |
| `AO_ISSUE_ID` | ✓ (when spawned from an issue) | Issue identifier |
| `CLAUDECODE` | ✓ | Signals to Claude that it's running under a harness |
Your Anthropic API key comes from wherever `claude` normally reads it — `~/.claude/`, env, etc. AO doesn't touch it.
## Troubleshooting
`npm install -g @anthropic-ai/claude-code`, then reopen your terminal so the PATH picks it up.
AO registers the PostToolUse hook in `.claude/settings.json` on spawn. If the hook got removed, run `ao spawn` again — AO re-installs it idempotently.
Claude's session JSONL lives at `~/.claude/projects//.jsonl`. If that file is gone (cleaned up, moved), resume won't work — spawn fresh.