Handoffs & agentic context
Give coding agents the same onboarding you’d give a senior colleague, and less chat history
The problem
AI coding agents are fast, but every session starts cold. Teams typically compensate in one of two ways, and both are expensive:
- very long chats, which cost tokens on every turn, drift, and can’t be reviewed later;
- re-explaining the project each time, which is slow and inconsistent.
Instead, give the agent durable, versioned context (what a senior colleague would read on day one) plus short, curated notes about the work in progress.
Layer 1: project instructions (CLAUDE.md / AGENTS.md)
A markdown file at the repo root that the agent reads at the start of every session. CLAUDE.md is Claude Code’s file. AGENTS.md is a tool-neutral convention that several agents read, and Next.js now generates one for its own framework rules. A CLAUDE.md can import it (@AGENTS.md) and add project rules.
What belongs in it, and what we learned to put there:
| Section | Why |
|---|---|
| Stack + exact commands (test one file, full check, format) | Agents otherwise guess, and run the slow full suite every time |
| Git rules (Conventional Commits, squash, no AI attribution) | Consistent history (git workflow, conventional commits) |
| Confidentiality rules (no client/employer names, no real data) | The agent will otherwise happily paste whatever it sees |
| Domain rules (e.g. banned compliance claims or blanket validation claims) | Encodes review knowledge once |
| Verification rule: done means tests pass, not “the model said so” | Self-reports are not evidence |
| Handoff and teaching rules | Continuity and learning |
Keep it short and specific: these instructions take up context in each session. A starter for R packages is in templates/agentic/CLAUDE.md.
Layer 2: handoffs for work in progress
We now keep long-lived areas, such as content/, site/, design/ and agents/, under dev/handoffs/. An area survives individual issues and PRs. A short-lived feature folder still makes sense for bounded work; close it when that work is done.
The root README.md maps folders to responsibilities. An optional overview/ holds shared priorities, decision pointers and a delivered index when work spans areas. Every folder uses the same numbered files (the first keeps its old name, 01-feature.md):
dev/handoffs/<area>/
├── README.md # dated Status · Next step · Read order · Last session; ≤ 60 lines
├── 01-feature.md # what and why, scope, acceptance, source-of-truth links
├── 02-code-map.md # where things live
├── 03-open-issues.md # open work: tracker pointers and current gotchas
├── 04-plan.md # next steps, how work runs, verification
├── 05-questions.md # pending decisions: question, options, recommendation
└── 06-delivered.md # finished work, newest first, with links
Delete files an area does not need, without renumbering; an overview without code needs no code map. Named extras are fine, including overview/decisions.md for brief decision pointers. The templates live inside the committed skill. The working notes stay local and gitignored.
We share one handoff skill across two repositories and two coding agents. Each repository keeps its own handoffs; each agent reads the skill from its own folder, with the instructions, helper and templates kept as identical copies. Shared behaviour does not mean shared session state across repositories. Within one repository, the helper resolves the main checkout’s handoffs, including when called from a worktree.
To use it, copy the published skill into your repository as .claude/skills/handoff/ (another agent gets an identical copy in its own skills folder). The commands below use that path. For a new project, init creates the root index and an overview; start content copies the area templates. Both require dev/handoffs/ to be gitignored. Fill in the new folder and add it to the root index yourself.
bash .claude/skills/handoff/scripts/handoff.sh init
bash .claude/skills/handoff/scripts/handoff.sh start contentA fresh session reads the root index, then runs status to see each folder’s Status and Next step. Read only the area the task needs; read the overview when priorities cross areas.
bash .claude/skills/handoff/scripts/handoff.sh status
bash .claude/skills/handoff/scripts/handoff.sh checkcheck warns about a missing root index or folder README, a README over 60 lines, and an active Status without a date or older than 14 days by default (HANDOFF_STALE_DAYS). It also checks recognised handoff paths in backticks. Repository paths are opt-in with HANDOFF_CHECK_REPO_PATHS=1; bare filenames, URLs and placeholders are skipped. This is a lint check, not proof that the tracker agrees with the notes. Warnings produce exit status 1.
Updating and closing are skill procedures, /handoff update content and /handoff close content, not shell subcommands. The rules that make the notes useful:
- Verify before writing Status. Check the linked issues and PRs, the branch and the latest commit on main. Do not copy yesterday’s claim that a PR is open after it has merged.
- Update every area touched, before a PR, before compaction and when stopping or handing over. Change
overview/only when a shared priority or decision changes, then runcheck. - Keep the README short. Date the Status, give one concrete Next step and record 1–3 Last session bullets. Use absolute dates and a Read order. Move finished items from the README, open issues and plan to
06-delivered.md, newest first, with brief links. - Point to the tracker; don’t recreate it. Remove answered questions. Put lasting decisions in issues or ADRs, documentation in the repo and reusable scripts in
tools/. Handoffs are not backed up by git. - Close bounded work deliberately. Do a final update, mark the dated Status as closed, link the durable outcomes and remove the live Next step. Keep the folder unless asked to delete it.
When several repositories work together, a session in one often learns something another needs: an idea, a decision, a change, a note there that went stale. It writes it as an entry in the other repository’s inbox, dev/handoffs/external-notes.md (handoff.sh note). The receiving project treats each entry as a claim to verify, not a decision: it spreads what holds into its own notes, opens an issue for agreed work, and moves the entry along with handoff.sh set (triaged, planned, in-progress, then done, future, rejected, duplicate or noted). Handled entries shrink to one line at the bottom of the file, and that record is the point: when the same request arrives again months later, the next session can see it was already rejected, and why. A session hook announces new entries and blocks a merge while an entry has waited untriaged for a day.
For R readers, think of a package’s NEWS.md versus your working lab notebook: the package keeps its lasting change record, while the notebook tells you which test to open next. An area’s 06-delivered.md is a local index to finished work, not a replacement for that record. For an R package, exclude dev/ from the source tarball with ^dev$ in .Rbuildignore too.
The skill files
The full skill, as we run it, is published here. Keep its folder structure when you copy it (the script finds the templates next to itself):
SKILL.md: the proceduresscripts/handoff.sh: the helper (init,start,status,check, and the inbox commands)scripts/external-notes.sh: the inbox commands (inbox,note,set,migrate,gate)scripts/hook.shandscripts/hook.py: a session hook for Claude Code, Codex and Antigravity (announces new entries, guards merges)- Root index template:
root/README.md - Inbox template:
root/external-notes.md - Overview decision log template:
overview/decisions.md - Area templates:
README.md,01-feature.md,02-code-map.md,03-open-issues.md,04-plan.md,05-questions.md,06-delivered.md
Layer 3: skills and plugins
Reusable procedures (a release checklist, a handoff, a review recipe) can be packaged as skills: a SKILL.md with instructions, plus scripts and templates. The agent loads them only when relevant, though skill names and descriptions also take up context. Plugins can be enabled at project scope (.claude/settings.json) to share the selection with contributors.
Working with more than one model
On this project one model (Claude) owns the work: it plans, decides and verifies. A second (Gemini) takes well-scoped tasks: reading docs, analysing dependency PRs, drafting. The rules:
- Give a clear brief with acceptance checks and constraints (for example, “edit only this file; no git, no push”).
- Take back a short digest, not a transcript.
- Re-check the evidence and review the diff. In our dependency case the second model’s conclusions held up, but review still surfaced a nuance it had glossed over.
- Keep outward-facing actions (push, merge, publish) with the owner, after verification.
Token discipline is cost governance
For teams paying for AI seats, context is money. I use these patterns to keep context focused:
- short project instructions;
- handoffs instead of long chats;
- targeted tests while iterating;
- digests from delegated work;
- skills loaded on demand.
We don’t quote savings figures until we’ve measured them. Neither should you.
The GxP angle
- No real data in prompts, ever. Use synthetic or public pilot data, or your organisation’s approved enterprise AI environment.
- A named human is accountable for every change an agent makes. It goes through the same PR, review and CI as human code.
- Provenance: keep the lasting record in commits, reviewed PRs and ADRs; local handoffs point to it.
Sources
CLAUDE.md/ project memory: Claude Code Docs: How Claude remembers your projectAGENTS.md(tool-neutral convention): agents.md- Next.js generating
AGENTS.md/CLAUDE.mdfor its own framework rules: Next.js Docs: Set up your project for AI coding agents - Claude Code Skills: code.claude.com/docs/en/skills
- Claude Code Plugins: overview and installation scopes.
- Areas layout and helper behaviour: the published skill above (
SKILL.mdandhandoff.sh), run on 2026-09-28. - Gitignored working notes: Git: gitignore.
- R package records and build exclusions: R Packages: NEWS.md and Writing R Extensions: Building package tarballs.
- 2026-09-26: Removed the end-of-post checklist.
- 2026-09-26: Established repository-scoped handoffs across two repositories, configuring
CLAUDE.mdto reference sibling handoffs for cross-repo context. Copied the handoff skill into the second repository. - 2026-09-27: Added a Sources section.
- 2026-09-27: Linked every template file and showed it on the page.
- 2026-09-28: Reworked handoffs around long-lived areas, with an optional overview, dated status checks and
06-delivered.md. Clarified what belongs in git, the shared skill copies, andstatus/check. The downloadable skill is now the current version (areas,init/status/check). - 2026-10-03: Added an inbox for notes between related repositories (
external-notes.md, with statuses fromnewtodoneorrejected), a migration for older notes, and a session hook that announces new entries and blocks a merge while an entry has waited untriaged for a day. The skill now also asks you to keep the tracker in step: close issues through a PR, with a comment, or as not planned. An optional update step now asks whether delegated work showed a new kind of mistake, for projects that keep standing rules for delegated AI work.