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.

SituationSign
Insufficient dataClaude asks for a specific file, log, or reproduction step
Polluted contextClaude works from old assumptions and confuses tasks
The task changedIndependent workstreams are mixed in the conversation
Changes are questionableThe git diff should be reviewed first

Recovery actions map

ActionWhen to use itCaution
/compactThe goal is the same, but the history is too largeDetails may disappear
/clearA different task has startedThe specification must be entered again
/rewindThe latest direction is clearly wrongDoes not guarantee that file changes are undone
New sessionSevere disorder or several failed attemptsOnly verified facts should be carried over
Diff reviewCode has already changed and trust is lowThe process temporarily slows down

Recovery algorithm

  1. Stop making new changes.
  2. Determine whether data is missing or already getting in the way.
  3. If files were edited, read git diff and check the scope.
  4. Choose /compact, /clear, /rewind, or a new session.
  5. Restore the task spec: goal, boundaries, prohibitions, evidence, and criteria.
  6. Start with read-only analysis and a plan for the smallest correction.
  7. 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.
SESSION_LOG.md or emergency task spec
## 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