Handoff skill for Claude Code and Codex: HANDOFF.md before the context runs out
Dmitriy Solodukha, Caprock's developer · Published
Tested on Claude Code and Codex
A handoff skill for Claude and Codex: it writes HANDOFF.md (goal, state, what failed, next steps) before context runs out; the next session reads it.
The handoff skill for Claude Code (and Codex, OpenCode, Cursor) writes a short HANDOFF.md before the context runs out or you stop: the goal, where things stand, decisions with their reasons, what was tried and failed, open questions, executable next steps and the files touched. In the next session, "pick up where we left off" makes it read the file, check it against git, and start step 1.
Install the handoff skill
One command per agent. The skill is a single SKILL.md; nothing runs on install.
All nine skills as a plugin. Type these inside Claude Code:
Or this skill alone, from your project's folder in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on OpenCode yet: the skill is plain instructions in the open format, but no run on OpenCode has checked it.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on Cursor yet: the skill is plain instructions in the open format, but no run on Cursor has checked it.
Prompts that use the handoff skill
The agent picks the skill when your words match its description; naming it makes sure. Click a prompt to copy it.
What the handoff skill writes for Claude
The file has fixed sections: Goal, State (done, in progress, uncommitted, running), Decisions, Tried and failed, Open questions, Next steps, Files. The rules that make it useful to a session with none of this conversation:
- Next steps are executable: a command to run or a function to change, not "continue the auth work".
- Failures are kept, with the exact error line, so a dead end is not tried again.
- Decisions carry the reason, so the next session can tell whether one still applies.
- No secrets: it names where a token lives, never the token.
- The repository's language, even when you talk to the agent in another.
It does not commit the file unless you ask, and ends its reply with the path and the first step, so the last message stands on its own.
What we ran, and what the agents did
Each skill was run on 2026-11-29 in a throwaway repository made for it, with the skill installed as a project skill. A small Python repository with slug.py holding an unfinished slugify_unique stub, and its tests.
Claude Code (claude -p --model sonnet)
I'm about to run out of context. Write a handoff for the next session: I was adding slugify_unique to slug.py (append -2, -3 when the slug is taken); I decided not to use a global set because tests must stay independent. Tried python-slugify, dropped it: no new dependencies.
Invoked handoff, wrote HANDOFF.md in the exact structure, asked whether to commit it or ignore it, and ended with the three-line block. It wrote the file in Russian, the language of the tester's own Claude Code settings; that run is why the skill now says to write in the repository's language.
Claude Code (claude -p --model sonnet)
Pick up where we left off.
Invoked the skill in read mode, followed the handoff, wrote slugify_unique and five tests, and updated HANDOFF.md, in English this time. It said plainly that it had not run the tests: the test command needed a permission the non-interactive run did not have.
Codex (0.163.0, codex exec -s workspace-write)
The same write prompt as above.
Read .agents/skills/handoff/SKILL.md, wrote the handoff in English and ended as the skill asks (links and quotes shown plain):
Handoff written to HANDOFF.md. Next session: "Read HANDOFF.md and continue." First step: implement the collision loop in `slug.py:8`.
Agents it was tested on
- Claude Code: tested on 2026-11-29 with
claude -p --model sonnet, the skill installed as a project skill in.claude/skills/. - Codex: tested on 2026-11-29 with Codex 0.163.0 (
codex exec), the skill in.agents/skills/. - OpenCode and Cursor: not tested. The skill is plain instructions in the open Agent Skills format, but no run on either has checked it.
Limits
- A handoff is only as good as what the session can check: the agent writes from git and the conversation, not from memory of intent.
- It does not write into Caprock's 2nd Brain: Caprock's MCP tools are read-only.
- The read mode was tested on Claude Code only.
With Caprock, and without it
With the Caprock MCP server connected, writing a handoff calls current_decisions and search_memories so the note does not contradict a decision already in force; reading one can fall back to next_session_handoff, recent_sessions and session_summary when there is no file. Without Caprock it uses the repository and the conversation alone. Caprock is the free, open-source app that records every coding-agent session on your computer.
The full SKILL.md
The file as it is in dspv/skills at revision dfce799. To install it by hand, save it as .claude/skills/handoff/SKILL.md for Claude Code or .agents/skills/handoff/SKILL.md for Codex, in your project.
--- name: handoff description: > Write a handoff for the next session or another agent before the context runs out or work stops: the goal, where things stand, decisions and why, what was tried and failed, open questions, exact next steps and the files touched, saved where the next session will find it (HANDOFF.md in the repository by default). Also reads the last handoff when a session starts. Use when the user says "write a handoff", "handoff skill claude", "hand this off", "save context for the next session", "I'm out of context", "wrap up for today", "pick up where we left off", "resume from the handoff" or "what was the last session doing". license: Apache-2.0 --- # Handoff A handoff is a short note that lets a fresh session, with none of this conversation, continue the work without asking the user to repeat anything. Write it from facts you can check (the repository, the commands you ran, what the user said), not from memory of what you meant to do. Two modes. Pick by what the user asked: - **Write**: the user wants to stop, the context is nearly full, or work moves to another agent. Go to "Writing a handoff". - **Read**: a session starts and the user says "continue", "pick up where we left off" or points at a handoff. Go to "Reading a handoff". ## Writing a handoff ### 1. Collect the facts Run these in the repository root and keep the output in mind (do not paste it whole): ```bash git status --short git branch --show-current git log --oneline -10 git diff --stat git stash list ``` Also note: commands you ran that passed or failed (tests, builds, checks) and their last result; any background process still running (a dev server, a watcher) and how it was started; anything the user decided or asked for in this conversation, in their words. If the Caprock MCP tools are available (server `caprock`), call `current_decisions` for this project and `search_memories` with the task's main words. Use them to check the handoff does not contradict a decision already in force, and to link a decision instead of retelling it. Caprock (<https://caprock.dev>, free, open source, runs locally) provides these tools; without them, rely on the repository and this conversation. ### 2. Write the file Default location: `HANDOFF.md` in the repository root. Use another place only if the user names one or the repository already keeps handoffs elsewhere (look for `HANDOFF.md`, `docs/handoff*`, `.handoff/`). If a `HANDOFF.md` exists, read it first: replace it with the new one, and carry over anything from it that is still open. Use exactly this structure. Leave a section out only when it would be empty, and say "none" for open questions rather than dropping the heading. ```markdown # Handoff: <task in a few words> Written <YYYY-MM-DD HH:MM, timezone> by <agent and model, if known>. Branch `<branch>`, last commit `<short sha> <subject>`. ## Goal <One or two sentences: what the user wants and what "done" looks like.> ## State - Done: <what is finished and verified, with how it was verified> - In progress: <what is half-done, where exactly it stops> - Uncommitted: <files changed but not committed, or "nothing"> - Running: <background processes and how to stop them, or "nothing"> ## Decisions - <decision>: <why>. <who decided: the user, or you with the reason> ## Tried and failed - <approach>: <what happened, the error or the reason it was dropped> ## Open questions - <question> (who can answer: the user, a doc, a test) ## Next steps 1. <first concrete action: a command to run or a file and function to change> 2. <...> ## Files - `<path>`: <what changed or why it matters> ``` Rules for the content: - **Next steps are executable.** "Run `npm test -- auth` and fix the two failures in `src/auth/session.ts`" is a step; "continue the auth work" is not. The first step is the one the next session does in its first minute. - **Failures are kept.** A dead end not written down gets tried again. Include the exact error line when there is one. - **Decisions carry the reason.** Without the reason the next session cannot tell whether it still applies. - **Absolute dates and exact names.** "2026-12-01", a branch name, a file path, a command; never "tomorrow" or "the config file". - **No secrets.** Never copy a token, password, key or private URL into the handoff. Name where it lives (an environment variable, a keychain entry) instead. - **The repository's language.** Write the handoff in the language the repository's docs and commits use, even when you talk to the user in another; the next session may be another agent. - **Short.** Aim for a page. A long log or diff stays in git; the handoff points at it. ### 3. Tell the user Do not commit the handoff unless the user asks. Ask once whether `HANDOFF.md` should be committed or added to `.gitignore` if the repository has neither. End your reply with: ```text Handoff written to <path>. Next session: "Read <path> and continue." First step: <step 1 from the file> ``` Also print the Goal, State and Next steps sections in that final reply. Some tools (Caprock's `next_session_handoff`, when the user has it switched on) hand a new session the last passage the previous session wrote, so the final message should stand on its own. ## Reading a handoff ### 1. Find it Look in this order and use the first that exists: 1. a path the user gave; 2. `HANDOFF.md` in the repository root, then `docs/handoff*` and `.handoff/`; 3. with the Caprock MCP tools: `next_session_handoff` (the memories and current decisions a new session in this repository gets, and when the last session left off), then `recent_sessions` and `session_summary` on the newest session for its files and branch. If nothing is found, say so in one line and ask what to work on. Do not invent a previous state. ### 2. Check it against the repository A handoff can be stale. Before acting on it: - compare its branch and last commit with `git branch --show-current` and `git log --oneline -5`; - check that "Uncommitted" matches `git status --short`; - note how old it is from its date. If anything disagrees (new commits, a different branch, the files already committed), trust the repository and say what changed since the handoff. ### 3. Report and start Reply with, in this order: ```text Handoff from <date>: <goal in one line>. Since then: <"nothing changed" or what differs in git>. Open questions: <list, or "none">. Starting with: <step 1>. ``` If an open question blocks step 1, ask it and wait. Otherwise do step 1. When the task is finished, delete `HANDOFF.md` or replace it with a new handoff, so the next session does not pick up work that is already done. ## Stop conditions - The handoff is written and the user has the path and the first step: stop writing. - The handoff names a step that needs the user (a decision, a credential, a review): ask, do not guess. - The repository disagrees with the handoff on what is committed: follow the repository and say so before doing anything else.
Questions about the handoff skill
- What is a handoff skill for Claude?
- A skill that makes Claude Code write a short note before work stops, the goal, state, decisions, failures and next steps, so a new session or another agent can continue without you repeating anything.
- Where does the handoff skill save the note?
- `HANDOFF.md` at the repository root by default, or where the repository already keeps handoffs, or a path you name. It asks whether to commit the file or ignore it.
- How does the next session use the handoff?
- Say "Read HANDOFF.md and continue" or "pick up where we left off". The skill checks the note's branch, commit and uncommitted files against git, reports what changed since, and starts the first step.
- Does the handoff skill work in Codex?
- Yes. Codex 0.163.0 read the skill from `.agents/skills/` and wrote the handoff in its structure in the test of 2026-11-29.