wan-huiyan

Memory Hygiene — Security skill for Claude Code

Security community

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

[![GitHub release](https://img.shields.io/github/v/release/wan-huiyan/memory-hygiene)](https://github.com/wan-huiyan/memory-hygiene/releases) [![Claude Code](https://img.shields.io/badge/Claude_Code-skill-orange)](https://claude.com/claude-code) [![license](https://img.shields.io/github/license/wan-huiyan/memory-hygiene)](LICENSE) [![last commit](https://img.shields.io/github/last-commit/wan-huiyan/memory-hygiene)](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:

  1. Truncation: MEMORY.md exceeding ~200 lines is silently truncated — context lost without warning.
  2. 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