agentleFS
Guz007Guz007/claude-code-os-plugin/skills/memory-hygiene/SKILL.md

memory-hygiene

Skill0 starsChanged 4 months agoMITView on GitHub

Audit, prune, and update persistent memory or instruction files (CLAUDE.md, AGENTS.md, memory/) via a destructive-first three-phase protocol with an approval gate. Use at end of session, on a weekly cadence, or when memory files have grown bloated, stale, or self-contradictory.

13 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never skip Phase 1. Never auto-write without Phase 3 approval.

    line 14
  2. Distinctive:

    Wait for explicit approval before writing anything to disk.

    line 78

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Memory Hygiene Protocol

Maintains LLM memory and instruction files. Prevents the primary failure mode: accumulation of dead weight that dilutes signal-to-noise until the model ignores the file entirely.

Phase 1: AUDIT (destructive) → Phase 2: CAPTURE (filter) → Phase 3: DIFF (approval gate)

Never skip Phase 1. Never auto-write without Phase 3 approval.

Phase 1 — Destructive Audit

Audit all memory files against four criteria. Do not modify files — report only.

  • STALENESS — entries referencing dates, versions, or states that may no longer be true.
  • REDUNDANCY — entries duplicating rules already in CLAUDE.md / AGENTS.md / system instructions.
  • CONTRADICTION — entries conflicting with each other or with the instruction file.
  • BLOAT — entries containing full content instead of pointers, or exceeding 5 lines for a single fact.

Format: [FILE] | [CRITERION] | [SPECIFIC TEXT] | [RECOMMENDATION]

Why destructive first: models default to additive behavior — they append whatever came up without pruning. Forcing a destructive pass combats accumulation. Remove before you add.

Phase 2 — Capture Candidates

Review the current session and extract memory-worthy signal. Filter before adding anything:

  • Would this change how you respond to future prompts in this project?
  • Is it non-obvious enough that it would be missed without being stated?
  • Is it durable (weeks, not hours)?
  • Is it specific (actionable by a model, not a vague preference)?

Discard: one-off debugging steps, exploratory dead-ends, context already inferrable from the codebase, anything better placed in a commit message or PR description.

Categorize as:

  • [NEW CONVENTION] — coding patterns, naming rules, architecture decisions
  • [NEW CONSTRAINT] — things to always/never do in this project
  • [NEW CONTEXT] — background knowledge that shapes how to interpret requests
  • [NEW WORKFLOW] — build, test, deploy, or review process changes

Format: [CATEGORY] | [PROPOSED ENTRY] | [RATIONALE] | [SUGGESTED SECTION]

"Non-obvious, durable, specific" are heuristics, not hard rules. Models over-classify — they label exploratory decisions as conventions. Apply judgment at the gate, don't rubber-stamp.

Phase 3 — Unified Diff with Approval Gate

Combine Phase 1 and Phase 2 into a single proposal. Never auto-write.

--- REMOVE ---
[verbatim text to remove, with section reference]
REASON: [one line]

--- ADD ---
SECTION: [target section name]
CONTENT:
[exact text to add, formatted to match existing style]
REASON: [one line]

--- REPLACE ---
ORIGINAL: [verbatim]
NEW: [replacement text]
REASON: [one line]

Then a one-paragraph summary:

Net change: X removals, Y additions, Z replacements. Memory file impact: [leaner / more specific / broader coverage / no net change]. Highest-risk edit: [which change most alters model behavior, and why].

Wait for explicit approval before writing anything to disk. Any prompt that auto-writes to a memory file without review is a liability — one misattributed session decision becomes a persistent behavioral constraint across all future work.

Cadence

ContextCadence
Single active projectEnd of session or daily
Multiple active codebasesWeekly per project file
Pre-ship / high-velocityAfter each major milestone
Stable / maintenanceMonthly

Single-Shot Version

For quick sessions where the full three phases are overkill:

Review this session. Any memory-worthy signal? Filter: non-obvious, durable (weeks+), specific, not inferrable from code. If zero candidates, say "nothing to save" and stop. If candidates exist, show diff format and wait for approval.

Known Gaps

  1. Filter heuristics are soft — the model will still hallucinate capture candidates. Judgment required at the gate.
  2. Assumes structured files — a flat wall of text with no sections breaks Phase 3's SUGGESTED SECTION. Run a structure pass first.
  3. No cross-project dedup — doesn't check whether a convention already exists in another project's memory.

See Also

  • memory-bootstrap — creates what this maintains
  • claude-md-bootstrap — instruction file template

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.