# Context hygiene

The active practice of selecting, labeling, refreshing, compacting, and removing model-visible information so the working context stays relevant, attributable, and within budget.

technical-term · Context & knowledge · maturing · Reviewed 2026-08-09

## Definition

Context hygiene manages the quality of an agent’s finite working set over time. It chooses the smallest sufficient instructions, state, evidence, retrieved material, and tool output; tracks provenance and freshness; summarizes with a path back to primary sources; and starts a clean context when accumulated history creates more noise than value. It does not mean deleting evidence or assuming a larger context window removes the need for selection.

Context selection and compaction are established constraints, while reusable measures and operating standards for hygiene are still developing.

## Why it matters

Every token competes for model attention and can carry stale assumptions, untrusted instructions, or irrelevant detail into the next decision.

Durable state and evidence should live outside transient context. A refreshed agent can load the current task packet without losing the authoritative history.

## System anatomy

- **Selection:** Load only information relevant to the present decision.
- **Provenance:** Retain source, trust, and recency labels for context items.
- **Compaction:** Summarize history while preserving links to primary evidence and unresolved decisions.
- **Refresh:** Restart with clean context and explicit state when accumulation degrades performance.



## Important distinctions

- **Large context window:** Capacity says how much can fit; hygiene determines what deserves to be present and trusted.
- **Deleting history:** Transient context can be refreshed while durable evidence and decision records remain available.



## Implementation signals

- Separate authoritative state from conversational history
- Load detail progressively from a compact task packet
- Mark summaries as summaries and retain primary-source pointers
- Test performance under realistic context noise

## Failure modes

- Old instructions silently override the current task
- Compaction converts an uncertain claim into an apparent fact
- Tool output floods the context with low-value detail



## Related knowledge

- [Context engineering](https://aisdlc.ai/agentic-engineering/context-engineering) — The deliberate selection and maintenance of instructions, knowledge, tools, state, examples, and artifacts within a finite model attention budget.
- [Context window](https://aisdlc.ai/agentic-engineering/context-window) — The finite sequence of tokens a model can directly condition on during a single inference operation.
- [Working state](https://aisdlc.ai/agentic-engineering/working-state) — The current, inspectable record of an agent’s task position, observations, decisions, pending actions, and budgets.
- [Agent-readable codebase](https://aisdlc.ai/agentic-engineering/agent-readable-codebase) — A repository engineered so coding agents can discover its purpose, boundaries, commands, constraints, and feedback paths without reconstructing the system from an entire history.

## Sources and further study

- [Anthropic — Effective context engineering for AI agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) — A working model for treating model-visible context as a finite resource that must be selected and maintained. **Use:** First-party case study. **Limitation:** This first-party account documents one organization, product, or implementation context and should not be generalized without local evidence.
- [Anthropic — Effective harnesses for long-running agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents) — Patterns for incremental progress and durable handoffs across context windows and extended execution. **Use:** First-party case study. **Limitation:** This first-party account documents one organization, product, or implementation context and should not be generalized without local evidence.
- [AI Hero — Claude Code for Real Engineers](https://www.aihero.dev/cohorts/claude-code-for-real-engineers-2026-04) — The official course page frames AI-assisted engineering around planning, decomposition, steering, feedback loops, tracer bullets, sandboxing, and maintaining navigable production codebases. **Use:** Practitioner perspective. **Limitation:** This is a commercial course description and first-party outcomes narrative, not independent evidence of learner or production results; examples focus on Claude Code.
- [Matt Pocock — mattpocock/skills: A complete AI Coding workflow, end-to-end](https://www.youtube.com/watch?v=M6mYodf0dJM) — Demonstrates a skills-based coding workflow that develops shared domain context, writes a specification, decomposes work into tickets, implements it, and reviews against the specification and standards. **Use:** Practitioner perspective. **Limitation:** This is a first-party workflow demonstration rather than comparative evidence. A fresh-context model review is useful challenge but is not automatically an independently owned verifier.

---

This library synthesizes cited research, standards, official documentation, and clearly attributed practitioner perspectives. Maturity describes the state of a concept—not vendor endorsement, production readiness, or permission to deploy. Benchmarks and demonstrations do not replace use-case evaluation, governed controls, independent verification, or named human release authority.
