Memory Hygiene — Security skill for Claude Code
Audit and clean up Claude Code's persistent memory system — MEMORY.md, memory files, lessons, and ADRs.
How to install Memory Hygiene
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open wan-huiyan/memory-hygiene and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Memory Hygiene does
Audit and clean up Claude Code's persistent memory system — MEMORY.md, memory files, lessons, and ADRs.
Alternatives in Security
- Octoboss Clean Contexts — You are the Octoboss — a cross-tentacle orchestrator 1.4k ★
- Imcodes — The IM for agents 960 ★
- OpenTag — Open-source, channel-native agent gateway for Slack 499 ★
README
memory-hygiene
[](https://github.com/wan-huiyan/memory-hygiene/releases) [](https://claude.com/claude-code) [](LICENSE) [](https://github.com/wan-huiyan/memory-hygiene/commits)
Audit and optimize Claude Code's persistent memory system — axioms, phase templates, MEMORY.md, lessons, memory files, and ADRs — using a research-backed tiered architecture with promotion/demotion lifecycle and agency-aware staleness detection. **v3.4** fixes the cross-plugin lookup of `session-handoff`'s `label_audit.py`, which silently found nothing on a plugin install. **v3.3** added a label-table integrity audit and a peer workflow for auditing a project's `docs/` directory against a canonical 7-bucket taxonomy.
The Problem
Claude Code's memory system has two failure modes that compound over time:
- Truncation: MEMORY.md exceeding ~200 lines is silently truncated — context lost without warning.
- Lost in the Middle: Even within the context window, LLMs show >30% accuracy degradation for information in the middle of long contexts (Liu et al. 2023). A critical lesson at line 617 of a 1400-line file is effectively invisible.
This means **bulk-loading large files into context is counterproductive** — it wastes tokens AND buries the important rules. The solution is a tiered architecture:
T0: Axioms (≤12 items, always loaded) — Universal + Role behavioral overrides
T0: CLAUDE.md (~70 lines, always loaded) — workflow rules, retrieval strategy
T1: MEMORY.md (~40-80 lines, always loaded) — index pointers
T1.5: .claude/rules/ (auto on file match) — phase-specific rules with paths: globs
T2: Topic files (~50
Related Skills
Knowledgehub
🧠 Enterprise AI-Enhanced Development Platform with GraphRAG, LlamaIndex, Multi-Tenant Architecture, and Advan
AI OS Self
MaiKS is a microkernel-inspired governance layer that runs inside your project workspace. It adds rules, a pre
Claude Clean Context
Keep Claude Code's always-loaded context lean: deterministic memory guard-rail distiller + skills audit. Never
Cleanup Docs
Audit and clean up a repo's Claude documentation — measure the always-on tier first (CLAUDE.md + nested + .cla
Coherence Audit
Read-only audit of semantic drift between ADRs/backlog and the code they describe
The Openclaw Optimizer
AI skill for optimizing and troubleshooting OpenClaw workspaces. 29 providers, tiered model routing, 36-check
Related Agents
Taa Brain
Use this agent for TAA Brain operations - recalling institutional memory before pipeline stages (patterns, pas
Project Steward
WRITE-access sole owner of documentation, the knowledge base, ADRs, the lessons log, and release process. The
Distiller
Turns a raw work session (sessions/archive/ notes, .jsonl transcripts) into clean notes and lessons in the tru