## Definition
**Session-scoped task hygiene** is the discipline of treating the agentic session boundary as the primary unit of cognitive containment: one task per session, sessions named for their scope, and a local commit at every green test. The core argument is that ending a session is cheaper than carrying contaminated context into the next task.
## The Three Habits
The three habits work as a compounding system, not as independent tips:
1. **One task per session.** When a feature, bug fix, or investigation is complete, end the session. Starting fresh costs nothing. Carrying the prior task's context into the next task costs [[Context Rot]] — the agent's accuracy on the new task is degraded by irrelevant tokens from the old one, often invisibly.
2. **Name your sessions.** Most agentic CLIs allow tagging a session at startup (e.g., `claude --session feat/passwordless`). A named session is recoverable: `/resume` brings it back without reconstruction. Anonymous sessions vanish opaquely when interrupted.
3. **Commit at every green test.** Even without pushing, a local commit is a deterministic checkpoint. If the agent goes off-piste on the next step, `git reset --hard HEAD` recovers the last known-good state without negotiation. The commit serves the human, not the agent — but the agent also uses it as a coordination point when asked to recover.
## Relationship to Context Rot
[[Context Rot]] explains the mechanism: as the context window fills, the model's attention to any given fact degrades non-monotonically. Session hygiene is the session-level response to this: rather than fighting degradation within a session with compaction tricks, the session boundary is used proactively to reset. The habits in §4.5 of the course are framed as a *system* precisely because each one addresses a different failure mode of session contamination — context pollution, session unrecoverability, and state loss respectively.
## Cost Meter as Diagnostic
The `/cost` command surfaces session spend in real time. Most sessions should be well under one dollar. If a session regularly costs double-digits for a single task, something is wrong upstream — either an unbounded loop, a session that refused to die, or context stuffed with irrelevant material. The cost meter is therefore a proxy health signal for hygiene: high cost correlates with hygiene failure, not with task complexity alone.
## Ending the Session as a Practice
The unconditional end of a session after task completion is the session-level analogue of a commit: it marks the boundary, prevents cross-contamination, and forces the next task to start from a clean state. "Ending the session is cheaper than carrying contaminated context" is the principle; the three habits are its operational form.
## Related
- [[Context Rot]]
- [[Context Compaction]]
- [[Agentic CLI]]
- [[AGENTS.md Convention File]]
## Sources
- [[Modern AI Software Engineering - The Orchestrators Playbook]]