agentleFS
po4ykapo4yka/llm-wiki-skills/skills/llm-wiki-retrieval-architect/SKILL.md

llm-wiki-retrieval-architect

Skill3 starsChanged 5 months agoMITView on GitHub

Design the retrieval/indexing layer for an LLM-Wiki. Use for lexical/FTS search, BM25, hybrid retrieval, vector databases, rerankers, metadata filters, or GraphRAG, or when `rg`/index.md no longer retrieves enough context; route whole-stack local-first tooling choices to llm-wiki-local-first-stack.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    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
  1. Very specific:

    Use references/docs/16-retrieval-architecture.md as the reference playbook for detailed technology comparisons, metadata schema, GraphRAG …

    line 18
  2. Distinctive:

    Do not add infrastructure until a real retrieval failure is identified.

    line 58
  3. Distinctive:

    Default recommendation: hybrid retrieval + metadata filters + reranker.

    line 74
  4. Distinctive:

    Default governed query filter:

    line 144
  5. Distinctive:

    Prefer native structure over arbitrary windows:

    line 157
  6. Distinctive:

    Use contextual retrieval when chunks are semantically ambiguous without surrounding document context.

    line 168
  7. Distinctive:

    Use graph extraction only when the wiki already has stable page types, wikilinks, entities or citations.

    line 172
  8. Distinctive:

    Do not use graph visualization as proof of knowledge quality.

    line 186
  9. Distinctive:

    Do not make the vector index the source of truth.

    line 256
  10. Distinctive:

    Do not use dense-only retrieval for corpora full of filenames, IDs, code symbols or proper nouns.

    line 257
  11. Distinctive:

    Do not expose sensitive pages through unfiltered semantic search.

    line 258
  12. Distinctive:

    Do not recommend cloud embeddings/rerankers for sensitive material without explicit approval.

    line 259
  13. Distinctive:

    Do not hide chunking, embedding model, index revision or rebuild policy.

    line 260
  14. Distinctive:

    Do not claim GraphRAG is necessary when failures are lexical, metadata, chunking or ranking problems.

    line 261
  15. Distinctive:

    Do not let draft, rejected, stale or unauthorized content enter production retrieval.

    line 262

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

LLM-Wiki Retrieval Architect

Goal

Choose the smallest retrieval tier that solves the user's measured retrieval failure while preserving inspectable Markdown, provenance, access filters and rebuildable indexes.

Use references/docs/16-retrieval-architecture.md as the reference playbook for detailed technology comparisons, metadata schema, GraphRAG lane design, evaluation gates, security controls and source URLs to re-check.

When to use

  • The wiki's search misses relevant pages even though the content exists (lexical miss, stale index, poor ranking, thin context, or multi-hop miss).
  • You need to pick or size a retrieval tier (grep-only, lexical index, hybrid semantic search, reranker, parent/context retrieval, graph-aware retrieval, or product storage) for a Markdown/wiki corpus.
  • You must define index contracts, metadata/access filters, chunking policy, or graph edge schema for a new or growing wiki.
  • Retrieval needs to respect tenant, sensitivity, or review-state boundaries before rollout.
  • Whole-stack local-first tooling choices belong in llm-wiki-local-first-stack; use this skill once retrieval specifically is the bottleneck.

Inputs

  • Corpus size and source types.
  • Current folder structure and wiki page schema.
  • Query examples that failed.
  • Privacy/local-first requirements.
  • Latency, cost and deployment constraints.
  • Existing tools: rg, SQLite, vector DB, GraphRAG, LlamaIndex, Haystack, MCP.
  • Team/tenant/security requirements.
  • Evaluation set or recent real questions, if available.

Procedure

1. Diagnose the retrieval failure

Classify the failure:

