# 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.

Canonical HTML: https://canopyide.dev/guides/claude-code-forgot-task-after-compaction
Article date: 2026-09-28

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 lost | Check now | Give back to the session |
| --- | --- | --- |
| Goal or acceptance check | Issue, task brief, or product decision | One current outcome and its pass/fail check |
| Branch or completed work | Git status, diff, commit, and PR head | Checkout and exact changed files |
| Failed command | Saved log or a focused rerun | First error and command result |
| Reason for a choice | PR discussion or short decision note | Accepted choice and why the alternative was rejected |
| Local app state | Live service output and preview URL | Actual 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.

````text
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.

## Sources and further reading

- [Claude Code: context, auto-compaction, and focus instructions](https://code.claude.com/docs/en/how-claude-code-works)
- [Claude Code: /context, /compact, /clear, and /resume commands](https://code.claude.com/docs/en/commands)
- [Claude Code: what project memory reloads after compaction](https://code.claude.com/docs/en/memory)
- [Canopy app README: sessions and project context](https://github.com/FluidWorksApp/canopy-ide/blob/main/README.md)

## Related Canopy pages

- [Keep coding-agent context useful between sessions](https://canopyide.dev/guides/keep-agent-context-between-sessions.md)
- [Find the old agent session, then resume the right project](https://canopyide.dev/use-cases/find-old-agent-session-and-resume-project.md)
- [How to reduce coding-agent token usage without losing the result](https://canopyide.dev/guides/reduce-coding-agent-token-usage.md)
- [The coding agent says done, but the app is still broken](https://canopyide.dev/guides/agent-says-done-but-app-is-broken.md)
- [Switch from Claude Code to Codex without losing the task](https://canopyide.dev/guides/switch-coding-agents-without-losing-context.md)

Canopy runs installed coding CLIs; CLI accounts, model selection, and provider billing remain separate. Check the installed release before relying on version-specific behavior.
