When a long Claude Code session seems to lose the thread, the fix is to stop relying on the conversation as the only record of the task. Write the task state into files in your project, then resume or restart Claude Code and point it at those files. This guide covers the documented recovery commands, a state-file workflow, and what is and isn’t established about compaction.
What is actually known about compaction
Long sessions eventually run into the limits of a context window. Users describe the result as Claude Code “forgetting”: it repeats work, drops a decision you made earlier, or loses track of the next step. Anthropic’s documentation that covers this topic supports session-recovery commands and state-management advice. The pages reviewed for this article do not state a current automatic-compaction trigger threshold. They also do not guarantee which details survive compaction. So this article gives no numeric threshold and no list of what gets dropped. Treat any such claim elsewhere with caution unless it cites a current Anthropic Claude Code reference.
The practical consequence is simple: anything important that exists only in the conversation is at risk. Anything written into the project is not.
Step 1: Save state to files before a transition
Anthropic’s prompting best practices recommend that, for work spanning multiple context windows, you save progress and current state to memory. They also describe organizing progress in structured files that a later window can review. The template below is an editorial implementation of that advice, not a format Anthropic prescribes.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Ask Claude Code to write a short state file (for example PROGRESS.md) in the project containing:
- Goal: one or two sentences on what you are trying to achieve.
- Decisions: choices made and the reason, so they aren’t relitigated.
- Files changed: paths touched so far.
- Checks run: tests or commands executed and their results.
- Outstanding work: a short checklist.
- Next step: the single next concrete action.
Update it at natural milestones, not only when the session feels strained. A short checklist is easier to recover than an implicit conversation summary.
Step 2: Choose how to get back in
Anthropic’s CLI reference documents two ways to return to earlier conversations.
| Command | What it does | Use it when |
|---|---|---|
claude -c or claude --continue |
Continues the most recent conversation in the current directory | The session you want is the latest one in this project |
claude -r "<session-id>" or claude --resume <session-id> |
Resumes a specific session by ID | The session you want isn’t the most recent and you have its ID |
Run claude -c from the same directory as the original work, since “most recent” is scoped to the current directory. Resuming recovers conversational context, but the CLI reference does not promise perfect recall of every detail, and neither command is documented as repairing or removing a compaction summary.
Rank #3
Step 3: Decide between continuing and starting fresh
Anthropic’s guidance states: “Starting fresh versus compacting: When a context window is cleared, consider starting with a brand new context window rather than using compaction.” The stated reasoning is that Claude can rediscover state from the local filesystem. This is context-dependent advice, not a universal rule.
- Favor a fresh session when the repository and your progress file reflect the real state of the work: code is committed or saved, tests exist, notes are current.
- Favor continuing or resuming when the key information lives only in the conversation, such as exploratory reasoning, rejected approaches, or requirements you stated verbally and haven’t written down.
Step 4: Re-orient Claude explicitly
If a session feels disoriented, don’t just say “continue.” Give it a grounded instruction, for example:
Read PROGRESS.md and review the files it lists. Summarize the goal, what’s done, and the next step. Don’t change anything until I confirm.
Then check the summary against the repository (for instance with git status and git diff) and your notes. Don’t assume a resume alone restored every unstated decision. If something is wrong, correct it and update the progress file so the correction persists.
Quick Recap
Best Value
Failure modes to watch for
- Stale state file: a progress file that isn’t updated is worse than none, because Claude will trust it. Refresh it after each milestone.
- Wrong directory:
claude -clooks at the current directory, so launching elsewhere gives you a different conversation. - Decisions kept only in chat: if a constraint matters, put it in the file.
- Vague next step: “keep going” recovers poorly. Record a concrete action.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




