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
- anthony-chaudhary/faktheir own version, first seen Nov 3, 2026
- whinc/super-skillstheir own version, first seen Oct 18, 2026
- dewil/ai-toolkittheir own version, first seen Aug 25, 2026
- dewil/claude-toolkittheir own version, first seen Aug 25, 2026
- SuShuheng/openclaw-memory-compacttheir own version, first seen Mar 12, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- anthony-chaudhary/fak★ 47same name
- whinc/super-skills★ 40same name
- dewil/ai-toolkit★ 9same name
- dewil/claude-toolkit★ 9same name
- 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.
- memory-lintSkill
- memory-reindexSkill
- recallSkill
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
- Very specific: line 15
Run python3 ~/.agents/skills/memory-lint/lint.py --print-dir (checks .agents/memory/, ~/.gemini/config/projects/<slug>/memory/, and …
- Very specific: line 37
Verify that all (file.md) targets match the live MEMORY.md 1:1.
- Distinctive: line 42
If any canary fails or prefixes mismatch, abort and report.
“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.
Files
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
- 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). - Find over-length hooks: Identify index lines longer than 250 characters. Report the count and current size.
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_subagentcall: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.
- Assemble and verify:
Merge batch JSON results.
Build
MEMORY.md.compactby splicing the new hook text onto the original[Title](file.md) —prefixes. Verify that all(file.md)targets match the liveMEMORY.md1:1. Run canary validation:
If any canary fails or prefixes mismatch, abort and report.python3 ~/.agents/skills/memory-lint/lint.py <DIR> --canary-check MEMORY.md.compact - 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
Agenttool instead ofinvoke_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 (Roleis 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.
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
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.

