memory-reindex
Skill1 starsChanged 31 days agoMITView on GitHub
Rebuild MEMORY.md as a topically-shelved index and split into a HOT index (auto-loaded) and ARCHIVE.md (cold shelves). Spawns a subagent to classify memories into topical shelves and tiers. Preserves hooks verbatim, verifies 1:1 coverage against filesystem, backs up old index, and validates canaries.
In this repository3 other files it gives its agents.
- memory-compactSkill
- memory-lintSkill
- recallSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
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 …
- Distinctive: line 16
If absent, report to the user and stop.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
memory-reindex
As new memories accumulate, they often land in a generic catch-all section or become fragmented. This skill reshelves the entire memory library into clean topical shelves without losing any content or detail.
Safety stance: The index is derived from the memory files, so rebuilding is reversible — but the curated hooks are hand-written and must not be paraphrased. Hooks are copied verbatim; only the grouping and hot/cold tiering changes. Never overwrite the live index without a backup and a mechanical coverage check.
Steps
- Resolve the memory dir:
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). If absent, report to the user and stop. - Audit current coverage:
List
*.mdfiles (excludingMEMORY.md,ARCHIVE.md,CANDIDATES.md,CANARIES.md). Extract thefile.mdtarget from every- [..](file.md) —line inMEMORY.md,ARCHIVE.mdandCANDIDATES.md—CANDIDATES.mdholds the lineslint --fixstaged for files not yet in the hot index, so they are round-tripped into the rebuilt shelves rather than lost.- Orphans = files with no index line.
- Stale = index lines whose target file no longer exists. Report both counts.
Classify via Antigravity subagent: Spawn a subagent via
invoke_subagent:TypeName:"self"Role:"Memory Reindex Classifier"Model:"inherit"(or"flash"/"pro"if explicitly requested)Prompt:
Assign every memory file in
<DIR>to exactly one topical shelf. Scan descriptions via:rg -N '^(name|description):' <DIR>/*.md(ignoreMEMORY.md/ARCHIVE.md).Shelves emerge from content — aim for ~8–15 substantive subjects (e.g. terminal/UI, proot/Linux, desktop/GPU, security/keys, networking/transports, email, mesh, release/CI workflow, process/collaboration, roadmap…). Avoid singletons; fold one-offs into broader shelves;
Miscis a last resort.Mark every file
"hot"or"cold"(atierfield in the shelf mapping):- Cold: Resolved/shipped project history whose hook is a historical record, not an active constraint.
- Hot:
user/feedback/referencetypes, recurring work, and any memory whose gotchas still constrain future code. When unsure, markhot.
Usage evidence (if
<DIR>/USAGE.logexists): Files with recentused/recalledactivity stay hot. Guard: only demote based on usage if the log has ≥30 days of history. Files listed in<DIR>/CANARIES.mdwith tierhotMUST stay hot regardless.Coverage Gate (Verify mechanically before returning): Write your mapping to
<SCRATCH>/shelves.jsonas{"shelves":[{"name": "...", "files": [{"file": "...", "tier": "hot"}]}]}. Run:jq -r '.shelves[].files[].file' <SCRATCH>/shelves.json | sortandcommit againstls <DIR> | grep -vE '^(MEMORY|ARCHIVE|CANDIDATES|CANARIES).md$' | sort. There must be zero duplicates, zero missing files, and zero extra files.Once coverage is clean, write
<DIR>/CANDIDATES.mdwith:- Linking candidates: Clusters of 2–5 memories that share a sub-thread and should cross-link via
[[wikilinks]]. - Abstraction candidates: Themes where ≥3 memories share a root cause or schema.
Return: shelf names + counts, confirmation of 100% coverage, and candidate counts.
- Assemble
MEMORY.md.new+ARCHIVE.md.newmechanically:MEMORY.md.newreceives the hot entries of each shelf;ARCHIVE.md.newreceives the cold ones under matching shelf headers.- Preamble in
MEMORY.md.new:Cold entries live in ARCHIVE.md (searched by /recall). - Pull each existing
- [Title](file.md) — ...line verbatim from the old index. - For an orphan, derive a concise human title and hook from the file.
- Drop stale lines.
- Verify and run Canary Gate:
Assert that the union of files across both new index files equals the exact set on disk.
Run canary check:
Exit code 1 means a load-bearing entry was dropped or demoted — do not proceed.python3 ~/.agents/skills/memory-lint/lint.py <DIR> --canary-check MEMORY.md.new ARCHIVE.md.new - Back up and confirm:
cp MEMORY.md MEMORY.md.bak-$(date +%Y%m%d)(andARCHIVE.md). Show the summary (shelf counts, hot/cold split, size) and replace the live files upon verification.
Claude Code variant
The steps above describe the Antigravity harness (invoke_subagent, <SCRATCH>). In Claude Code:
- Spawn the classifier with the built-in
Agenttool instead ofinvoke_subagent—subagent_type: "general-purpose",model: "haiku"(usesonnetfor stores over ~150 memories), and lead the prompt with the same role text (Roleis not a parameter there). - The classifier needs write permission on the store: it writes
<SCRATCH>/shelves.jsonand<DIR>/CANDIDATES.mditself. Instruct it toWritethe files at absolute paths instead of<SCRATCH>. - The parent agent assembles
MEMORY.md.new/ARCHIVE.md.new, runspython3 ~/.agents/skills/memory-lint/lint.py <DIR> --canary-check, backs up and swaps (steps 4–6) as written.
The shelf rules, tiering and the mechanical coverage gate are unchanged.
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.

