Why does Claude Code forget its own instructions mid-task and undo its own work after compacting?
Context compaction doesn't re-read CLAUDE.md and auto-continues with degraded context, so the agent sometimes actively undoes work it just built because it forgot doing it, with no pause or confirmation.
Category: AI / Agents · Trend: Agents · Opportunity score: 7.2 / 10
What is the “Why does Claude Code forget its own instructions mid-task and undo its own work after compacting?” problem in 2026?
Context compaction doesn't re-read CLAUDE.md and auto-continues with degraded context, so the agent sometimes actively undoes work it just built because it forgot doing it, with no pause or confirmation.
Who has this problem?
Developers running long, complex Claude Code sessions on real production codebases.
Recorded source context
Dataset source note: It's like having a brilliant employee who every 5 minutes becomes an imbecile and has to relearn everything — while actively destroying what they just built.
This note may summarize the referenced material rather than quote it verbatim. Source label: anthropics/claude-code GitHub issue #21925, gizyckik, 30 Jan 2026. (reference).
Existing players in this space
- Automatic compaction: Built-in but silent, no pause, no CLAUDE.md reload, no warning.
- Manual /clear + restart: Avoids the bug but loses all session context deliberately.
What existing players are missing
A compaction mode that pauses for confirmation, re-reads CLAUDE.md, and shows a diff of what context was dropped before the agent is allowed to continue acting on a degraded memory.
How Real Problem AI scores this opportunity
Aggregate score: 7.2 / 10. Four-axis rubric:
- Problem severity: 8 / 10
- AI feasibility today: 7 / 10
- Market signal: 7 / 10
- Competition gap: 7 / 10
How to build a solution: stack hints
- Compaction pause/confirm gate
- CLAUDE.md re-injection on resume
- Context-loss diff viewer
- Session checkpoint/rollback
Related AI / Agents problems on Real Problem AI
- My AI agent repeated one broken action all night, and I only saw the cost in the morning. (9.0/10)
- Someone opened a function to fix one bug and it was 300 lines nobody wrote by hand. (9.0/10)
- Why can a hidden line of text on a webpage hijack my AI agent and steal my data? (8.0/10)
- Why does my AI agent have the same production access as my senior engineer but none of the judgment? (8.0/10)
- Why does Claude Code hide your own plan quota from the terminal you live in? (8.0/10)