Skip to article
← All articles

Multi-agent · Engineering guide

How to Keep Claude Code and Codex in Sync Between Sessions

Stop losing project decisions between Claude Code and Codex sessions. Separate rules from task state, write a useful handoff, and verify every restart.

Make every new session recover the task before changing code.
AI-generated editorial cover
On this page

Claude Code and Codex can lose task continuity when decisions and unfinished actions exist only in a previous conversation. Keep a short current-task record beside the project rules, and make every new session read and verify it. Sharing a folder gives the next agent files; it still needs a reliable way to discover where the work stands.

What should the next session know before it touches code?

It should know the intended result, the allowed scope and the difference between what was attempted and what was verified. That is enough to restart a task without replaying every tool call. The next session should still inspect the actual files before trusting the summary.

The correct restart says, “I found the handler change, preserved the unrelated copy and still need a test result.” It does not say “tests passed” merely because the previous agent started a command. Keeping that uncertainty visible lets the receiving agent finish the work without repeating an unsupported claim.

Our take: make the restart routine boring. Read, inspect, compare, then act. A clever memory system is less useful than a habit that reliably checks which repository is open and whether the last claimed result exists. You can implement that habit with ordinary files before adding any service.

Why does Claude Code rediscover the project every session?

A session needs relevant context assembled for the task at hand. Some information can persist through instruction files, saved notes or a resumed conversation, but those mechanisms serve different purposes. A build command is a reusable rule. An unfinished test run is current task state. A transcript is historical evidence.

Rediscovery is wasteful when the agent repeats settled investigation, but some rechecking is useful. Files may have changed since the previous session, another agent may have fixed the bug, or you may have opened a different worktree. Preserve the conclusion and evidence so the next session can verify them cheaply.

Do not solve every forgetting problem by making the instruction file longer. A diary of changing tasks can bury the few stable rules every session needs. Keep current work in a separately named record and give the instruction file a short pointer explaining when to read it.

The single-handoff guide explains what to put in a transfer packet. This article covers the repeated cycle around that packet: starting a session, finishing a bounded step, handling interruption and checking the next restart. The packet is useful only when the cycle keeps it current.

What is the simplest way to share context between the tools?

Start with the same reviewed task record available to both tools. If a file already solves that, use it. Host memory helps within its own documented scope. A shared structured record becomes useful when tasks and decisions change across sessions, machines or multiple assistants.

Approach you can use todayWhat survivesGood fitWhat to verify
Manual Markdown handoffGoal, decision, evidence, blocker and next actionA project with one writer or deliberate handoffsBoth sessions read the latest file in the intended checkout
Built-in session and project-memory featuresHost-managed conversation continuity or notesYou mainly remain in one toolThe intended session, directory and loaded instructions
Structured state, such as SaveSlotCurrent task and decision records accessible through authorized toolsSeveral assistants need changing stateRecord identity, freshness, access and saved updates

A shared directory is not always the same view. Two worktrees contain separate files, and two machines may have different revisions. A handoff should name the repository, branch or worktree and relevant revision. When a task file belongs in version control, synchronize it through the project’s approved process rather than assuming sibling worktrees see uncommitted changes.

The Project Keeper template offers a record structure. Do not migrate an entire project just to try it. Begin with one current task and test whether a fresh session can identify the accepted decision, unfinished work and next verifiable action.

CLAUDE.md vs AGENTS.md: do I need both?

Choose a shared home for project rules, then verify how each installed host loads it. Avoid maintaining two independent copies of the same build and safety instructions. A small host-specific adapter is easier to review than two documents that slowly disagree.

As of November 2026, the Claude Code memory documentation describes native AGENTS.md loading, with behavior affected by version, settings and the presence of CLAUDE.md files. It also documents an @AGENTS.md import from CLAUDE.md. Check the installed session instead of assuming either universal native loading or universal lack of support.

The Codex AGENTS.md guide, checked November 21, 2026, describes scoped instruction discovery and overrides. Ask Codex which sources it loaded for the actual working directory. A rule file at the repository root does not tell you whether a more specific rule changes the instructions for the files you are editing.

