/obsidian-brain:vault-reindexfrom obsidian-brain
Rebuild the SQLite FTS5 vault index. Non-destructive by default — preserves Friston activation data (access_log, themes, theme_members); only regenerates derivable tables. Opt into `--full` for a complete wipe.
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.
Regenerates the notes and notes_fts tables from on-disk state. Use when the index is stale, corrupt, after bulk edits in Obsidian, or to purge leftover rows from pytest fixtures.
Tools needed: Bash
/vault-reindex) — non-destructive. Reconciles the note index with current vault contents via an mtime-incremental sync: newly added notes get indexed, notes deleted from disk are removed, rows with paths outside the current scanned folders (pytest pollution, stale mounts) are cleaned up. Preserves access_log (ACT-R activation history), themes, and theme_members (cluster centroids + surprise scores). Orphaned rows whose note paths are no longer in scope are pruned. Does not re-tokenise unchanged notes or rebuild FTS/term_df for them — if an existing row is internally corrupted but its on-disk mtime hasn't changed, only --full will fix it./vault-reindex --full — destructive. Deletes the entire ~/.claude/obsidian-brain-vault.db file and rebuilds from an empty schema. Every Friston field is lost. Required when the schema is corrupt/incompatible or when derivable tables need a clean-slate rebuild.Follow these steps exactly. Do not skip steps or reorder them.
If the user passes --full, set FULL_MODE=true; otherwise FULL_MODE=false.
Run:
python3 -c '
import sys, os, glob
import glob, json, os, re, sys
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")
sys.path.insert(0, _ob_hooks())
from obsidian_utils import load_config
c = load_config()
if not c.get("vault_path"):
print("ERROR: vault_path not configured", file=sys.stderr)
sys.exit(1)
print("VAULT=" + c["vault_path"])
'
Parse each output line as KEY=VALUE, splitting on the first =.
If config is missing or the command fails, tell the user:
Config not found. Run
/obsidian-setupfirst to configure your vault path.
Stop here if config is missing.
--full)If FULL_MODE=true, warn the user before proceeding:
⚠️ Full rebuild requested. This will delete
access_log,themes, andtheme_members(activation history, cluster centroids, surprise scores). These tables do not regenerate automatically — activation signal accumulates over time as you run/recall,/vault-search, and/vault-ask. Themes will be empty until/consolidateships.Continue? Reply
yesto confirm, anything else to cancel.
Wait for confirmation. Abort if the user does not reply yes. If cancelled, tell them they can run the default /vault-reindex (without --full) for a non-destructive rebuild.
Run, passing VAULT_PATH and FULL_MODE as command-line arguments. The folders come from a fresh read of the config, not the session cache. The snippet refuses (exit 1) when that read's vault_path does not match VAULT_PATH (an unreadable config falls back to defaults) or when wiki_folder is invalid:
python3 -c '
import sys, os, glob, time, json
import glob, json, os, re, sys
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")
sys.path.insert(0, _ob_hooks())
from obsidian_utils import load_config, indexed_folders
from vault_index import rebuild_index
t0 = time.time()
full = sys.argv[2].lower() == "true"
try:
cfg = load_config(fresh=True)
# An unreadable config falls back to defaults (vault_path ""); its
# default folders would make the rebuild prune every custom folder.
if cfg.get("vault_path") != sys.argv[1]:
raise ValueError("config vault_path %r does not match %r (config unreadable or changed)" % (cfg.get("vault_path"), sys.argv[1]))
folders = indexed_folders(cfg, strict=True)
except ValueError as exc:
# A rebuild prunes rows outside the scanned folders; refuse rather than
# silently drop the wiki folder and its rows (#393).
print(f"ERROR: {exc}. Fix it with /vault-config, then re-run.", file=sys.stderr)
sys.exit(1)
stats = rebuild_index(sys.argv[1], folders, full=full)
stats["folders"] = [{"name": f, "exists": os.path.isdir(os.path.join(sys.argv[1], f))} for f in folders]
stats["elapsed"] = round(time.time() - t0, 1)
# Derive mode from the returned stats, not the CLI flag — rebuild_index()
# can fall through to a full rebuild internally (missing DB, legacy schema)
# even when the caller asked for preserve mode. Presence of "preserved"
# in the stats dict is the single source of truth.
stats["mode"] = "preserve" if "preserved" in stats else "full"
print(json.dumps(stats))
' "$VAULT_PATH" "$FULL_MODE"
If the command fails (non-zero exit or exception in output), tell the user:
Index rebuild failed. Check that the vault path is accessible and that the plugin is installed. Error:
<stderr>
Stop here on failure.
Parse the JSON output from Step 3. Extract:
inserted — total notes indexedskipped — sum of unchanged + malformed (kept for backward compatibility; do not report this alone — it conflates a healthy outcome with a real one)unchanged — notes whose mtime matched the index; nothing to do, the healthy common casemalformed — notes whose frontmatter failed to parse (true total, not capped): dropped from the index if never indexed before, or, if already indexed, left at its last-good indexed contentmalformed_files — list of {"file": <sanitized basename>, "reason": <classifier>}, capped (currently 20 entries) even when malformed is largerforeign_deleted — rows dropped because their path is outside every scanned folder (non-destructive mode only)folders — list of {"name", "exists"} for each folder scannedexcluded — notes skipped on purpose because their type is never indexed (the wiki's own index.md and log-*.md files, typed claude-wiki-index, #383); not a problemelapsed — time in secondsby_type — dict mapping note type to countmode — "preserve" or "full"preserved — dict with access_log, themes, theme_members counts (non-destructive mode only)pruned_orphans — dict with access_log, theme_members pruned counts (non-destructive mode only)access_log_gc — access rows dropped because a note had more than 1,000 (the newest 1,000 per note are kept, #448); always 0 in full modePresent this report:
Rebuilt vault index (
<mode>mode):<inserted>notes indexed in<elapsed>s
Type Count claude-session <count>claude-insight <count>... ... Unchanged:
<unchanged>file(s) already indexed (nothing to do). Malformed:<malformed>file(s) with frontmatter that failed to parse.
Add a line naming the scanned folders from folders, marking each one whose exists is false as "(missing — nothing indexed)". A missing wiki_folder usually means a typo in the config or that /obsidian-setup has not been re-run. If excluded is greater than 0, add: "Skipped <excluded> wiki index/log file(s) (not knowledge, never indexed)." If foreign_deleted is greater than 0, add: "Dropped <foreign_deleted> row(s) for notes outside the scanned folders (a folder was renamed or removed from the config, or old test data)." If access_log_gc is greater than 0, add: "Trimmed <access_log_gc> old access row(s) (kept the newest 1,000 per note)."
Only include rows in the table for types that appear in by_type (omit zero-count types). Sort rows by count descending.
If malformed is greater than 0, list the named files so the user can act:
Malformed files:
<file>—<reason>- ...
List every entry in malformed_files. If malformed exceeds the length of malformed_files (the report is capped), append, using the actual number of entries you just listed rather than a hardcoded number:
Showing the first
<len(malformed_files)>of<malformed>malformed file(s); re-run after fixing these to surface the rest.
Additional section — non-destructive mode only:
Friston data preserved:
access_log:<access_log>activation event(s)themes:<themes>cluster(s)theme_members:<theme_members>assignment(s)Pruned
<pruned_access_log>orphaned access-log row(s) and<pruned_theme_members>orphaned theme-member row(s) referencing notes no longer in the current index scope (either deleted from disk or outside the scanned folders).
If both pruned counts are 0, replace the pruning line with No orphan rows to prune..
Additional section — full mode only:
⚠️ Friston data cleared:
access_log,themes, andtheme_membersare now empty. Activation signal will rebuild as you use the vault.
If inserted is 0 and skipped is 0, also tell the user:
No notes found. Verify that the folders listed in
folders(under<VAULT>) exist and contain markdown files.
What SKILL.md sets; muted values are Claude Code's defaults
21 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./Other plugins' skills for the same job
npx claudepluginhub abhattacherjee/obsidian-brain --plugin obsidian-brain