Guide / 2026-09-28

Why did Claude Code forget my task after compaction?

Recover a Claude Code task after /compact by checking the actual branch, diff, tests, and lost instructions before giving the agent one verified next step.

Canopy project context beside coding-agent sessions
Canopy project context beside coding-agent sessions

You return to a long Claude Code session after it compacts and the agent repeats a finished step, forgets a constraint, or asks which branch matters. Compaction summarizes the conversation so work can continue with less context; it does not certify the new summary against the repository. Recover the task from current files and decisions first, then give the session a short correction it can verify.

Identify what was lost before restarting

Ask the session to state its current goal, branch, latest accepted change, tests actually run, and next action. Compare that account with the open issue or task, the current Git branch and diff, and the latest PR commit. A wrong summary is a context problem; an uncommitted file or a failing test is a work-state problem. Canopy can keep the session, repository, project notes, and running app near one another, but the visible conversation is not proof that code changed or a test passed. Do not respond to apparent forgetting by repeating the entire original prompt and launching the same edit again.

Choose the evidence that answers the missing part.
What the agent lostCheck nowGive back to the session
Goal or acceptance checkIssue, task brief, or product decisionOne current outcome and its pass/fail check
Branch or completed workGit status, diff, commit, and PR headCheckout and exact changed files
Failed commandSaved log or a focused rerunFirst error and command result
Reason for a choicePR discussion or short decision noteAccepted choice and why the alternative was rejected
Local app stateLive service output and preview URLActual process, checkout, URL, and observed behavior

Check Claude Code's context boundary

Claude Code's documentation says the context window holds messages, files, command output, project memory, skills, and other instructions. It may clear older tool outputs and summarize a long conversation; detailed instructions given early in chat can be lost. Run `/context` in the Claude Code session to see what is consuming the window, and inspect the session after `/compact` rather than assuming the summary retained every condition. Claude documents `/compact` with optional focus instructions, such as the API change that must continue. This is a Claude Code command; another installed CLI can have a different compaction and resume behavior.

  • Keep the same session if its current context remains useful and its task is still the same.
  • If the task changed, use that CLI's documented new-session route and a verified handoff.
  • Do not treat a context percentage as a provider plan limit or a bill.

Restore the missing decision from durable evidence

For a settings-form retry, a useful recovery note says: the intended behavior, the branch and latest commit, the files touched, the failing request path, the tests that passed or failed, and the decision not to change the database schema. Link the PR or issue where those facts were accepted. Verify each item against the live checkout before asking the agent to proceed. If a previous approach failed, record its result and why it was rejected; otherwise a compacted session may repeat it. Avoid putting raw customer data, credentials, or a huge terminal transcript into the handoff. A concise note is easier for another agent to inspect and cheaper to carry into later turns.

  • Separate observed results from the prior agent's claims.
  • Include one next action, such as reproduce the failed save and inspect its handler, rather than a broad restart request.
  • Name the person who can decide an unresolved product rule or risky deployment change.

Put stable rules where Claude will reload them

Anthropic says a project-root `CLAUDE.md` is read again after compaction, while a conversation-only instruction can disappear. Nested instructions and path-scoped rules reload when the relevant files are read or matched. Put durable project conventions there: which command runs the app, how tests are named, and a rule that applies to future tasks. Keep today's branch, half-finished feature, and transient error in a task note or PR instead of turning them into permanent instructions. Claude's memory guide warns that oversized instruction files consume context and may reduce adherence, so keep the file focused. In Canopy, shared project notes and task artifacts can help the next session find that state; verify its installed version and the actual file the CLI loaded.

  • Make durable instructions short enough to inspect and maintain.
  • Use a PR, issue, or task note for changing work state and decisions.
  • After adding an instruction, test it in a fresh or compacted session instead of assuming it loaded.

Resume with a check, not a memory test

Give Claude Code the concise recovery card and ask it to inspect the cited branch, diff, and failing path before editing. Have it restate the acceptance criteria and identify the first command or browser action that would prove the remaining problem. Then let it perform one bounded step and compare the result with the current files. If it proposes redoing work that is already in the PR, point to the exact commit and ask what remains. If a new session or another CLI takes over, use the same evidence handoff; the other CLI does not inherit Claude Code's private transcript. Finish by updating the task note with the observed result so the next compaction has a current anchor outside the chat.

  • Verify the checkout, process, and preview URL before testing the fix.
  • Check the latest diff and result after the recovery step.
  • Escalate a genuine missing product decision rather than asking an agent to infer it from an old transcript.

Copyable resources

After-compaction recovery card

Fill this from current evidence, not only from the agent's summary.

Current outcome and acceptance check: [ ]
Issue/PR, checkout, branch, and latest commit: [ ]
Changed files and observed behavior: [ ]
Commands/tests actually run and first failing result: [ ]
Accepted decision and rejected approach with reason: [ ]
Service process and preview URL, if relevant: [ ]
Constraint that must survive this task: [ ]
One next action for this session: [ ]
Before editing: inspect the cited files and restate the acceptance check.
After editing: report the new diff, exact checks, and remaining uncertainty.

Frequently asked questions

Does /compact delete my code changes?

Compaction changes what the model carries in conversation context. Check Git status, the files, and the PR for the actual code state before assuming anything was lost or finished.

Will CLAUDE.md survive Claude Code compaction?

Anthropic documents that the project-root file is re-read after compaction. Nested or path-scoped instructions have loading conditions, so verify the relevant file was read and keep task-specific state in a current artifact.

Should I paste the entire old conversation after compaction?

Usually start with the goal, branch, decisions, exact failing result, and one next action. Retrieve a specific old message or log only if the remaining question requires it.

Can I hand the compacted Claude task to another coding CLI?

Yes, through current repository artifacts and a short handoff. Another CLI has its own conversation and model account, so verify its checkout and task understanding before it edits.

Browse more Canopy questions →

Sources and further reading