What context rot is
Context rot is the quality degradation that accumulates as an AI fills its context window with conversation history. The model’s attention is finite — as the window fills, the signal-to-noise ratio drops, earlier content receives less attention, and the quality of reasoning and recall quietly degrades. The model does not warn you when this happens. It continues generating output, but that output is less accurate, less consistent, and more likely to contradict earlier decisions. Context rot is why an AI that produces excellent results on a fresh task produces mediocre results on the tenth task in the same session. The model has not changed — its context has degraded.Fresh-context subagent architecture
GSD Core’s primary defense against context rot is architectural: heavy work never runs in the main session. Instead, thin orchestrators spawn specialist subagents, each in its own isolated context window. When you run/gsd-plan-phase 1, the orchestrator does not do the planning in your current conversation. It spawns:
- Four researcher subagents — each with a fresh context window, each focused on one research dimension
- A synthesizer subagent — reads only the four research outputs, nothing else
- A planner subagent — reads only
PROJECT.md,REQUIREMENTS.md,CONTEXT.md, andRESEARCH.md - A plan-checker subagent — reads only the generated plans and the phase context
PLAN.md files) arrives in your session without the accumulated cost of the work that produced it.
This pattern holds throughout the phase loop:
- Execute: Each executor subagent gets one plan and a fresh context — parallel executors run simultaneously without sharing state
- Verify: The verifier reads all summaries and performs a goal-backward check in its own clean window
- Map codebase: Four mapper subagents explore different dimensions of your codebase in parallel
/clear to reset the conversation context. GSD Core is designed for this — the state that matters is in .planning/, not in conversation memory.
The context monitor hook
Even with fresh-context subagents, some workflows run in the main session for extended periods. The context monitor hook watches your context usage in real time and injects warnings directly into the agent’s conversation when usage runs high. The hook works as a pipeline between two components:Warning thresholds
| Remaining context | Level | Message injected |
|---|---|---|
| > 35% | Normal | No warning |
| ≤ 35% | WARNING | Wrap up the current task; avoid starting new complex work |
| ≤ 25% | CRITICAL | Context nearly exhausted; save state with /gsd-pause-work and start a new session |
The context monitor is advisory only. It injects a warning that the agent sees, but it never blocks tool execution or overrides your commands. A broken monitor exits silently — it cannot interfere with your workflow.
Debounce behavior
To avoid flooding the agent with repeated warnings, the monitor debounces after the first alert:- The first warning fires immediately when a threshold is crossed
- Subsequent warnings at the same severity level require five tool uses between them
- Severity escalation from WARNING to CRITICAL bypasses the debounce and fires immediately
Status line
The status line hook also renders a persistent status bar in your terminal showing the current model, active task, working directory, and a context usage bar. This gives you a human-readable view of the same context metrics the agent sees internally.Prompt guard and read injection scanner
GSD Core generates Markdown files that become LLM system prompts. Any user-controlled text that flows into planning artifacts is a potential indirect prompt injection vector — an attacker could embed instructions in a file you ask GSD Core to read, and those instructions could execute in the agent’s context. GSD Core includes two defensive hooks:Prompt guard (gsd-prompt-guard.js)
The prompt guard fires on every Write or Edit call to .planning/ files. It scans the content being written for known injection patterns:
- Role override attempts (
"Ignore previous instructions","You are now...") - Instruction bypass patterns
- System tag injections
Read injection scanner (gsd-read-injection-scanner.js)
The read injection scanner fires after every Read tool call. It scans the tool output for embedded instructions in untrusted content — for example, a source file or external document that contains hidden directives designed to manipulate the agent.
Like the prompt guard, the scanner is advisory and never blocks the read. Together, the two hooks provide defense-in-depth against the most common prompt injection vectors.
Cross-session persistence
GSD Core maintains project state across sessions without relying on conversation memory. Two files are the backbone of session persistence:STATE.md
STATE.md is the living memory of your project. It is updated after every significant action and contains the current position in the phase loop, active decisions and blockers, and metrics. When you start a new session, running /gsd-progress reads STATE.md and tells you exactly where you left off and what to do next.
STATE.md is designed to be small and high-signal. It does not hold the full history of every decision — it holds the current state and the most recent decisions that are still active. Historical decisions are archived in phase artifacts.
continue-here.md
continue-here.md is a structured handoff document written by /gsd-pause-work. It captures the current session’s momentum:
- What was completed in this session
- What is currently in progress
- What the next concrete step is
- Any open questions or blockers
/gsd-resume-work at the start of a new session, GSD Core reads continue-here.md alongside STATE.md to restore full context without re-reading the entire conversation history. The agent comes back oriented and ready to continue — not asking you to re-explain the project.
Practical context discipline
Follow these practices to keep context healthy throughout a project:Run /clear between major commands
Run /clear between major commands
GSD Core is designed for frequent context clears. After
/gsd-new-project, after /gsd-plan-phase, and after /gsd-execute-phase, run /clear before the next command. All state is in .planning/ — nothing important is lost.Use /gsd-progress when you return
Use /gsd-progress when you return
After any break, run
/gsd-progress before doing anything else. It reads STATE.md and tells you exactly where you are and what step is next. This is faster and more accurate than re-reading the conversation history.Respond to WARNING messages
Respond to WARNING messages
When the context monitor injects a WARNING, finish your current task and then run
/gsd-pause-work to save state, /clear to reset context, and /gsd-resume-work to pick up exactly where you stopped.Respond to CRITICAL messages immediately
Respond to CRITICAL messages immediately
When the context monitor injects a CRITICAL warning, stop immediately. Run
/gsd-pause-work to write the handoff, then /clear. Do not start new work in a critical context — the output quality will be degraded.