---
title: "How to hand work from one AI coding agent to another · Cork"
description: "Hand off work between AI coding agents without losing context: commit, write a handoff note, resume or fork sessions in Claude Code and Codex, and verify first."
canonical: "https://corkcli.com/blog/hand-off-work-between-ai-coding-agents"
last_updated: "2026-10-03"
published: "2026-10-03"
author: "Kevin Vera"
---

# How to hand work from one AI coding agent to another

Hand off work between AI coding agents without losing context: commit, write a handoff note, resume or fork sessions in Claude Code and Codex, and verify first.

By Kevin Vera · October 3, 2026 · [Guides](https://corkcli.com/blog/c/guides) · 6 min read

To hand work from one AI coding agent to another, make the state of the work explicit outside the first agent's context: commit what exists (even as a work-in-progress commit), write a short handoff note that says what is done, what is not, what was decided and how to verify it, and point the next agent at both. If the next agent is the same tool, you can also resume or fork the original session; if it is a different tool or a different person, the commit and the note are the handoff. The next agent should start by running the checks the note lists, not by trusting the note.

## Why handoffs go wrong

An agent's knowledge lives in its context window. When the session ends, is compacted, or the work moves to another tool or teammate, most of that knowledge disappears: which approach was tried and abandoned, why a function has an odd signature, which test is flaky. The next agent then spends its first turns re-reading files to rebuild what the first one knew, or worse, undoes a deliberate decision because nothing recorded it.

Anthropic's engineering team described the same problem for long-running agents that span many context windows. Their harness kept a `claude-progress.txt` log of what agents had done, a JSON feature list with each item marked failing until verified, and git commits as the handoff points between sessions, plus an `init.sh` script so each new session could start the environment quickly. The same ingredients work for handing work between different agents.

## Step 1: put the state in git

Uncommitted changes in one agent's checkout are invisible to every other agent. Before you hand off:

```bash
git add -A
git commit -m "WIP: invoice retry logic, tests for backoff still failing"
git push origin HEAD
```

If agents work in separate worktrees, the receiving agent can check out the branch in its own worktree:

```bash
git worktree add ../repo-invoice-retry invoice-retry
```

A branch cannot be checked out in two worktrees at once by default, so the first agent should be finished with it, or the second should take a new branch from its tip.

## Step 2: write a handoff note

Keep it short and concrete. A template that works:

```markdown
## Handoff: invoice retry
Branch: invoice-retry (pushed)
Done: exponential backoff in billing/retry.ts, wired into sendInvoice()
Not done: jitter; tests in billing/retry.test.ts (2 failing, expected)
Decisions: kept sendInvoice() signature unchanged because webhooks/stripe.ts calls it
Watch out: test "retries on 503" is timing sensitive; run with --runInBand
Verify: npm test -- billing/retry
```

Put it where the next agent will read it: the commit message body, a file in the branch, the pull request description, or the prompt you give the next agent. The "Decisions" line is the one most often skipped and most often needed.

## Step 3: start the next agent from the note

Same tool, same machine: resume or fork the original conversation.

- **Claude Code:** `claude --continue` resumes the most recent session in the directory, `claude --resume` lets you pick one, and `--fork-session` starts a new session from an old one without changing the original. A session that ended inside a `--worktree` worktree resumes back into it.
- **Codex:** `codex resume --last` or `codex resume <SESSION_ID>` reopens a session; `codex fork` branches a previous session into a new chat while preserving the original transcript; `codex exec resume --last` continues a non-interactive run.

Resuming carries the whole conversation, which is convenient but expensive and noisy if the session was long. For a clean handoff, start a fresh session and give it the note:

```text
Read HANDOFF.md, run the verify command, then finish the "Not done" items.
Do not change sendInvoice()'s signature.
```

Different tool or different person: the commit and the note are all that travel. Claude Code subagents work the same way by design: each starts with a fresh context and only the task message it is given, so writing that message well is the handoff.

## Step 4: verify before building

The receiving agent's first job is to confirm the note is true: run the verify command, check the branch is up to date with the main branch, and look at what changed since the note was written (`git log --oneline main..HEAD`, `git log -L :sendInvoice:billing/invoice.ts`). Notes go stale fastest when other agents are working on the same code at the same time; a decision that was right an hour ago may conflict with a teammate's rename.

## Handoffs when several agents are live

Handing off between two agents in sequence is a documentation problem. Handing off while other agents are also editing is a coordination problem: the receiving agent needs to know not only what the previous agent did, but what everyone else has changed around it since. Options, from lightest to heaviest:

- Put the handoff in the pull request and let review catch conflicts.
- Send it as a message to the receiving session (Claude Code's `SendMessage` works between your own sessions).
- Use a shared task list, such as [Claude Code agent teams](https://corkcli.com/blog/cork-vs-claude-code-agent-teams), where a teammate claims the next unblocked task.
- Use a [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents) that keeps notes and live changes attached to the code itself.

## How Cork helps

Cork makes the second half of the note automatic. When the receiving agent starts or gets a prompt, it is briefed with the exact signatures, callers and recent changes of the code it is about to touch, so "what changed around this since the handoff" is already in its context. Durable decisions can be stored with the `remember` tool as notes anchored to code and read back with `recall`, so "kept sendInvoice() unchanged because webhooks call it" stays attached to `sendInvoice` instead of living in one session. `recap` answers what happened and what it cost. To pass work to whoever is on a piece of code, any agent can message one agent, all agents in the repo, or whoever is working on a given function.

Cork is the coordination layer for [multiplayer coding agents](https://corkcli.com/blog/multiplayer-coding-agents): it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned.

```bash
curl -fsSL https://corkcli.com/install.sh | sh
```

## Frequently asked questions

### How do I pass context from one Claude Code session to another?

Resume or fork the session with `claude --resume` or `--fork-session`, send a message with cross-session messaging, or commit the work and start the new session with a handoff note. The note is the most reliable across tools and people.

### Can Codex continue work that Claude Code started?

Yes, through git. Commit and push the branch, write a handoff note, and start Codex on that branch with the note as the prompt. Session transcripts do not transfer between the tools.

### What should a handoff note include?

What is done, what is not, decisions and their reasons, known traps, and one command that verifies the current state.

### Should I resume the old session or start fresh?

Resume when the session is short and focused. Start fresh with a note when it was long, compacted, or wandered, since a summary costs far fewer tokens than replaying the whole history.

## Sources

- <https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents>
- <https://code.claude.com/docs/en/worktrees>
- <https://code.claude.com/docs/en/sub-agents>
- <https://code.claude.com/docs/en/cross-session-messaging>
- <https://learn.chatgpt.com/docs/cli/reference>
- <https://git-scm.com/docs/git-worktree>
- <https://git-scm.com/docs/git-log>

## Related reading

- [How to share context between Claude Code sessions](https://corkcli.com/blog/share-context-between-claude-code-sessions): Six ways to carry context between Claude Code sessions: CLAUDE.md, auto memory, handoff files, resume and fork, cross-session messaging, SessionStart hooks.
- [How to share context between Codex and Claude Code](https://corkcli.com/blog/share-context-codex-claude-code): Make Codex and Claude Code work from the same context: one AGENTS.md, shared MCP servers, handoff files, and live awareness when both edit the same repo.
- [How to run Claude Code on two machines on the same repo](https://corkcli.com/blog/claude-code-two-machines-same-repo): Run Claude Code on a laptop and a desktop against one repo: what syncs through git, what stays local, and how to move sessions and context between machines.
- [How to stop an agent editing a file someone else is changing](https://corkcli.com/blog/stop-agent-editing-file-someone-else-is-changing): Block an AI coding agent from editing a file another session is changing: a tested Claude Code PreToolUse lock hook, Cursor and Codex equivalents, and limits.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/hand-off-work-between-ai-coding-agents
