# Hand off a task from Claude Code to Codex

Both agents connect to the same project with their own keys, so one can leave work for the other through the project's disk.

## 1. Connect both

```bash
npx brynth init --client claude-code,codex
```

or `npx brynth connect codex` on a machine where the project is already set up (it uses the last project created, or `--project`). Each client gets its own key; the ledger records `claude-code` and `codex` as different agents.

## 2. Claude Code saves the state

> Save where we are on the billing migration to Brynth as task billing-migration, so Codex can finish it.

```text
state_save({
  task_id: "billing-migration",
  state: {branch: "feat/billing-v2", done: ["schema", "backfill"], next: ["switch reads", "drop old table"]},
  note: "Reads still go to the old table"
})
```

Larger material goes to files, which return a `disk://…` reference:

```text
file_put({path: "billing-migration/plan.md", content_base64: "…", content_type: "text/markdown"})
```

## 3. Codex picks it up

> Load the Brynth task billing-migration and continue.

```text
state_load({task_id: "billing-migration"})
file_get({path: "billing-migration/plan.md"})
```

Task state has no expiry: it stays until it is overwritten or deleted.

## 4. With an approval in between

If Claude Code asks a person before handing off, it passes the task id as `state_ref`:

```text
ask_approval({action: "migrate", summary: "Switch billing reads to the new table?", state_ref: "billing-migration"})
```

When the person decides, the `request.resolved` event carries `state_ref`, and Codex resumes with `state_load({task_id: "<state_ref>"})`. The Brynth skill does this at the start of every session.

## 5. See who did what

```bash
npx brynth logs --limit 20
```

Each line shows the operation and the agent that ran it.