A minimal shared layout can have AGENTS.md for stable conventions and CURRENT-TASK.md for changing progress. Where the installed Claude configuration needs an adapter, a CLAUDE.md import can reference the shared rules. Treat that as a project choice to verify, rather than an instruction to overwrite an existing file.

Keep tool configuration and permission policy separate. Sharing a rule document does not install an MCP server, grant file access or make command names identical across runtimes. Verify each dependency in the receiving tool. If it cannot access a record, say so before proceeding on an assumed copy.

What should go in current task state instead of the rules?

Keep only information that changes where the next session should begin. Record the current goal, accepted decision and reason, permitted files, inspected evidence, actual results, open questions and next action. Link detailed logs instead of copying them into every restart.

  • Decision: what is accepted now, why, and where the approval came from. Keep rejected alternatives separate.
  • Implementation: which files changed and which changes remain incomplete. Record unrelated edits without taking ownership of them.
  • Validation: the command, relevant scope, observed result and where evidence is saved. A started command remains unverified until its result is known.
  • Environment: the intended checkout, branch, test fixture and any required local service. Do not include credentials.
  • Next action: one concrete action that can confirm or advance the current state, plus the boundary of existing authorization.

Use exact status words. “Implemented locally” is different from “built,” “deployed” and “verified with a real account.” If a UI passed local checks but has not been deployed, the record should not shorten that to “done” when the next task depends on production behavior.

When the owner changes direction, update the current decision and preserve the old rationale in history. Appending “actually do the other thing” at the bottom of a long diary leaves the next agent to infer precedence. Make the current pointer explicit and give the change an effective date or revision.

The shared-decisions guide follows a complete decision change. Use that pattern when the reason matters later. For a small bug fix, a few precise lines may be enough; do not introduce a formal decision system for every trivial edit.

How should I end one session and start the next?

Update the handoff after a meaningful change, rather than waiting until the conversation is already difficult to manage. Before stopping, compare the record with the diff and latest check results. Remove stale next steps and leave genuine unknowns visible.

  1. At the end: inspect the current diff and record what actually changed. Preserve unrelated work and name outstanding conflicts.
  2. Save the latest observed check results. If a process is still running, record that state and its recovery information without calling it passed.
  3. Replace the current next action with the action the receiving session should take now. Keep history separately if useful.
  4. At restart: confirm the working directory and inspect Git status before editing. Read the applicable rules and the latest task record.
  5. Compare the handoff with files and evidence. Resolve mismatches, then continue the authorized work.

A resumed session can save time when you are staying in the same host. It still benefits from a current task note. Resuming the wrong session, opening a copied folder or reading an old worktree can look like a memory failure while actually being an environment mismatch.

If the previous session stopped mid-command, inspect before rerunning. A read-only check is usually straightforward to repeat. A command that may have changed an external system needs evidence about what happened first. A handoff should state whether an operation was merely prepared, issued, acknowledged or independently verified.

Do not repeat an irreversible action because the old transcript is unavailable. Recover the external state through the approved read path and preserve the existing permission boundary. A task record can transmit context; it cannot create authority that the user never granted.

How can I test whether both agents really stay in sync?

Use a harmless project record with a known current decision and a superseded alternative. Ask each agent to read it in a fresh session and report the current version, source and next action. Then change the record deliberately and check both readers again.

Include one negative check. Ask about an unrelated project or an unverified result. The useful behavior is to keep the project boundary and admit the missing result. A system that confidently applies the sample decision everywhere has remembered something but failed the workflow.

For a connected record, follow the separate Claude Code setup and Codex setup instructions. Check each host’s read access and intended write scope. A working connection in one tool is not proof that the other is configured.

After a reviewed update, read back the stored record and repeat the current-decision question. If one agent still returns the old state, inspect record identity, source revision and whether it actually fetched again. Do not mask the discrepancy by pasting the expected answer into the test question.

For concurrent writers, define ownership before updating the same state. A revision number written in Markdown is a useful label, but it does not provide an atomic write lock. If the backing system offers conditional updates, use its documented behavior. Otherwise coordinate a single writer or reconcile from the latest readable version.

