What context pollution is
Context pollution occurs when outdated hypotheses, side topics, large logs, and conflicting constraints accumulate. Claude may return to disproven assumptions, ignore fresh rules, or expand the diff without changing the original goal.
| Situation | Sign |
|---|---|
| Insufficient data | Claude asks for a specific file, log, or reproduction step |
| Polluted context | Claude works from old assumptions and confuses tasks |
| The task changed | Independent workstreams are mixed in the conversation |
| Changes are questionable | The git diff should be reviewed first |
Recovery actions map
| Action | When to use it | Caution |
|---|---|---|
/compact | The goal is the same, but the history is too large | Details may disappear |
/clear | A different task has started | The specification must be entered again |
/rewind | The latest direction is clearly wrong | Does not guarantee that file changes are undone |
| New session | Severe disorder or several failed attempts | Only verified facts should be carried over |
| Diff review | Code has already changed and trust is low | The process temporarily slows down |
Recovery algorithm
- Stop making new changes.
- Determine whether data is missing or already getting in the way.
- If files were edited, read
git diffand check the scope. - Choose
/compact,/clear,/rewind, or a new session. - Restore the task spec: goal, boundaries, prohibitions, evidence, and criteria.
- Start with read-only analysis and a plan for the smallest correction.
- Allow editing only after verifying the direction.
What to carry into a new session
- Do not carry over the entire old history.
- Do not present rejected hypotheses as current.
- Replace large logs with short relevant excerpts.
- Keep only facts, decisions, and the next action.
## Verified facts
- Symptom:
- Reproduction steps:
- Relevant files:
## Rejected hypotheses
- ...
## Immutable constraints
- ...
## Next action
- Analyze ... first without editing.Recovery summary
A mature process is not endless correction of responses in the same conversation. Diagnose the session state in time, clear or compress it, check Git changes, and resume work with a clear task spec.
Canonical lesson source · JavaRush
Open JavaRush material