Skip to content

/wiki-retrieve

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.

From plugin
claude-obsidian
16k15 skills3 agents2 hooks

Claude Code

$ npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent claude-code

SKILL.md

wiki-retrieve.SKILL.md
name: wiki-retrieve
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."

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:

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:

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.

Contextual-prefix privacy

Synthetic prefixes use only local frontmatter and page text. The explicit Anthropic API profile can send page bodies off-machine and requires the user's consent plus `--allow-egress` and a configured API key. There is no Claude CLI generation tier or ambient subprocess fallback. Never infer consent from an API key or installed binary. Preview the scope first and state which provider will receive what data.

Remote Ollama endpoints also require explicit approval and `--allow-remote-ollama`; the default reranker accepts localhost only.

Local model prefixes are a separate explicit option. Use an already installed exact `name:tag`; no server is started and no model is installed or pulled:

python3 "$PREFIX" --vault "$VAULT" --all --local-ollama --ollama-model installed:tag --peek
python3 "$PREFIX" --vault "$VAULT" --all --local-ollama --ollama-model installed:tag

The prefix adapter verifies cloud-disabled server status and local model identity before sending page text. Unsupported or unavailable preflight falls back to synthetic prefixes for new or changed chunks only; prefixes from the same endpoint and model stay in place, so a transient outage leaves an unchanged vault's chunks and BM25 index untouched. This requirement can exclude older Ollama servers. Reranking and tiling use the same local-only proof before query, page, chunk, or embedding cache work. `--allow-remote-ollama` approves the endpoint, not cloud delegation by the server. See [prefix providers](../../docs/prefix-providers.md) for the exact policy, cloud model selection and verification limits. The reranker has its own model and endpoint policy; selecting local prefixes does not enable reranking.

Query

For a strictly read-only lookup, use the prebuilt BM25 index:

python3 "$RETRIEVE" --vault "$VAULT" "$QUERY" --top 5 --no-rerank --explain

For an explicitly requested rerank, omit `--no-rerank`. The default is Ollama's multilingual `nomic-embed-text-v2-moe` model (approximately 958 MB); the product never pulls it automatically. To use an already-installed, smaller, English-oriented v1.5 model, pass `--model nomic-embed-text` explicitly. Nomic models use `search_query:` for the query and `search_document:` for candidate text. Nomic v2 has a 512-token input context and Ollama truncates longer embedding inputs by default; BM25 still scores the complete chunk. Embeddings are cached by exact model, verified digest, input scheme, and hash of the exact prefixed input. A missing local Ollama service, malformed HTTP reply, missing selected model, unusable vector, or any candidate embedding failure falls back for the complete result set to the original BM25 order; it never mixes cosine and BM25 score scales.

Query input is bounded at 8,000 normalized characters and result counts must be between 1 and 1,000. Oversized queries and invalid limits fail with an actionable usage error instead of looking like an empty successful search. An untagged model request matches only the installed untagged name or its `:latest` alias; select any other tag explicitly.

Use direct diagnostics when needed:

python3 "$BM25" --vault "$VAULT" stats
python3 "$BM25" --vault "$VAULT" query "$QUERY" --top 10
python3 "$RERANK" --vault "$VAULT" "$QUERY" --peek
python3 "$RERANK" --vault "$VAULT" "$QUERY" --model nomic-embed-text --peek

Integrity rules

  • Accept only relative chunk and page paths whose resolved targets remain under

`$VAULT/.vault-meta/chunks/` and `$VAULT/wiki

Read more
@agricidaniel
Ships withclaude-obsidian

Self-organizing AI second brain for Obsidian + Claude Code. Drop any source and Claude reads, links, and files it into one connected knowledge graph of plain Markdown you own. AI note-taking, personal knowledge management (PKM), and an open-source Notion alternative. Based on Karpathy's LLM Wiki pattern.

Stars on GitHub

Momentum

stars in total
16.3k
Star history of AgriciDaniel/claude-obsidian on GitHub, a chart by star-history.com

Other skills on claude-obsidian.

autoresearch
Auto-invoked

autoresearch

Run a bounded, source-grounded research loop, draft a cited dossier, and optionally propose a separately reviewed canonical vault…

canvas
Auto-invoked

canvas

Create, inspect, and update Obsidian JSON Canvas boards with text, file, link, group, and edge nodes. Use for canvas status,…

defuddle
Auto-invoked

defuddle

Plan optional Defuddle extraction and retain already available local source files through reviewed filesystem capture. Use for…

obsidian-bases
Auto-invoked

obsidian-bases

Explain, draft, and validate Obsidian Bases .base files with filters, formulas, properties, summaries, and table, card, list, or…

save
Auto-invoked

save

Save a user-selected answer, decision, insight, or session summary into an Obsidian vault as one reviewed transaction. Use only…

More skills from other plugins.

i-have-adhd

i-have-adhd

Shape output for a reader with ADHD: lead with the next action, number multi-step work, restate state across turns, suppress…

@ayghri@ayghriInstall Skill
ab-test-analysis

ab-test-analysis

Analyze A/B test results with statistical significance, sample size validation, confidence intervals, and ship/extend/stop…

@phuryn@phurynInstall Skill
distilly

distilly

Set up the owner profile so a personal agent knows who it works for (first-run setup, \"get to know me\"), or distill colleague,…

Questions about wiki-retrieve.

Which coding agents can use wiki-retrieve?
wiki-retrieve installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.