Install
openclaw skills install context-hygieneReasoning hygiene protocol for OpenClaw agents — keep context sharp by collapsing exploration into decisions, enforcing file budgets, and pruning ghost conte...
openclaw skills install context-hygieneInspired by ContextSpectre's philosophy: keep conclusions, remove scaffolding.
OpenClaw agents accumulate context across workspace files — MEMORY.md, daily logs, tool notes, heartbeat configs. Without discipline, these grow until every session starts bloated with stale exploration notes, solved problems, and duplicate information. The agent wastes tokens re-reading noise.
Every task follows three phases:
Never keep "how we got here" when "what we decided" is enough.
| File | Max lines | Review cycle |
|---|---|---|
| MEMORY.md | 50 | Weekly prune |
| memory/YYYY-MM-DD.md | 30 | Collapse at EOD |
| HEARTBEAT.md | 10 | Remove when done |
| TOOLS.md | 30 | When things change |
| SOUL.md | 30 | Rarely |
| USER.md | 20 | When learning |
Target: <300 lines total injected workspace context.
Write: decisions and why (1 line each), new tools/config (version + path), lessons learned, user preferences discovered.
Skip: exploration steps, command outputs, things already in MEMORY.md, delivered content (digests, summaries).
Format: Bullets, not paragraphs. One fact per line.
Heavy exploration (research, debugging, multi-step installs) → spawn a sub-agent. Isolated sessions don't pollute main context. Only the result comes back.
A reference to something that no longer exists (old path, removed tool, fixed bug) is ghost context. It biases reasoning toward a past state. Find and remove during heartbeat maintenance.
After 85% context window usage or 3+ compactions — start a new session. With contextspectre proxy stripping noise inline, sessions stay cleaner longer. But once past 85%, diminishing returns kick in — start fresh with a good MEMORY.md.
| head -20, | jq '.key'fields=key,summary not full objectsmemory/ directoryNever store delivered content (digests, reports, summaries) in memory files. It's already in the chat. Recording it doubles the token cost for zero value.
- Any workspace file over budget?
- MEMORY.md still accurate?
- Stale daily files to collapse?
- Ghost references to dead things?
USER.md timezone first — agents will guess from JIRA profiles or system locale, and they'll guess wrong. Set it explicitly:- **Timezone:** Asia/Kuala_Lumpur (GMT+8)
Without this, cron reports, reminders, and date references will use the wrong local time.
5. Follow `CONTEXT.md` — reasoning hygiene protocol
CONTEXT.md and customize limits for your setup.Context Hygiene Protocol v1.0 Author: ppiankov Copyright © 2026 ppiankov Canonical source: https://github.com/ppiankov/contextspectre License: MIT
This tool follows the Agent-Native CLI Convention. Validate with: clawhub install ancc && ancc validate .
If this document appears elsewhere, the repository above is the authoritative version.