FailureMeaningTypical fix
lexical missKeywords differ but concept is the same.Add dense retrieval or query expansion.
exact-token missIDs, filenames, names or code symbols are missed.Improve lexical/FTS lane; do not rely on dense-only search.
stale indexSearch misses newly added or changed pages.Fix rebuild/watch/CI triggers.
poor metadataResults cannot filter by source, status, sensitivity or date.Add required metadata fields and query-time filters.
poor rankingRelevant result exists in top 20-100 but not top 5.Add reranker.
thin contextRetrieved chunk is relevant but too small to answer.Add parent-child or contextual retrieval.
synthesis missIndividual pages are found but no cross-page answer exists.Add synthesis pages or graph lane.
multi-hop missRelationships across entities/concepts are not traversed.Add graph-aware retrieval or GraphRAG lane.
provenance missThe result is plausible but unsupported by raw sources.Add citation metadata and claim-support checks.
permission missRetrieval can expose restricted content.Stop and fix filters/security before tuning relevance.

Do not add infrastructure until a real retrieval failure is identified.

2. Pick the retrieval tier

Use progressive retrieval:

TierUse whenCapability shape
0. Map + grepSmall/medium wiki with good names, indexes and wikilinks.index.md, log.md, rg, fd, backlinks.
1. Local lexical indexExact search must be faster, ranked or scoped.Embedded or hosted full-text engine with ranking and scoping.
2. Hybrid semantic searchConceptual search fails or users ask natural-language questions.Lexical lane plus embedding lane with score fusion.
3. Reranked retrievalTop-k contains signal but order is poor.Cross-encoder or late-interaction reranker over candidate sets.
4. Parent/context retrievalSmall chunks retrieve well but answer context is incomplete.Parent-document, contextual or recursive retrieval.
5. Graph-aware retrievalMulti-hop, relationship-heavy or corpus-level questions dominate.Wikilink/entity graph traversal or a GraphRAG-family lane.
6. Product storageMulti-user permissions, concurrency, tenancy or scale dominate.Vector-native platform or SQL vector extension plus object storage and queues.

Default recommendation: hybrid retrieval + metadata filters + reranker. GraphRAG is a specialized lane for global/relationship-heavy questions, not the universal default.

Pick concrete engines per tier from the comparison tables in references/docs/16-retrieval-architecture.md, then browse each candidate's docs to re-verify maintenance status, licensing and feature claims before recommending it.

3. Choose by deployment archetype

SituationDefault shape
Personal/local-first wikiGrep plus an embedded lexical index and local embeddings; upgrade only on measured misses.
Obsidian-style Markdown vaultWikilinks/backlinks plus FTS; add graph-native retrieval before a vector DB if links are strong.
Repo-docs CIGit/module maps plus static search; optional hybrid preview index.
Hosted team wikiVector-native hybrid engine with payload/tenant filters and a reranker.
Existing enterprise search stackReuse the incumbent stack's hybrid capabilities; re-check current licensing terms before choosing between OSS and source-available engines.
App-data-heavy productThe application database's vector extension when SQL joins, transactional metadata and app ACLs dominate.
Very large vector collectionA scale-first vector platform only if the team owns the operational complexity.
Corpus-level synthesisHybrid default plus a graph/GraphRAG lane for selected query classes.

Map each shape to named engines using references/docs/16-retrieval-architecture.md and cite current sources for any licensing or maturity claim.

4. Define index contracts

For every index, define:

index_name: ""
index_type: lexical|dense|sparse|hybrid|graph|static
source_of_truth: raw|wiki|both
input_paths: []
output_paths: []
embedding_model: ""
sparse_model: "BM25|SPLADE|none"
reranker_model: ""
chunking_policy: heading-aware|parent-child|contextual|fixed-window
metadata_fields: []
access_filters: []
refresh_trigger: manual|pre-commit|scheduled|watch|ci
rebuild_command: ""
index_revision: ""

Indexes must be reconstructable unless the user explicitly chooses database-first storage.

5. Design metadata filters