When you don't need SaveSlot

A small repository with deliberate handoffs can work well with Markdown and existing version control. If you stay in one tool and its session features meet your needs, keep using them. A shared service is not required to write a current task note or verify a restart.

Consider a structured shared record when changes span sessions or machines and manual synchronization keeps failing. It still does not replace the runtime, repository permissions, tests or deployment checks. Measure it by whether the next session starts from the right state and preserves the boundaries of the task.

8 prompts for session handoffs that survive a restart

Recover before editing

Confirm the repository, working directory and branch. Read applicable instructions and CURRENT-TASK.md. Inspect Git status. Restate the current decision, unrelated edits and next verifiable action before editing.

Audit instruction loading

List the project instruction sources actually loaded in this session, their scopes and any relevant overrides. Distinguish files you know exist from files whose contents you have read.

Write the handoff

Draft a current handoff from observed evidence: goal, decision and reason, permitted scope, changed files, check results, unknowns and next action. Do not mark started or unobserved checks as passed.

Review an interrupted command

The previous session stopped during this operation. Determine what can be verified from current files or approved read-only external checks before proposing a rerun. Preserve the existing authorization boundary.

Check a changed decision

Read the latest decision record and its source. Identify the current choice and superseded alternative. Explain what implementation must be checked after this change, without assuming it is already updated.

Test another agent

From the shared record alone, return the project ID, current decision revision, supporting source, unfinished work and next action. If access is missing or sources conflict, report that instead of using a guessed value.

Protect concurrent work

Inspect the latest status and diff. Identify changes belonging to this task and unrelated changes to preserve. If another writer changed the relevant record, reconcile from the latest version instead of overwriting it.

Separate acceptance levels

Summarize progress separately as implemented, locally checked, built, deployed and verified with the intended account or device. Include evidence for each level claimed and leave unobserved levels pending.

Questions developers ask about session memory

How do I keep Claude Code from forgetting my project between sessions?

Keep stable project rules and a short current-task record available to the new session. Make reading and checking them part of startup. Preserve decisions and reasons, rather than only a list of changed files. Verify the intended checkout and latest evidence before continuing so the new session does not blindly trust an outdated summary.

Can Claude Code and Codex share the same context?

They can read shared files or an authorized record, but they do not automatically share every conversation or runtime capability. Confirm that both can access the intended revision and understand its scope. Keep host-specific tools and permission settings explicit. A shared task record helps coordinate work without making the two execution environments identical.

Does Claude Code read AGENTS.md now?

The current official documentation describes native support, subject to version, configuration and other instruction files. Check what your installed session loaded. Where needed, use the documented import mechanism rather than assuming an ordinary sentence pointing to a file forces loading. Verify the result again after a configuration or host-version change.

Why does my CLAUDE.md go stale so quickly?

It may contain changing task progress that belongs in a separate record. Keep stable commands and conventions in the rule file; put the latest decision, blocker and next action elsewhere. Link the current record from the rules when appropriate. Review the handoff at meaningful stopping points so the pointer does not lead to yesterday’s work.

Should I stop using compaction to avoid losing details?

Do not adopt a universal rule from an anecdote. Preserve the evidence and decisions needed to recover work regardless of how the host manages context. After a transition, check the current task against the record. If a needed detail was omitted, improve the handoff and retain its source rather than assuming a fixed context percentage solves every task.

What should I do when the handoff and repository disagree?

Treat the discrepancy as something to investigate before the affected edit. Inspect the current diff, relevant source and check results. Another session may have progressed the work or the handoff may be stale. Update the record from observed evidence, preserve unrelated changes and avoid recreating an old failure merely to make the handoff appear correct.

Sources & notes

Check the linked official documentation for current product behavior. Illustrations and downloadable examples use fictional data; they do not demonstrate a live account connection or write.

Revision history

  • : Published a session-lifecycle guide covering instruction loading, interrupted work and verified restarts.

Prepared by Jasper with AI-assisted drafting and illustrations.

Keep exploring

All articlesLast updated