Claude Code forgot the task details after executing '/compact', usually because the key state only remains in the chat history and does not fall into the project file. /compact compresses the conversation to release context, but it is impossible to preserve all the details in the compressed summary, so long tasks require writing the state to a file.
What content must be placed
What files are being changed, why are they being changed, what steps have not been done, what are the verification commands, these are not just in the chat. This can be written to 'CLAUDE.md', 'TODO.md', 'notes/implementation-plan.md' or to a temporary task document.
If you just let Claude Code chat all the way, it may remember the general direction after compact, but forget about boundary conditions, user requirements, and pitfalls halfway through.
Handover before compact
When approaching the context cap, don't just '/compact'. Let it write a handover record: current goal, changes completed, unfinished items, tests runn, reason for failure, next step. Confirm that this record is accurate before performing compact.
Anthropic's help documentation also mentions that '/compact' is used to preserve the necessary context and free up space; Project documents and 'CLAUDE.md' can still be used as a basis for follow-up work.
Don't overfill CLAUDE.md
'CLAUDE.md' is suitable for long-term rules and project entries, not for stuffing the entire log of each task. Temporary task status is more suitable for a separate document and then deleted or organized after completion.
If you cram all the history into 'CLAUDE.md', the next new session will start with a lot of context and will be more likely to slow down.
The most stable approach
The task document is updated every time a long task completes a short section. Compact only compresses chat and is not responsible for project management tools. Let "the work status is in the file, and the chat is just the operation interface", so that Claude Code is not easy to fragment.