At minimum support:

  • doc_id;
  • chunk_id;
  • parent_id;
  • source_uri;
  • source_type;
  • page_path;
  • heading_path;
  • repo, path, branch, commit_sha when code/repo docs are involved;
  • review_state;
  • publication_state;
  • sensitivity;
  • tenant_id;
  • acl_tags;
  • owner;
  • created_at;
  • updated_at;
  • stale_after;
  • model_policy;
  • hash_sha256;
  • embed_model;
  • index_revision.

Critical rule: tenant_id, acl_tags, sensitivity, review_state and publication_state must be query-time filters, not post-generation cleanup.

Default governed query filter:

tenant_id = current_tenant
AND review_state IN ('reviewed', 'verified')
AND publication_state IN ('internal', 'public')
AND publication_state != 'archived'
AND sensitivity IN allowed_sensitivity_classes
AND source_domain IN allowed_source_domains

6. Decide chunking and context strategy

Prefer native structure over arbitrary windows:

CorpusChunking rule
Markdown/wikiheading/subheading chunks with parent page references.
Long pages300-600 token chunks with 10-20% overlap, plus parent expansion.
Code/API docsfile + symbol + docstring or endpoint/class/function units.
Tablespreserve row/column labels and captions.
PDFsuse layout-aware chunks when table/layout fidelity matters.
Chat/session logssession -> task -> turn group; redact before indexing.

Use contextual retrieval when chunks are semantically ambiguous without surrounding document context. Use parent-child retrieval when small child chunks retrieve well but larger sections answer better.

7. Decide graph strategy

Use graph extraction only when the wiki already has stable page types, wikilinks, entities or citations.

Graph edges should include:

from: ""
to: ""
edge_type: cites|mentions|defines|contradicts|depends_on|similar_to|derived_from|owned_by|decided_by
source_chunks: []
confidence: 0.0
created_by: human|agent|importer
review_state: draft|reviewed|verified|stale|archived

Do not use graph visualization as proof of knowledge quality. Evaluate the graph lane against multi-hop/global query classes.

8. Plan evaluation

Measure before and after retrieval changes:

  • recall@k;
  • MRR;
  • nDCG@k;
  • query hit/miss labels;
  • citation coverage;
  • unsupported-claim count;
  • source-support rate;
  • p50/p95 retrieval latency;
  • indexing throughput;
  • freshness lag;
  • cost per query;
  • index rebuild time;
  • permission-filter failures;
  • sensitive-snippet leakage.

Hand off to llm-wiki-eval-tooling for formal eval design and CI gates.

9. Review security before rollout

Check:

  • PII/secret scanning before indexing;
  • source allowlists;
  • staging indexes for unreviewed content;
  • cross-tenant leakage tests;
  • cloud embedding/reranker data policy;
  • MCP scopes and local/remote trust boundaries;
  • retrieval logs that might store sensitive snippets.

Hand off to llm-wiki-security-review when sensitive/team data is involved.

Output

## Retrieval diagnosis

## Recommended tier

## Deployment recommendation

## Technology choices

| Component | Choice | Why | Rebuild policy | Risks |
|---|---|---|---|---|

## Chunking and context strategy

## Metadata and access filters

## Graph/GraphRAG lane

## Index rebuild plan

## Query evaluation plan

## Security review

## Upgrade triggers

## Next skill

Safety gates

  • Do not make the vector index the source of truth.
  • Do not use dense-only retrieval for corpora full of filenames, IDs, code symbols or proper nouns.
  • Do not expose sensitive pages through unfiltered semantic search.
  • Do not recommend cloud embeddings/rerankers for sensitive material without explicit approval.
  • Do not hide chunking, embedding model, index revision or rebuild policy.
  • Do not claim GraphRAG is necessary when failures are lexical, metadata, chunking or ranking problems.
  • Do not let draft, rejected, stale or unauthorized content enter production retrieval.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.