Problem
Why AI Coding Agents Lose Context Between Sessions
Resume the right session, check unfinished work, and give the next agent a clear starting point.
01
Choose resume or a fresh start.
02
Check the current code and test results.
03
Give the next agent one clear next step.
01
Quick answer
A fresh session lacks the previous conversation; compaction can omit details. Start with the recovery path that matches what went missing.
| What you need | Start here |
|---|---|
| The earlier conversation | In Claude Code, resume the native session: claude --continue for the latest eligible session in this project, or claude --resume to choose one. |
| Standing rules | Check the project instructions and native memory loaded by your client. |
| A decision lost during compaction | Open its saved note or transcript. Unrecorded reasoning stays unknown. |
| To continue in a new session or tool | Read the handoff, then check it against the current files using the steps below. |
02
Check what changed
Before editing, compare the handoff with the current repository. These commands inspect your work without resetting, staging or committing it.
Replace src/retry.mjs with a relevant path. For the last command, replace BASE_COMMIT with the handoff's verified commit; skip it if none was recorded.
- Check every kind of change: diff shows unstaged edits, --cached shows staged edits, and status lists untracked files to read separately. Preserve unrelated work.
- A clean worktree can still contain commits made after the handoff. Compare its recorded commit with HEAD too.
- Match test results to the code version they checked. Inspect unfamiliar test commands before rerunning them; missing results are unchecked.
- Find reasons in decision notes or the handoff, and command history in saved transcripts or terminal logs. A diff cannot reconstruct either.
pwd
git branch --show-current
git rev-parse HEAD
git status --short
git diff --stat
git diff -- src/retry.mjs
git diff --cached -- src/retry.mjs
# Also compare any commits since the handoff:
git diff BASE_COMMIT HEAD -- src/retry.mjs03
Give the next agent this prompt
Replace HANDOFF.md with your actual handoff path. Have the agent report its findings before editing.
Recover the task in HANDOFF.md.
Read project instructions first.
Do not edit, stage, reset, commit,
or push.
Check the branch and HEAD.
Compare commits since the handoff.
Inspect staged, unstaged and
untracked files.
Report:
- Completed and unfinished work.
- Decisions, reasons and sources.
- Test results and tested versions.
- Conflicts with current files.
- One next action.
Mark missing evidence unknown.04
Example: an old test pass no longer applies
We ran a tiny fictional Git project whose goal was to raise a retry limit. The handoff recorded a passing test; then only the implementation changed.
The rerun caught the mismatch. The next step was to reconcile the intended behavior and test, rather than call the task finished.
This was a synthetic Git/Node exercise, without an LLM or Wenlan run. The input files stayed unchanged during inspection and the test rerun.
| Version checked | Retry limit | Actual test result |
|---|---|---|
| Saved baseline | 2 | Passed: the test expected 2. |
| Current working tree | 3 | Failed: actual 3, expected 2; exit 1. |
05
When Wenlan helps
A handoff file can be enough for one project. Wenlan helps when several configured AI tools need durable decisions, reasons and project status in a shared memory boundary.
The loop below requires Wenlan's Claude Code or Codex plugin. MCP-only clients can use context, recall and capture tools, with an explicit handoff for unfinished work.
Keep code changes in Git and command history in saved transcripts or terminal logs. Wenlan does not replace those records or native resume.
/brief
/recall <specific decision or gotcha>
/capture <one durable fact and why it matters>
/handoffCarry one decision into the next session
Try the Claude-to-Codex example and compare the saved decision with the retrieved source.
FAQ