# Wiki Retrieve

Build and query a vault-local contextual BM25 retrieval index with optional...

- Repository: https://github.com/AgriciDaniel/claude-obsidian (16054 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-10-25
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve -g -a claude-code -y`
Codex: `npx skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve -g -a codex -y`
Cursor: `npx skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve -g -a cursor -y`
Gemini CLI: `npx skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add AgriciDaniel/claude-obsidian`

## Description

Build and query a vault-local contextual BM25 retrieval index with optional multilingual Nomic cosine reranking; use for retrieve, hybrid retrieval, BM25, rerank, contextual retrieval, chunk search, vault search, semantic search, find relevant passages, or retrieval diagnostics. Derived caches stay under .vault-meta, remote egress requires explicit consent, and unavailable reranking falls back deterministically.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Retrieve relevant passages

This extension derives search data from `wiki/` into `.vault-meta/`. It never
changes canonical notes. Always pass the selected vault explicitly.

Resolve the installed product root from this skill's own location, not from the
vault or current working directory:

```bash
PRODUCT_ROOT=/absolute/path/to/installed/claude-obsidian
PREFIX="$PRODUCT_ROOT/scripts/contextual-prefix.py"
BM25="$PRODUCT_ROOT/scripts/bm25-index.py"
RETRIEVE="$PRODUCT_ROOT/scripts/retrieve.py"
RERANK="$PRODUCT_ROOT/scripts/rerank.py"
test -f "$PREFIX" && test -f "$BM25" && test -f "$RETRIEVE" && test -f "$RERANK"
```

## Pipeline

1. `contextual-prefix.py` splits pages on paragraph boundaries and stores the
   raw chunk plus a short page-level prefix.
2. `bm25-index.py` builds a local, standard-library BM25 index over the
   contextualized text.
3. `retrieve.py` selects BM25 candidates, optionally reranks them, rejects
   invalid records, deduplicates by page, and returns paths and snippets.
4. The caller reads the returned pages and performs synthesis; retrieval output
   is not itself evidence.

## Provision locally

Preview first, then build synthetic prefixes without network egress:

```bash
python3 "$PREFIX" --vault "$VAULT" --all --no-llm --peek
python3 "$PREFIX" --vault "$VAULT" --all --no-llm
python3 "$BM25" --vault "$VAULT" build
python3 "$RETRIEVE" --vault "$VAULT" "wiki" --top 1 --no-rerank --explain
```

Chunk and index files are disposable runtime state. Incremental prefixing skips
records whose chunk hashes, page hashes and provider/model profile still match.
Legacy records without that profile regenerate on an explicit build. A complete scan removes
surplus records for deleted pages, and the prefixer invalidates the BM25 index
before changing its chunk set so a mixed stale index is not served.
Prefix and BM25 build operations share the vault-wide mutation lock with every
other writer; a busy vault fails closed instead of publishing a partial index.

The rest: https://github.com/AgriciDaniel/claude-obsidian/blob/HEAD/skills/wiki-retrieve/SKILL.md
