How to keep context across Claude Code, Codex and Cursor
Claude Code, Codex and Cursor don't share memory. Each keeps its own chat, and all three see
only the files in the folder you open them in and its Git history. So keep context where they
all read it: rules that hold for weeks in one AGENTS.md at the project root, and
the live state of the task in a short HANDOFF.md that each new session reads
first. When two agents work at once, give each its own branch or Git worktree. On a Mac,
BuildGist's Continue can hand the task to the next agent's chat for you. The
sample run shows what BuildGist writes about one run.
Why the second agent starts from zero
Cursor can't read a Claude Code transcript, and Codex can't read a Cursor one. So the new agent sees the code but not what you asked for, what you ruled out, or what's left to do.
Each tool can reopen its own past chats: claude --resume,
codex resume, and agent resume in the Cursor CLI. They bring back that
tool's history only.
Two kinds of context
| Kind | What goes in it | Where | Changes |
|---|---|---|---|
| Rules | Stack, build and test commands, style, folders never to touch | AGENTS.md | Every week or two |
| Live state | The task, what's done, what failed, the next step, who owns what | HANDOFF.md, plus TASKS.md for parallel agents | Every session |
Which file each agent reads
| Agent | Reads | Notes |
|---|---|---|
| Codex | AGENTS.md | ~/.codex/AGENTS.md first, then one file per folder from the repo root down. AGENTS.override.md wins in its folder. 32 KiB combined by default. |
| Cursor | AGENTS.md or .cursor/rules/*.mdc | Root and subfolders. A nested one is combined with its parents. |
| Claude Code | CLAUDE.md | Since v2.1.277 it reads AGENTS.md, but only when there's no CLAUDE.md or CLAUDE.local.md in your folder or above it. |
If you also keep a CLAUDE.md, make its first line @AGENTS.md.
Claude Code expands that import, so the rules live in one file. To check what loaded, run
/context and look under Memory files.
The file layout
AGENTS.md rules for every agent
CLAUDE.md @AGENTS.md, plus anything only Claude Code needs
HANDOFF.md goal, done, tried and failed, next step, don't redo
DECISIONS.md optional: one dated line per choice you don't want reopened
TASKS.md parallel agents only: owner, branch, status per task
Add these lines to AGENTS.md:
If HANDOFF.md exists, read it first and say the task and the next step back before you edit.
If TASKS.md exists, claim a task by writing your name and branch on it before you touch code.
Write the handoff note before you switch
Write it before a fresh start: a long session, a limit you can see coming.
Task: Add login with Google.
Done: the sign-in button, the callback route, the signed-in state. See the diff.
Tried and failed: keeping the session in localStorage (lost on refresh).
Next step: check that a deleted note belongs to the signed-in user.
Don't redo the sign-in work.
If the agent writes it, read it first. Run
git diff --stat, and if a file the note calls done isn't there, fix the note.
Delete it when the task is finished.
Two agents on the same repo at once
Give each agent its own git worktree so they never edit the same checkout:
git worktree add ../app-codex -b codex/export-csv
Open Codex in ../app-codex, Claude Code in the main folder. Merge when a piece is done, then read the combined diff once.
Other ways people do it
- dkothule/ai-context keeps
AGENTS.md,CLAUDE.mdand Cursor rules thin and puts decisions, plans and session history in an.ai-context/folder every agent reads. - For agents on different people's computers, Joxo describes a shared task board, decisions and handoffs that reach each teammate's agent on its next turn, and Agent Messaging Service a shared channel that agents in different tools post to and read.
- jimozo/agent-handoff-kit describes itself as a Git-native handoff protocol for teams using several coding agents in one project.
Or choose Continue in BuildGist
When you start a new chat in another coding agent in the same project, a BuildGist card at the bottom right of your screen offers the earlier agent's task. Choose Continue and the new chat starts with that task's context. Start fresh hands nothing over.
The context is your own words: what you asked for, and constraints you typed. If the last run's files are unchanged and HEAD hasn't moved, it can also say how many files that run changed, whether a test failed, and up to three paths. No patch.
By default the card offers a task active in this project within 12 hours. Claude Code and
Codex take the context on a new session. In Cursor it's best effort, so if the task doesn't
show, paste the note. BuildGist doesn't write HANDOFF.md, doesn't touch
CLAUDE.md or AGENTS.md, and doesn't merge two agents' edits. Setup is in Getting started.
More: Claude Code to Codex and which agents read AGENTS.md.
Questions
Do Claude Code, Codex and Cursor share memory?
No. Each keeps its own chat history, and Claude Code's auto memory stays on your machine.
They share the files in the folder, which is why AGENTS.md and
HANDOFF.md work across all three.
Should I symlink CLAUDE.md to AGENTS.md or import it?
Either works. Anthropic suggests the import if anyone clones on Windows, where Git can check
a committed symlink out as a one-line text file unless core.symlinks is enabled.
Does context survive Claude Code's /compact?
The project-root CLAUDE.md does: Claude Code re-reads it after compacting.
Instructions given only in the chat don't, so put what must last in a file. More in
Claude Code lost context after
compacting.
What happens to context when I hit a usage limit mid-task?
The chat stays in that agent. Update HANDOFF.md first if you can, then open the
other agent in the same folder, or start a new chat there and choose Continue. See
usage limit hit mid-task.
What you need
- A Mac with Apple silicon and macOS 12 or later.
- Claude Code, Cursor or Codex.
- A Git project. No commit, push, remote or GitHub repository is needed.
- A GitHub account, to sign in. BuildGist does not access your GitHub repositories.
Codex needs you to approve BuildGist once, in Codex. BuildGist shows the steps. Setup is in Getting started.
To explain a run, your computer sends BuildGist what that run needs, and BuildGist passes it to Anthropic. BuildGist does not keep this material. It does not send your whole repository, files the run did not change, or files named like secrets, such as .env files and keys. It keeps the explanation and short cited excerpts of changed code, at most 12 lines each. Secret masking is best-effort. Privacy has the full list.
Every account gets 7 days of BuildGist Pro free, with no card. The 7 days start at your first explanation or Continue handoff. Nobody is charged when the trial ends. After that, BuildGist Pro is $12 per month, plus any applicable tax shown at checkout. See pricing.
Try BuildGist Download for Mac
No Mac handy? Try it in your browser: paste a session or a git diff and see the explanation.
Apple silicon, macOS 12 or later. United States, 18 or older.
Related
- What did Claude Code change?
- Switch from Claude Code to Codex
- Understand code an agent wrote
- Hand off Claude Code to Cursor
- Review what Codex changed
- You’ve hit your session limit in Claude Code
- You’ve hit your usage limit in Codex
- Review AI code before merging
- BuildGist or the git diff
- Claude Code session history
- Undo Claude Code changes
- BuildGist vs CLAUDE.md, AGENTS.md and HANDOFF.md
- Keep context from Claude Code to Cursor
- Resume an agent session in another tool
- BuildGist vs Conductor
- Codex context window full
- Undo Codex changes
- Cursor usage limit reached
- Review Cursor agent changes
- Codex session history location
- Your conversation is too long in Cursor
- One default coding agent, or two?
- Tools that summarize agent sessions
- Switch from Codex to Claude Code
- Move from Cursor to Claude Code
- Switch from GitHub Copilot to Claude Code
- Move from Windsurf to Cursor
- Switch from Gemini CLI to Claude Code
- Coding agent crashed mid-task
- Claude Code lost context after compacting
- What commands did the agent run?
- Turn an agent session into a PR description
- Which coding agents read AGENTS.md?
- Switch from Cursor to Codex
- Export a Claude Code conversation
- Keep the dead ends when you switch agents
- Write a handoff note for a fresh session
- Usage limit hit in the middle of a task
- Mac apps that explain agent runs
- Explain a Claude Code session
- What did my agent change before I merge?
- BuildGist vs an AI PR reviewer
- Review what Claude Code changed
- Review what Copilot changed
- Review what Windsurf changed
- Review what Gemini CLI changed
- Review what Devin changed
- Review what Cline changed
- Review what Aider changed
Questions: kayvanandre@gmail.com.