A curated collection of patterns and tools for managing context rot in AI-assisted coding.
Context rot is the practical failure mode of long, mixed-purpose AI coding sessions: contradictions, forgotten constraints, vague plans, and repeated re-explanations as the working context becomes polluted.
Operating Model
Most effective approaches map to four levers:

Snapshot & Rehydrate
Record authoritative project state in files; resume from those instead of chat history
Quantitative Guidance
Research-backed thresholds for context management:
| Metric | Recommendation | Rationale |
|---|---|---|
| Effective context window | <256k tokens | Models degrade well before advertised limits (1M+) |
| Context utilization | Stop at ~75% | Sessions at 90% produce more code but lower quality |
| Compaction trigger | ~128k tokens or 50% utilization | Compact before degradation, not after |
| Memory/rules file size | <300 lines | Context tokens are precious; shorter is better |
Patterns
STATE.md as source of truth
Maintain a STATE.md file in your repository with:
- Objective — what "done" means
- Constraints — non-negotiables
- Decisions — selected approach and rationale
- Current status — where things stand
- Next steps — 3-7 concrete items
When outputs begin to drift, update STATE.md and start a fresh session using only that file plus relevant source code.
# STATE
## Objective
- ...
## Constraints
- ...
## Decisions
- ...
## Current Status
- ...
## Next Steps
1. ...
2. ...
3. ...Task-scoped sessions
One task per session. When you finish a task or pivot to something different, end the session and start fresh. Mixing unrelated work in a single context accelerates rot.
Phase separation
Split work into distinct phases (research, planning, implementation, review) and run each in its own session. Don't let implementation details pollute research context, or planning debates pollute implementation.
Fresh-start rehydration
When context feels degraded, don't try to recover it. Instead:
- Update your state file with current knowledge
- Start a new session
- Load only: state file + relevant source files (or a packed digest)
This is cheaper and more reliable than trying to "fix" a polluted context.
Controlled repository slicing
Never dump an entire repository into context. Use packing tools to provide:
- Only files relevant to the current task
- Summaries instead of full content where appropriate
- Token-aware truncation
Antipatterns
Dumping entire repositories
Loading a full repo into context wastes tokens on irrelevant code and drowns the signal in noise. The model will hallucinate connections between unrelated files and lose track of what matters.
Mixing planning and execution
Debating architecture while also writing code creates a context where half-formed plans mix with implementation details. Neither activity gets clean focus. Separate them into distinct sessions.
Chat history as project memory
Relying on earlier messages to remember decisions, constraints, or status. Chat history degrades, gets summarized lossy, and eventually falls out of context entirely. Externalize to files.
Pushing through drift
When outputs start missing constraints or repeating mistakes, continuing in the same session makes it worse. The context is polluted. Stop, snapshot, restart fresh.
Over-trusting summaries
Automatic summaries lose detail. When you resume from a summary, verify critical constraints and decisions are actually present. Don't assume the summary captured everything that matters.
Overloading a single agent
Asking one agent/session to handle research, planning, implementation, and review. Each activity pollutes context for the others. Use separate agents or sessions for separate concerns.
Tools
Each tool is included because it exposes a clear mechanism for one of the four levers.
Orchestration and Phase Separation
Tools that enforce phased execution and externalize state.
| Tool | Mechanism | Best for |
|---|---|---|
| Get Shit Done (GSD) | Spec-driven phases with persistent state files | Multi-phase feature delivery |
| Ralph | Autonomous loop runner with explicit completion gates | Long-running iteration with guardrails |
| Continuous Claude | Hooks + ledger/handoff patterns | Structured CLI workflows with state preservation |
| Claude Code Workflow | JSON-driven multi-step structure with explicit phase boundaries | Repeatable, bounded agent execution |
Parallel Work Without Context Bleeding
Tools for running multiple workstreams while keeping contexts isolated.
| Tool | Mechanism | Best for |
|---|---|---|
| workmux | Git worktrees + tmux to isolate at filesystem/session level | Parallel development without context mixing |
| Claude Squad | Multiple agents in separate terminal workspaces | Running parallel agent workstreams |
| Vibe Kanban | Multi-agent orchestration with task tracking | Managing multiple concurrent tasks/agents |
Repository Packing
Tools that produce controlled, prompt-friendly repository context.
Memory Persistence
Tools that persist decisions and state across sessions.
| Tool | Mechanism | Best for |
|---|---|---|
| memory-bank-mcp | Remote memory bank service via MCP | Cross-session project memory |
| Context Portal | Structured, DB-backed project context via MCP | Durable source-of-truth memory |
| Cursor Memory Bank | Structured memory workflow with rules loading | Reducing repeated explanations in Cursor |
| Cursor Rules | Persistent, versioned instructions per repository/path | Project-level AI configuration |
Compaction and Pruning
Tools and features for compacting long sessions before degradation.
| Tool | Mechanism | Best for |
|---|---|---|
| OpenCode | Built-in compaction/pruning workflows | Long terminal sessions |
| Claude Code | /compact command and session management | CLI-based context hygiene |
Research
Foundational reading on context management in AI-assisted development.



