Knowledge Query
Answer questions over existing knowledge assets: linked Markdown vaults, graph exports, RAG chunks, ontology files, source inventories, or a mixture of them.
Standing Mandates
- Search before reading. Never open a note body with Read, Grep, or Glob until a retrieval step has named it as a candidate. The order is fixed:
knowledge_search (or the CLI search) → knowledge_get on the top candidates → only then the Markdown file, and only when the returned text is insufficient.
- The index exists to be used. If
.knowledge/knowledge.sqlite or the knowledge-local MCP is present, it is the retrieval surface. Scanning notes/**/*.md while an index exists is a defect in the answer, not a shortcut; it bypasses ranking, filters, relation promotion, and the diagnostics that tell you whether retrieval worked.
- No index → catalog, not files. Without an index, search
_knowledge/catalog.jsonl first and open only the notes it nominates. Reading the vault directly is allowed only when neither an index nor a catalog exists, and the answer must say so.
- Cite what retrieval returned. Evidence lines name the
path / source_ref from the search result, so the reader can see the note was found, not browsed into.
- Cite only what you opened. A search result is a candidate, not evidence. Run
knowledge_get on every note you are about to cite; a snippet shows that the note matched, not what it says. Measured on a 94-question competency set: answers that opened no note cited the required note 14% of the time, answers that opened four or more, 93%. If a note is worth citing it is worth one get.
- One hop before answering, for questions with sides. A comparison, equivalence, sequence, or multi-source question is not answered from the one note that ranked first. Run
knowledge_neighbors on the best candidate and open every participant it names — a type: relation note's participants, the contrast note a workflow note links to, the code table a status question depends on. One hop, then answer; do not walk the graph. Measured on a 94-question set, neighbors was called 4 times in 188 answer runs, and the notes both models missed most were exactly the ones it reaches: a shared status-flow note missed on 5 of 6 questions that required it, a form-family contrast note missed on all 3, three carrier notes missed every time they were required. Multi-source questions scored 0.28 and 0.69 against 0.94 for single-note questions.
- Thin results are diagnosed, not worked around. When search looks empty, read
lexical_candidates and re-query with exact vocabulary before touching a file. A grep-based detour hides a ranking bug that eval should catch.
- Retrieval quality is a reported fact, not an assumption. Every result carries
embedding_quality, fusion_weights, and reranked. Under embedding_quality: lexical-baseline a paraphrased question is expected to miss — say so and re-query with vault vocabulary instead of concluding the vault lacks the answer. When rerank_error is set, the order you are reading is the fallback order, and the answer should not be presented as if the reranker ran.
Query Routing
Choose the retrieval path from the asset shape and question type:
| Asset or question |
Prefer |
.knowledge/knowledge.sqlite, knowledge-local MCP |
SQLite hybrid search first |
_knowledge/catalog.jsonl, note IDs, aliases, tags, entities |
Catalog-first candidate discovery |
| Obsidian-style Markdown notes, MOCs, backlinks |
Linked-vault traversal |
ontology.md, ontology.yml, controlled vocabularies |
Ontology-aware term/class/relation lookup |
nodes / edges, Cypher, RDF/Turtle, triples |
Graph query or graph inspection |
chunks.jsonl, retrieval metadata, eval queries |
RAG-style chunk retrieval |
| "What is X?" with source-backed explanation |
Vault or RAG |
| "What depends on X?" or "What is impacted by X?" |
Graph first, then vault/RAG for evidence |
| "What should I read next?" |
MOC and backlink traversal |
When assets are mixed, use graph/vault structure to find candidates and RAG chunks or source references to ground the final answer.
Local SQLite Fast Path
When the knowledge-local MCP tools are connected, use them before scanning JSONL or note bodies manually:
- Check index presence and freshness with
knowledge_status.
- Build or refresh with
knowledge_index when missing or stale.
- Retrieve candidates with
knowledge_search; use knowledge_get for full evidence and knowledge_neighbors to expand a candidate into its participants and siblings before composing a multi-sided answer.
- Check the retrieval diagnostics before trusting an empty-looking result. When
lexical_candidates exceeds lexical_matches_returned, or the query used vault vocabulary and retrieval is vector, the terms exist in the corpus but lost the ranking; re-query with the exact title, alias, or source symbol before grading coverage.
- For scoped questions ("every policy note in the goods domain"), use the
domain, docType, section, and pathPrefix filters on knowledge_search, or the CLI list command, instead of dropping to SQL. knowledge_status reports which metadata keys are filterable.
- When a reranker endpoint is attached, pass
--reranker-url (and --reranker-model) so a
shortlist is reordered by a cross-encoder before the window is built. It is optional by
design: absent means fused order, and a failing endpoint falls back to fused order with
rerank_error set rather than erroring the query. Never install or start one to answer a
question — if the user has not attached it, answer without it.
- Compose the answer yourself from the returned evidence and cite original
source_ref or path values.
Read references/local-sqlite.md for exact MCP routing, embedding modes, CLI, Docker operation, and failure handling. If the MCP server is unavailable, continue with the portable asset discovery below.
For a build, rebuild, refresh, or MD/JSONL-to-SQLite synchronization request whose primary outcome is the index itself, route to knowledge:sqlite-index-builder. Query-time refreshes may remain in this skill when they are only a prerequisite to answering the user's question.
Default Asset Discovery
Do not ask where knowledge or RAG artifacts are if the repository or vault follows the default convention. Check these catalog locations before scanning note bodies:
<vault>/_knowledge/catalog.jsonl
knowledge-base/_knowledge/catalog.jsonl
knowledge-system/_knowledge/catalog.jsonl
Then check these RAG locations when chunk retrieval is needed:
<vault>/_rag/chunks.jsonl
<vault>/_rag/sources.csv
knowledge-artifacts/rag/chunks.jsonl
knowledge-artifacts/rag/sources.csv
Also check sibling default asset folders when present:
<vault>/_ontology/
<vault>/_graph/
knowledge-artifacts/ontology/
knowledge-artifacts/graph/
Ask for location only after these default paths and obvious user-provided paths are absent.
Quick Intake
For vague queries, ask what kind of answer the user wants before searching broadly:
- Are they asking for lookup, synthesis, impact analysis, reading path, or gap finding?
- Should the answer be short, evidence-heavy, or exploratory?
If the query is concrete, skip intake and answer from the available assets. If assets are missing, ask for location only after checking default paths.
Process
- Identify available assets. Check the local SQLite MCP index first, then locate
_knowledge/catalog.jsonl, index.md, vault-plan.md, mocs/, note frontmatter, ontology.md, ontology.yml, mapping.md, nodes.*, edges.*, schema.md, chunks.jsonl, sources.csv, or eval-queries.jsonl.
- Restate the query intent. Classify the request as lookup, synthesis, impact analysis, comparison, provenance check, reading path, or gap/open-question search.
- Select candidates and a query path. When a catalog exists, search its titles, aliases,
user_terms, source_symbols, tags, domains, entities, and summaries first, then open only the best-matching notes. Use links/MOCs for conceptual navigation, graph edges for relationship traversal, and RAG chunks for passage-level evidence. For comparison, equivalence, or sequence questions, prefer first-class relation notes and verify every participant's evidence instead of synthesizing from one-sided proximity: expand the best candidate with knowledge_neighbors, open each participant, and stop expanding once every side of the question has a note. A relation note that carries evidence_by_participant for every side already covers them; a relation note that does not is one-sided until the participant notes are opened.
- Trace evidence. Open every candidate you intend to cite with
knowledge_get before writing anything, and preserve source references from note Sources, frontmatter sources, graph edge evidence, or chunk source_ref. Prefer direct evidence over inferred relationships. Answering off the search snippets is the single largest measured cause of a wrong or thin answer — the snippet is a ranking artifact, not the claim.
- Answer with citations. Cite the note, source path, chunk ID, node/edge record, or URL that supports each non-obvious claim.
- Assign coverage by checking the parts, not by feel. Split the question into its material parts — each entity being compared, each layer being bridged, each step being sequenced — and name the opened note that covers each.
complete requires every part to map to a note you opened; if any part maps to none, to a search snippet, or to your own inference, the answer is partial and the unmapped part is named under Missing knowledge. Use unanswerable when the assets cannot establish the answer. A plausible story assembled from nearby notes is partial, however confident it reads.
- Surface missing knowledge. For
partial or unanswerable, name the missing relation note, participant, source anchor, vocabulary bridge, or freshness evidence needed to resolve the question.
- Record failures only when authorized. Ordinary queries are read-only. Return an
Improvement candidate block for partial or unanswerable results. Append it to _knowledge/improvement-notes.md or update _knowledge/question-results.jsonl only when the user requested vault maintenance, the current build is running the competency gate, or the vault plan explicitly opts into query-failure logging.
- Suggest follow-up queries only when useful. Offer targeted next questions when they would materially improve the user's investigation.
Output Shape
For ordinary answers, always begin with the coverage grade:
Coverage: complete | partial | unanswerable
Answer in 2-5 concise paragraphs.
Evidence:
- `knowledge-base/path/Note.md` -> source or claim used
- `chunks.jsonl#chunk-id` -> source_ref
Opened: # every note read with get, in order
- `knowledge-base/path/Note.md`
Uncertainty:
- Any missing, stale, inferred, or conflicting evidence.
Missing knowledge: # required for partial/unanswerable
- Needed relation note, participant, anchor, bridge, or source.
Improvement candidate: # return; write only when authorized
- Question, observed failure, required evidence, and next extraction action.
For impact analysis:
## Direct Impact
- Affected entity or note, with edge/link/source evidence.
## Indirect Impact
- Second-order dependencies, clearly labeled as inferred when appropriate.
## Unknowns
- Missing relationships, stale sources, or sources not indexed.
Quality Bar
- Answers are grounded in the knowledge asset, not general memory, unless explicitly labeled as outside context.
- SQLite retrieval cites canonical Markdown/JSONL provenance rather than the derived database file.
- A thin SQLite result set is diagnosed against
lexical_candidates and embedding_quality before it is reported as missing knowledge.
- Catalog-backed queries narrow candidates before opening note bodies and preserve stable note IDs when paths change.
- Relationship-heavy questions inspect graph edges or note links before giving a narrative answer, by expanding a retrieved candidate rather than hoping every side ranked in the same result set.
- A question naming N things to compare, bridge, or order is answered from at least N notes, or its coverage is
partial and the unopened side is named.
- Comparison, equivalence, and sequence answers verify evidence for every participant, from that participant's own note or from the relation note's
evidence_by_participant; a one-sided relation is not presented as complete.
- Citations point to stable note paths, source refs, chunk IDs, or graph records.
- Every cited note was opened with
knowledge_get, and the Opened list says so; a note cited from its search snippet alone is a defect, not a shortcut.
- Conflicts and stale-risk evidence are visible.
- Every answer declares
complete, partial, or unanswerable coverage using the strict meanings above.
complete is a claim about parts and notes, not about confidence: every part of the question maps to a note that was opened. Measured on a 94-question competency set, complete was declared on 69–80 of 94 answers and was actually complete on 22–38 of them, in both cases while missing required notes and, in a few, while citing none at all. Downgrade to partial and name the gap; an honest partial is worth more than a complete the reader has to audit.
- If the knowledge asset cannot answer the question, say exactly what is missing and which source would likely resolve it; do not fill the gap with an unlabeled inference.
- Read-only queries do not mutate improvement memory or competency results without maintenance authorization or an explicit vault opt-in.
- No Markdown note is opened before a search or catalog step nominated it; when a file is read, the answer states which search result led there.
Related Skills
knowledge:sqlite-index-builder - build or refresh the derived SQLite index from canonical Markdown and JSONL.
knowledge:knowledge-base-builder - use to create or reshape the linked Markdown vault before querying.
knowledge:ontology-builder - use to define class/relation semantics and controlled vocabularies before querying or extraction.
knowledge:knowledge-graph-builder - use to create graph-ready entities and relationships before graph queries.
knowledge:rag-corpus-builder - use to prepare retrieval chunks and evals before RAG-style querying.
1---2name: knowledge-query3description: Use when answering questions over an existing linked Markdown vault, local SQLite index, ontology, knowledge graph, RAG corpus, or mixed knowledge assets while preserving citations, uncertainty, and retrieval traceability.4---56# Knowledge Query78Answer questions over existing knowledge assets: linked Markdown vaults, graph exports, RAG chunks, ontology files, source inventories, or a mixture of them.910## Standing Mandates1112- **Search before reading.** Never open a note body with Read, Grep, or Glob until a retrieval step has named it as a candidate. The order is fixed: `knowledge_search` (or the CLI `search`) → `knowledge_get` on the top candidates → only then the Markdown file, and only when the returned text is insufficient.13- **The index exists to be used.** If `.knowledge/knowledge.sqlite` or the `knowledge-local` MCP is present, it is the retrieval surface. Scanning `notes/**/*.md` while an index exists is a defect in the answer, not a shortcut; it bypasses ranking, filters, relation promotion, and the diagnostics that tell you whether retrieval worked.14- **No index → catalog, not files.** Without an index, search `_knowledge/catalog.jsonl` first and open only the notes it nominates. Reading the vault directly is allowed only when neither an index nor a catalog exists, and the answer must say so.15- **Cite what retrieval returned.** Evidence lines name the `path` / `source_ref` from the search result, so the reader can see the note was found, not browsed into.16- **Cite only what you opened.** A search result is a candidate, not evidence. Run `knowledge_get` on every note you are about to cite; a snippet shows that the note matched, not what it says. Measured on a 94-question competency set: answers that opened no note cited the required note 14% of the time, answers that opened four or more, 93%. If a note is worth citing it is worth one `get`.17- **One hop before answering, for questions with sides.** A comparison, equivalence, sequence, or multi-source question is not answered from the one note that ranked first. Run `knowledge_neighbors` on the best candidate and open every participant it names — a `type: relation` note's `participants`, the contrast note a workflow note links to, the code table a status question depends on. One hop, then answer; do not walk the graph. Measured on a 94-question set, `neighbors` was called 4 times in 188 answer runs, and the notes both models missed most were exactly the ones it reaches: a shared status-flow note missed on 5 of 6 questions that required it, a form-family contrast note missed on all 3, three carrier notes missed every time they were required. Multi-source questions scored 0.28 and 0.69 against 0.94 for single-note questions.18- **Thin results are diagnosed, not worked around.** When search looks empty, read `lexical_candidates` and re-query with exact vocabulary before touching a file. A grep-based detour hides a ranking bug that `eval` should catch.19- **Retrieval quality is a reported fact, not an assumption.** Every result carries `embedding_quality`, `fusion_weights`, and `reranked`. Under `embedding_quality: lexical-baseline` a paraphrased question is expected to miss — say so and re-query with vault vocabulary instead of concluding the vault lacks the answer. When `rerank_error` is set, the order you are reading is the fallback order, and the answer should not be presented as if the reranker ran.2021## Query Routing2223Choose the retrieval path from the asset shape and question type:2425| Asset or question | Prefer |26|---|---|27| `.knowledge/knowledge.sqlite`, `knowledge-local` MCP | SQLite hybrid search first |28| `_knowledge/catalog.jsonl`, note IDs, aliases, tags, entities | Catalog-first candidate discovery |29| Obsidian-style Markdown notes, MOCs, backlinks | Linked-vault traversal |30| `ontology.md`, `ontology.yml`, controlled vocabularies | Ontology-aware term/class/relation lookup |31| `nodes` / `edges`, Cypher, RDF/Turtle, triples | Graph query or graph inspection |32| `chunks.jsonl`, retrieval metadata, eval queries | RAG-style chunk retrieval |33| "What is X?" with source-backed explanation | Vault or RAG |34| "What depends on X?" or "What is impacted by X?" | Graph first, then vault/RAG for evidence |35| "What should I read next?" | MOC and backlink traversal |3637When assets are mixed, use graph/vault structure to find candidates and RAG chunks or source references to ground the final answer.3839## Local SQLite Fast Path4041When the `knowledge-local` MCP tools are connected, use them before scanning JSONL or note bodies manually:42431. Check index presence and freshness with `knowledge_status`.442. Build or refresh with `knowledge_index` when missing or stale.453. Retrieve candidates with `knowledge_search`; use `knowledge_get` for full evidence and `knowledge_neighbors` to expand a candidate into its participants and siblings before composing a multi-sided answer.464. Check the retrieval diagnostics before trusting an empty-looking result. When `lexical_candidates` exceeds `lexical_matches_returned`, or the query used vault vocabulary and `retrieval` is `vector`, the terms exist in the corpus but lost the ranking; re-query with the exact title, alias, or source symbol before grading coverage.475. For scoped questions ("every policy note in the goods domain"), use the `domain`, `docType`, `section`, and `pathPrefix` filters on `knowledge_search`, or the CLI `list` command, instead of dropping to SQL. `knowledge_status` reports which metadata keys are filterable.486. When a reranker endpoint is attached, pass `--reranker-url` (and `--reranker-model`) so a49 shortlist is reordered by a cross-encoder before the window is built. It is optional by50 design: absent means fused order, and a failing endpoint falls back to fused order with51 `rerank_error` set rather than erroring the query. Never install or start one to answer a52 question — if the user has not attached it, answer without it.537. Compose the answer yourself from the returned evidence and cite original `source_ref` or `path` values.5455Read [references/local-sqlite.md](references/local-sqlite.md) for exact MCP routing, embedding modes, CLI, Docker operation, and failure handling. If the MCP server is unavailable, continue with the portable asset discovery below.5657For a build, rebuild, refresh, or MD/JSONL-to-SQLite synchronization request whose primary outcome is the index itself, route to `knowledge:sqlite-index-builder`. Query-time refreshes may remain in this skill when they are only a prerequisite to answering the user's question.5859## Default Asset Discovery6061Do not ask where knowledge or RAG artifacts are if the repository or vault follows the default convention. Check these catalog locations before scanning note bodies:62631. `<vault>/_knowledge/catalog.jsonl`642. `knowledge-base/_knowledge/catalog.jsonl`653. `knowledge-system/_knowledge/catalog.jsonl`6667Then check these RAG locations when chunk retrieval is needed:68691. `<vault>/_rag/chunks.jsonl`702. `<vault>/_rag/sources.csv`713. `knowledge-artifacts/rag/chunks.jsonl`724. `knowledge-artifacts/rag/sources.csv`7374Also check sibling default asset folders when present:7576```text77<vault>/_ontology/78<vault>/_graph/79knowledge-artifacts/ontology/80knowledge-artifacts/graph/81```8283Ask for location only after these default paths and obvious user-provided paths are absent.8485## Quick Intake8687For vague queries, ask what kind of answer the user wants before searching broadly:8889- Are they asking for lookup, synthesis, impact analysis, reading path, or gap finding?90- Should the answer be short, evidence-heavy, or exploratory?9192If the query is concrete, skip intake and answer from the available assets. If assets are missing, ask for location only after checking default paths.9394## Process95961. **Identify available assets.** Check the local SQLite MCP index first, then locate `_knowledge/catalog.jsonl`, `index.md`, `vault-plan.md`, `mocs/`, note frontmatter, `ontology.md`, `ontology.yml`, `mapping.md`, `nodes.*`, `edges.*`, `schema.md`, `chunks.jsonl`, `sources.csv`, or `eval-queries.jsonl`.972. **Restate the query intent.** Classify the request as lookup, synthesis, impact analysis, comparison, provenance check, reading path, or gap/open-question search.983. **Select candidates and a query path.** When a catalog exists, search its titles, aliases, `user_terms`, `source_symbols`, tags, domains, entities, and summaries first, then open only the best-matching notes. Use links/MOCs for conceptual navigation, graph edges for relationship traversal, and RAG chunks for passage-level evidence. For comparison, equivalence, or sequence questions, prefer first-class relation notes and verify every participant's evidence instead of synthesizing from one-sided proximity: expand the best candidate with `knowledge_neighbors`, open each participant, and stop expanding once every side of the question has a note. A relation note that carries `evidence_by_participant` for every side already covers them; a relation note that does not is one-sided until the participant notes are opened.994. **Trace evidence.** Open every candidate you intend to cite with `knowledge_get` before writing anything, and preserve source references from note `Sources`, frontmatter `sources`, graph edge evidence, or chunk `source_ref`. Prefer direct evidence over inferred relationships. Answering off the search snippets is the single largest measured cause of a wrong or thin answer — the snippet is a ranking artifact, not the claim.1005. **Answer with citations.** Cite the note, source path, chunk ID, node/edge record, or URL that supports each non-obvious claim.1016. **Assign coverage by checking the parts, not by feel.** Split the question into its material parts — each entity being compared, each layer being bridged, each step being sequenced — and name the opened note that covers each. `complete` requires every part to map to a note you opened; if any part maps to none, to a search snippet, or to your own inference, the answer is `partial` and the unmapped part is named under `Missing knowledge`. Use `unanswerable` when the assets cannot establish the answer. A plausible story assembled from nearby notes is `partial`, however confident it reads.1027. **Surface missing knowledge.** For `partial` or `unanswerable`, name the missing relation note, participant, source anchor, vocabulary bridge, or freshness evidence needed to resolve the question.1038. **Record failures only when authorized.** Ordinary queries are read-only. Return an `Improvement candidate` block for partial or unanswerable results. Append it to `_knowledge/improvement-notes.md` or update `_knowledge/question-results.jsonl` only when the user requested vault maintenance, the current build is running the competency gate, or the vault plan explicitly opts into query-failure logging.1049. **Suggest follow-up queries only when useful.** Offer targeted next questions when they would materially improve the user's investigation.105106## Output Shape107108For ordinary answers, always begin with the coverage grade:109110```markdown111Coverage: complete | partial | unanswerable112113Answer in 2-5 concise paragraphs.114115Evidence:116- `knowledge-base/path/Note.md` -> source or claim used117- `chunks.jsonl#chunk-id` -> source_ref118119Opened: # every note read with get, in order120- `knowledge-base/path/Note.md`121122Uncertainty:123- Any missing, stale, inferred, or conflicting evidence.124125Missing knowledge: # required for partial/unanswerable126- Needed relation note, participant, anchor, bridge, or source.127128Improvement candidate: # return; write only when authorized129- Question, observed failure, required evidence, and next extraction action.130```131132For impact analysis:133134```markdown135## Direct Impact136- Affected entity or note, with edge/link/source evidence.137138## Indirect Impact139- Second-order dependencies, clearly labeled as inferred when appropriate.140141## Unknowns142- Missing relationships, stale sources, or sources not indexed.143```144145## Quality Bar146147- Answers are grounded in the knowledge asset, not general memory, unless explicitly labeled as outside context.148- SQLite retrieval cites canonical Markdown/JSONL provenance rather than the derived database file.149- A thin SQLite result set is diagnosed against `lexical_candidates` and `embedding_quality` before it is reported as missing knowledge.150- Catalog-backed queries narrow candidates before opening note bodies and preserve stable note IDs when paths change.151- Relationship-heavy questions inspect graph edges or note links before giving a narrative answer, by expanding a retrieved candidate rather than hoping every side ranked in the same result set.152- A question naming N things to compare, bridge, or order is answered from at least N notes, or its coverage is `partial` and the unopened side is named.153- Comparison, equivalence, and sequence answers verify evidence for every participant, from that participant's own note or from the relation note's `evidence_by_participant`; a one-sided relation is not presented as complete.154- Citations point to stable note paths, source refs, chunk IDs, or graph records.155- Every cited note was opened with `knowledge_get`, and the `Opened` list says so; a note cited from its search snippet alone is a defect, not a shortcut.156- Conflicts and stale-risk evidence are visible.157- Every answer declares `complete`, `partial`, or `unanswerable` coverage using the strict meanings above.158- `complete` is a claim about parts and notes, not about confidence: every part of the question maps to a note that was opened. Measured on a 94-question competency set, `complete` was declared on 69–80 of 94 answers and was actually complete on 22–38 of them, in both cases while missing required notes and, in a few, while citing none at all. Downgrade to `partial` and name the gap; an honest `partial` is worth more than a `complete` the reader has to audit.159- If the knowledge asset cannot answer the question, say exactly what is missing and which source would likely resolve it; do not fill the gap with an unlabeled inference.160- Read-only queries do not mutate improvement memory or competency results without maintenance authorization or an explicit vault opt-in.161- No Markdown note is opened before a search or catalog step nominated it; when a file is read, the answer states which search result led there.162163## Related Skills164165- `knowledge:sqlite-index-builder` - build or refresh the derived SQLite index from canonical Markdown and JSONL.166- `knowledge:knowledge-base-builder` - use to create or reshape the linked Markdown vault before querying.167- `knowledge:ontology-builder` - use to define class/relation semantics and controlled vocabularies before querying or extraction.168- `knowledge:knowledge-graph-builder` - use to create graph-ready entities and relationships before graph queries.169- `knowledge:rag-corpus-builder` - use to prepare retrieval chunks and evals before RAG-style querying.