/obsidian-brain:memory-consolidatefrom obsidian-brain
Moves durable facts out of a project's Claude Code memory store into the Obsidian vault, one note per fact, so MEMORY.md shrinks or loses its orphans without losing anything. Dry run first; originals go to a backup dir, never deleted. Use when: (1) /memory-consolidate to shrink a MEMORY.md near its size limit, (2) /memory-consolidate to rescue orphaned memory files the index no longer reaches, (3) vault-doctor's memory-index check reports drift or an oversized index.
Ships in obsidian-brain. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
MEMORY.md is the only part of a project's memory that loads every session, and it has a
read budget (about 24,000 bytes; compaction is asked for near 17,000) and a 200-line limit.
This skill moves facts that do not need to be in context every session into the vault, where
/vault-ask and /vault-search find them.
Two modes, same steps:
Claude makes the judgement calls (keep or move, note type, dedupe). The CLI
hooks/memory_consolidate.py does the mechanics (audit, apply, verify, smoke).
Tools needed: Bash, Read, Write
--apply.apply --apply copies the whole store to a backup dir first (built
under a temporary name, renamed only when complete), writes the notes from that copy, then moves
each original to <backup>/moved/<slug>.md. One lock per store keeps two runs apart.migrated_from_memory: <slug> and no source_session (retro would count them as the moving
session's findings, #495).Run this as a command of its own and keep the printed hooks directory; the steps below call it
<HOOKS>. Paste it literally, in single quotes.
If it prints the bare word hooks, the plugin install was not found: stop and tell the user to
check the obsidian-brain install.
python3 -c "
import glob, json, os, re
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser('~/.claude/plugins/known_marketplaces.json'))).values():
_s = _m.get('source') if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get('source') == 'directory'):
continue
_i = _m.get('installLocation') if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, 'hooks')
if os.path.isfile(os.path.join(_h, 'obsidian_utils.py')):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser('~/.claude/plugins/cache/*/obsidian-brain/*/hooks')) if re.fullmatch('[0-9]+([.][0-9]+)*', _d.split('/')[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split('/')[-2].split('.')], _p), default='hooks')
print(_ob_hooks())
"
python3 '<HOOKS>/memory_consolidate.py' audit
The first line is store: <path>: the store this run works on (the main worktree's store, even
from a worktree). Keep it as <STORE>. If the user names another project, add
--store '<that store path>' here and keep that path as <STORE>. Steps 5 to 7 pass the same
--store '<STORE>': without it apply picks the store of the current directory and refuses
another project's plan as a store mismatch. Exit 2 means the store could not be chosen; show
the error and stop.
Report to the user: index size in bytes, characters and lines (say which unit), the limits,
the mode (shrink, rescue or ok), and any orphans, dangling links or duplicates. Mode ok
with no drift: say there is nothing to do and stop unless the user asks to go on.
Read each candidate entry in <STORE> (Read tool). Apply this test:
/vault-ask: deploy and live-service rules, approval limits, hook and
preflight mechanics, daily tool gotchas.CLAUDE.md
already says.When the user asks for a number of entries or for older ones, use audit --json (each entry has
mtime and body_chars) to pick, oldest first, among those that pass the move test; if fewer
pass, move only those and say so.
Pick a note type per moved entry: claude-insight (a reusable rule; the default),
claude-error-fix (a diagnosed failure and its fix) or claude-decision (a chosen option with
its rationale).
Index lines that point at several entries. When one MEMORY.md line links more than one
entry, plan those entries as a group: all move, or none. apply refuses to move one entry off a
line that still points at entries that stay, and the dry run says so.
For each entry you plan to move, search the vault (/vault-search <key phrase>, or
/vault-ask for a fuzzy match). A hit counts only when the matching note is about that
lesson, not a retro or session note that mentions it in passing. On a real hit, plan the entry
as append to that note instead of new. Check _provisional/ hits too: an earlier capture of
the same lesson often sits there.
Write the plan JSON with the Write tool to a file in your scratchpad (never /tmp/ob-*):
{
"version": 1,
"store": "<STORE>",
"items": [
{"slug": "feedback_x", "action": "new", "type": "claude-insight", "topic": "testing"},
{"slug": "feedback_y", "action": "append", "target": "claude-insights/2026-11-03-foo-0d18.md"},
{"slug": "project_z", "action": "retire", "reason": "PR merged; git holds it"}
]
}
slug is the file name without .md. topic is optional kebab-case.target is the vault-relative path of the note to append to.reason is required for retire.Keep the path as <PLAN>.
python3 '<HOOKS>/memory_consolidate.py' apply --plan '<PLAN>' --store '<STORE>'
It prints NEW, APPEND, RETIRE, REFUSE and WARN lines and every index line it would
drop, and writes nothing. Exit 2 means the plan is bad: fix it and rerun.
Show the user the full list, every RETIRE and REFUSE line in particular, and ask before going
on. If the user drops or changes items, edit the plan and rerun this dry run before Step 6.
A REFUSE for a secret-shaped string means the entry stays in memory; tell the user which.
python3 '<HOOKS>/memory_consolidate.py' apply --plan '<PLAN>' --store '<STORE>' --apply
Keep the backup: line's path as <BACKUP>. Exit 1 means some items were refused and the rest
were done. Exit 2 means the run could not go on:
another run holds the lock: another apply or --resume is running on this store. Wait for
it. A lock left by a dead process is taken over (WARN stale lock from pid N).cannot tell which project ... belongs to; pass --project: add --project '<name>'. The
default is the project of <STORE>, never the current directory's.MEMORY.md kept changing. Once the backup dir exists the
error is followed by a finish with: apply --resume <BACKUP> line. Run
apply --resume '<BACKUP>' (--resume takes no --store): it runs the same steps again
(notes, moves, index) from the backup's copy, and is safe to repeat. On a finished run it
prints nothing to do.A WARN leftover partial backup <path> line means an earlier run stopped while copying the store.
It wrote no note and moved nothing; the partial dir can be deleted.
python3 '<HOOKS>/memory_consolidate.py' verify --backup '<BACKUP>' --store '<STORE>'
It prints one line per check: index-links-resolve, no-duplicates, all-indexed,
removed-equals-moved, notes-lossless, backups-present, sizes, then verify: ok.
Every line must be PASS; a missing line counts as a failure. A run that is not finished prints
one state line instead, as FAIL: resume it (Step 6), then verify again.
Any FAIL (exit 1): report it to the user with its detail line. The originals are all in
<BACKUP>/moved/ and <BACKUP>/full-copy/, so nothing is lost.
Pick a distinctive phrase from one moved fact and the vault-relative path of the note it went to:
python3 '<HOOKS>/memory_consolidate.py' smoke --query '<phrase>' --expect '<note path>'
This runs the default (non-wiping) reindex, then searches. Exit 0 means the moved note was found.
Exit 1 means the move is not retrievable yet: either the search had no hits (smoke: 0 hit(s))
or a MISSING <note path> line names a note --expect did not find. Report it, do not claim
success. Exit 2 means the smoke run itself failed (error: line, for example a vault that is not
a directory): stop and report the error, do not claim success.
Tell the user, in a short table: entries moved, appended, retired and refused; index size before
and after in bytes, characters and lines (from verify's sizes line); and the backup path. Name
any WARN lines (for example, an aside left on a kept index line).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub abhattacherjee/obsidian-brain --plugin obsidian-brain21 skills in this plugin
/check-itemsTriage open `- [ ]` items across your Obsidian vault with evidence-grounded AI classification. Auto-closes items shipped by merged PRs, surfaces items needing external action (e.g. `gh issue close`), hides stale items by default. Replaces the old token-overlap heuristic with a two-pass AI pipeline backed by a persistence cache. Use when: (1) sweeping a project for done work, (2) auditing what's still actionable, (3) recovering from /recall deferral fatigue./compressInteractively saves curated insights from the current Claude Code session to the Obsidian vault. Use when: (1) /compress command to save session insights, (2) /compress <topic> to extract a specific topic, (3) user wants to capture decisions, patterns, solutions, or error fixes from the current session./