agentleFS
GlassOnTinGlassOnTin/claude-memory-skills/skills/memory-compact/SKILL.md

memory-compact

Skill1 starsChanged 29 days agoMITView on GitHub

Shrink over-length hooks in the MEMORY.md index while verifying fact recoverability from the underlying memory bodies. Parallelizes across subagents, validates canaries, and creates timestamped backups. Run when the index is over the target size threshold.

5 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. anthony-chaudhary/fak★ 47same name
    2. whinc/super-skills★ 40same name
    3. dewil/ai-toolkit★ 9same name
    4. dewil/claude-toolkit★ 9same name
    5. SuShuheng/openclaw-memory-compact★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run python3 ~/.agents/skills/memory-lint/lint.py --print-dir (checks .agents/memory/, ~/.gemini/config/projects/<slug>/memory/, and …

    line 15
  2. Very specific:

    Verify that all (file.md) targets match the live MEMORY.md 1:1.

    line 37
  3. Distinctive:

    If any canary fails or prefixes mismatch, abort and report.

    line 42

“Common” is measured: kept by at least 6 in 10 of the 3 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-compact

reindex reorganizes the index losslessly without modifying hook text. When individual hooks bloat past ~250 chars, memory-compact tightens the pointers.

The Golden Rule: Shrink the pointer, never the fact. A hook is shortened only when its detail is already recoverable from the memory file's body. Anything a hook carries that the body does not (a specific commit SHA, a ★still-open note, an untested flag) would be lost by shortening — so those hooks are kept verbatim and flagged, never trimmed.

Steps

  1. Resolve memory directory: Run python3 ~/.agents/skills/memory-lint/lint.py --print-dir (checks .agents/memory/, ~/.gemini/config/projects/<slug>/memory/, and ~/.claude/projects/<slug>/memory/, walking up parent directories to $HOME).
  2. Find over-length hooks: Identify index lines longer than 250 characters. Report the count and current size.
  3. Parallel rewrite via Antigravity subagents: For >20 over-length hooks, partition into batches of ~15–20 files and launch parallel subagents in a single invoke_subagent call:

    • TypeName: "self"
    • Role: "Memory Compaction Worker [Batch N]"
    • Model: "inherit" (or "flash" if explicitly requested)
    • Prompt:

    For each filename in your batch: locate its line in MEMORY.md (grep -F '(FILE)'), read the memory's body in <DIR>/<FILE>, and generate a compacted hook (text after —):

    • Target length: ≤180 characters (≤300 chars for giant hooks >1000 chars).
    • Derived directly from the body.
    • Safety check: If the original hook contains specific facts (SHAs, gotcha notes, versions) NOT present in the body, set the value to "KEEP".
    • Write {FILE: hooktext | "KEEP"} JSON to <SCRATCH>/compact_batch_N.json.
    • Do not edit any memory files.
  4. Assemble and verify: Merge batch JSON results. Build MEMORY.md.compact by splicing the new hook text onto the original [Title](file.md) — prefixes. Verify that all (file.md) targets match the live MEMORY.md 1:1. Run canary validation:
    python3 ~/.agents/skills/memory-lint/lint.py <DIR> --canary-check MEMORY.md.compact
    If any canary fails or prefixes mismatch, abort and report.
  5. Backup and confirm: cp MEMORY.md MEMORY.md.bak-$(date +%Y%m%d). Display before/after size, count of compacted hooks, and sample diffs. Replace live file upon confirmation.

Claude Code variant

The steps above describe the Antigravity harness (invoke_subagent, <SCRATCH>). In Claude Code:

  • Workers: the built-in Agent tool instead of invoke_subagent — subagent_type: "general-purpose", model: "haiku", launched as several parallel Agent calls in one message (one per batch of ~15–20 files). Lead each prompt with the role text (Role is not a parameter there).
  • Each worker Writes the same {FILE: hooktext | "KEEP"} JSON to an absolute scratch path outside the memory store (e.g. /tmp/compact-batch-N.json) instead of <SCRATCH>/compact_batch_N.json.
  • The parent agent does the splicing, 1:1 verification, backup and replace (steps 4–5) itself using python3 ~/.agents/skills/memory-lint/lint.py <DIR> --canary-check MEMORY.md.compact.

The Golden Rule, worker prompt and safety checks are harness-agnostic.

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.