/cogni-knowledge:knowledge-queryfrom cogni-knowledge
Queries a bound cogni-knowledge base by slug, ranks and reads covering pages, and synthesizes a cited answer from ≤12 pages. Read-only by default; opt-in --file-back deposits an un-verified synthesis page.
Ships in cogni-knowledge. 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.
Ask a question against a bound cogni-knowledge base. This skill is the shallow
rung of the query↔research depth ladder: it ranks the pages that cover the
question, reads them, and synthesizes a grounded, cited answer — one question,
index-first, ≤12 pages, no web, no verify (the deep wiki-only report rung is
owned by knowledge-compose --source wiki).
It runs natively on the vendored wiki engine — it consumes the shared
wiki-grounding.py discovery primitive directly and reads the wiki pages with
the Read tool, so a Karpathy base answers questions without cogni-wiki
installed. The cogni-knowledge value-add:
--wiki-root from the user; read from binding.json.wiki-grounding.py, read them, answer only from what they say (with [[slug]] citations), and report honestly when coverage is thin.Read ${CLAUDE_PLUGIN_ROOT}/references/differentiation-thesis.md once per session to anchor on the accumulation thesis. The synthesis discipline below — answer only from the pages you read, cite every claim, admit uncertainty — is the shallow rung's core contract.
/cogni-knowledge:knowledge-queryknowledge-resume has shown what is in the basebinding.json exists at the resolved knowledge root — route the user to /cogni-knowledge:knowledge-setup first.knowledge-compose --source wiki (the deep rung), not this skill.| Parameter | Required | Description |
|---|---|---|
--knowledge-slug | Yes | Slug of the bound knowledge base. Resolves to cogni-knowledge/<slug>/ unless --knowledge-root overrides. |
--question | Yes (prompted) | Free-text question. Grounded against the bound wiki. |
--knowledge-root | No | Override the default knowledge-base directory. Defaults to cogni-knowledge/<knowledge-slug>/ (relative to the current working directory). |
--max-pages | No | Cap on how many ranked pages to read and synthesize from. Default 12 (the shallow-rung ceiling). Passed to wiki-grounding.py rank --top-k. |
--theme | No | Optional thematic label folded into the ranking (passed to wiki-grounding.py rank --theme-label) to sharpen page selection on a broad question. |
--dual-level | No | Opt-in, default off. Passes wiki-grounding.py rank --dual-level — an additive dual-level (entity + cross-document) rank that lifts answering source pages via the distilled concept/entity pages that cite them, and folds those distilled pages into the ranked set. Sharpens retrieval on entity-spanning / cross-document questions a query under-retrieves at the source level alone; the single-level ranking is byte-identical without it. |
--file-back | No | Opt-in synthesis deposit. Absent → read-only (the default; no writes, no prompt — autonomous/cron runs stay clean). yes → deposit the synthesized answer as an honestly-labeled un-verified type: synthesis wiki page (Step 4). |
--synthesis-slug | No | Override the auto-derived deposit slug (only meaningful with --file-back yes). |
--overwrite | No | With --file-back yes, replace an existing wiki/syntheses/<slug>.md instead of aborting on the collision guard. |
If --question is missing, ask the user once via AskUserQuestion (single free-text question — load the schema via ToolSearch(query="select:AskUserQuestion") if needed). Do not invent a question.
Required engine. This skill resolves the wiki engine vendored-first —
cogni-knowledge ships a byte-identical copy of the engine in-tree under
scripts/vendor/cogni-wiki/, so a bound base is queryable without cogni-wiki
installed. Probe it so the
skill aborts cleanly here rather than failing mid-read:
# vendored-first: the in-tree engine is self-contained
test -d "${CLAUDE_PLUGIN_ROOT}/scripts/vendor/cogni-wiki/skills/wiki-ingest/scripts" && WIKI_OK=yes || WIKI_OK=no
If WIKI_OK is no, abort:
cogni-knowledge's vendored wiki engine is missing. Reinstall cogni-knowledge, then retry.
Then continue with the binding-resolution checks:
Resolve knowledge_root:
--knowledge-root is set, use it.knowledge_root = cogni-knowledge/<knowledge-slug>/ (relative to the current working directory).Read the binding:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/knowledge-binding.py read \
--knowledge-root <knowledge_root>
On success: false, abort and offer knowledge-setup. Do not auto-create.
Extract wiki_path, knowledge_slug, and research_projects[] from the binding. Validate that binding.knowledge_slug == --knowledge-slug — mismatch indicates the user is pointing at the wrong directory.
Confirm the wiki is still there: <wiki_path>/.cogni-wiki/config.json must exist. If not, abort with a clear "the binding points at a wiki that no longer exists" error.
Run the shared wiki-grounding primitive against the bound wiki — the same
rank mechanism wiki-coverage.py and wiki-source-manifest.py resolve to:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/wiki-grounding.py rank \
--wiki-root <wiki_path> \
--question "<question>" \
--top-k <max-pages, default 12> \
[--theme-label "<theme>"] \
[--dual-level]
Forward --dual-level to wiki-grounding.py only when the caller passed it to
this skill; otherwise omit the flag entirely, leaving the single-level ranking
byte-identical. When set, it adds the entity + cross-document fold-in described
in the parameter table.
Capture data.pages[] (each {slug, type, page_path, title, overlap_score, reasons}, ranked highest-overlap first; page_path is wiki-root-relative) and
data.coverage_verdict (covered / partial / uncovered). With
--dual-level, a page lifted via the citation edge carries a
dual-level: … lead reason so the second-level hit is visible in reasons[].
uncovered (no covering pages) → do not synthesize from nothing. Tell
the user the base has no page covering this question, suggest
knowledge-resume to see what the base holds (or running the research
pipeline / knowledge-ingest-source to add a source), then go straight to
Step 3's footer. This honest-empty report is the shallow rung's contract.covered / partial → continue to Step 2.Read each covering page in data.pages[] order via the Read tool at
<wiki_path>/<page_path>, up to --max-pages (default 12). Then synthesize the
answer in context, following the grounded-research discipline:
[[<slug>]] wikilink to the page it came
from (use the page's slug), so the answer is auditable against the base and
the backlink graph stays intact.type of summary/concept/entity/synthesis/question is
cross-source evidence) over restating one raw source.partial verdict — lead with what the base
confirms, then flag the gap.This is a single pass: rank → read → synthesize. No web search, no claim verification loop (those are the deeper rungs).
Before printing, read the knowledge-base-global fetch-cache health so the footer can show how much evidence the base has cached:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/pipeline-summary.py cache-health \
--knowledge-root <knowledge_root>
Capture entries (cached source count <M>) and unavailable (<U>) from data. On success: false, treat the counts as unknown and drop the fetch-cache clause from the footer rather than aborting — the answer itself is the deliverable.
Print the synthesized answer, then append a single footer line on its own line:
Knowledge base: <knowledge_slug> · <N> deposited projects · fetch-cache: <M> sources cached (<U> unavailable) · /cogni-knowledge:knowledge-resume for status.
<N> is len(research_projects) from the binding; <M>/<U> come from cache-health. The footer reminds the user which base the answer came from, how much evidence the inverted pipeline has cached, and points at the status skill.
--file-back only)Default: skip entirely. When --file-back is absent, this skill is
read-only — it never modifies the binding or the wiki. It reads ranked
pages and synthesizes; the workflow ends at Step 3's footer and writes nothing.
This keeps the per-run no-write invariant intact for autonomous / cron runs.
When --file-back yes is passed, deposit the synthesized answer as a wiki page —
the shallow-rung analog of the deep rung's knowledge-finalize synthesis
deposit, reusing the same vendored write lockstep (no new write path). The
shallow rung runs no verify pass, so the deposit is honestly labeled
un-verified.
Deposit-eligibility gate (operationalized — tie to the observable coverage verdict + cited pages, not to an LLM self-judgement):
uncovered verdict → never deposit (Step 1 already short-circuited to
the footer; there is no grounded answer to file).covered verdict → deposit.partial verdict → deposit only when ≥1 covering page was actually read
in Step 2 AND cited via a [[<slug>]] wikilink in the synthesized answer.
A partial answer that cited no page (the base confirmed nothing concrete) is
not depositable — skip the write and say so. The cited-page set is the
observable signal; it is also the sources: list the deposit records (4.4)
and the backlink target set (4.5.3), so the three stay consistent.4.1 Resolve the vendored write lockstep. Resolve the wiki-ingest script
dir vendored-first, exactly as knowledge-finalize / knowledge-ingest-source
do (the deposit reuses the already-vendored helpers — never a new script):
. "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-wiki-scripts.sh"
WIKI_INGEST_SCRIPTS=$(resolve_wiki_scripts wiki-ingest backlink_audit.py) \
|| { echo "cogni-knowledge's vendored wiki-ingest scripts are missing (reinstall cogni-knowledge) — cannot --file-back"; exit 1; }
WIKI_ROOT is the wiki_path already resolved in Step 0; confirm
<WIKI_ROOT>/wiki/ is writeable before continuing.
4.2 Derive the synthesis slug. Single source of truth —
_knowledge_lib.slugify (the same helper knowledge-finalize uses). Pass the
question via env var (never interpolate untrusted text into a Python literal):
SYNTHESIS_SLUG=$(KNOWLEDGE_SCRIPTS="${CLAUDE_PLUGIN_ROOT}/scripts" \
QUESTION="<question>" \
python3 -c '
import os, sys
sys.path.insert(0, os.environ["KNOWLEDGE_SCRIPTS"])
from _knowledge_lib import slugify
print(slugify(os.environ["QUESTION"]) or "")
')
If --synthesis-slug was passed, use it instead. On an empty result, abort and
ask the user to supply --synthesis-slug. The resolved string must match
[a-z0-9][a-z0-9-]{0,79}.
4.3 Collision guard. If <WIKI_ROOT>/wiki/syntheses/<SYNTHESIS_SLUG>.md
already exists, do not blind-overwrite: abort with a clear message naming
the existing page and offering --overwrite (replace) or --synthesis-slug
(deposit under a new slug). Only proceed past an existing page when --overwrite
was passed.
4.4 Write the synthesis page. Atomically write
<WIKI_ROOT>/wiki/syntheses/<SYNTHESIS_SLUG>.md via
_knowledge_lib.atomic_write_text. The frontmatter labels the deposit
un-verified; the body leads with a visible blockquote so a human reading the
page in Obsidian is never misled:
---
id: <SYNTHESIS_SLUG>
title: <question verbatim>
type: synthesis
tags: [synthesis, knowledge-query]
created: <YYYY-MM-DD UTC>
updated: <YYYY-MM-DD UTC>
sources:
- wiki://<cited-page-slug-1>
- wiki://<cited-page-slug-2>
verification: unverified_shallow_rung
---
> **Un-verified shallow-rung answer.** Filed from `knowledge-query` — grounded
> in the cited wiki pages but **not** claim-verified (the shallow rung runs no
> verify pass). Treat as a convenience capture, not a vetted synthesis.
<the synthesized answer from Step 2, with its bare [[slug]] citations preserved>
sources: lists one wiki://<slug> entry per covering page actually cited
in the answer (the [[<slug>]] wikilinks in the synthesized body — the same set
the deposit-eligibility gate keys on), not every page read in Step 2 — so the
deposit is grounded and de-orphaned without claiming evidence it did not use. The
type: synthesis + knowledge-query tag distinguishes a query-filed-back page
from a knowledge-finalize deposit in the same wiki/syntheses/ directory.
Quote the title: via json.dumps(..., ensure_ascii=False) so a
colon-containing question deposits valid YAML (the knowledge-finalize posture).
created:-preservation on --overwrite. On a fresh deposit, stamp both
created: and updated: to today (UTC). On an --overwrite re-deposit, read
the existing page's created: frontmatter and carry it forward (the page's
birth date is durable), and set only updated: to today — matching the
knowledge-finalize / concept-store.py posture that never clobbers created:
across re-writes. Read the prior created: via the same _knowledge_lib
frontmatter helpers (_FRONTMATTER_RE / _unquote_scalar) before composing the
new page.
4.5 Post-write lockstep (lighter than knowledge-finalize). Run the
vendored index/config/backlink helpers — the same ones knowledge-ingest
Step 4 runs (each acquires and releases its own _wiki_lock internally, so the
calls are sequential and deadlock-free; the synthesis page itself is
unique-by-construction and needs no lock):
_knowledge_lib.sanitize_summary (env-var pattern), then
python3 "$WIKI_INGEST_SCRIPTS/wiki_index_update.py" --wiki-root "$WIKI_ROOT" --slug "$SYNTHESIS_SLUG" --summary "$CLEAN_SUMMARY" --category "Syntheses" --max-summary 240. Capture the envelope; data.action == "inserted" means a
new row landed.--overwrite re-deposit): python3 "$WIKI_INGEST_SCRIPTS/config_bump.py" --wiki-root "$WIKI_ROOT" --key entries_count --delta 1. Non-fatal on failure
(the page is already discoverable; reconcilable via
wiki-lint --fix=entries_count_drift).targets[] plan inserting one
bare [[<SYNTHESIS_SLUG>]] sentence under the ## See also of each cited
page only — the same sources: set written in 4.4 (the pages cited via
[[<slug>]] in the answer), not every page read in Step 2. Backlinking an
uncited-but-read page would over-link the synthesis to evidence it did not
use. Then python3 "$WIKI_INGEST_SCRIPTS/backlink_audit.py" --wiki-root "$WIKI_ROOT" --new-page "$SYNTHESIS_SLUG" --apply-plan -. Fail-soft — a
backlink failure never blocks the deposit; never invent a backlink to an
unrelated page.4.6 Log line. Append one line to <WIKI_ROOT>/wiki/log.md:
## [<YYYY-MM-DD>] synthesis | <SYNTHESIS_SLUG> — <short question> (the same
prefix the deep rung uses), so the deposit is visible in the wiki log.
The binding is not touched — research_projects[] records inverted-pipeline
deposits (from knowledge-finalize), not shallow-rung query answers. After
depositing, add one line to the printed answer noting the page path and that it
was filed un-verified.
research_projects[] is empty and wiki-grounding.py rank returns no covering pages → the uncovered path (Step 1) reports honestly (0 deposited projects in the footer) instead of fabricating.knowledge-compose --source wiki (the deep rung).--file-back deposit (Step 4) is honestly labeled verification: unverified_shallow_rung — the shallow rung runs no claim-alignment pass. A vetted synthesis is the deep rung's knowledge-finalize deposit, not this one.--file-back auto (prompt-to-deposit) and multi-question deposits — a future enhancement; today --file-back is the explicit yes/absent opt-in only.[[slug]]-cited answer grounded in the ranked wiki pages.Knowledge base: <slug> · <N> deposited projects · ...By default no files are written (read-only). When --file-back yes is
passed, the answer is additionally deposited as
<wiki>/syntheses/<slug>.md (type: synthesis, verification: unverified_shallow_rung) with the index row, entries_count bump, backlinks,
and a wiki/log.md line (Step 4).
${CLAUDE_PLUGIN_ROOT}/references/differentiation-thesis.md — the accumulation thesis the shallow rung serves${CLAUDE_PLUGIN_ROOT}/scripts/wiki-grounding.py — the shared rank discovery primitive (index-first page selection)${CLAUDE_PLUGIN_ROOT}/scripts/knowledge-binding.py --help${CLAUDE_PLUGIN_ROOT}/scripts/pipeline-summary.py cache-health --help — fetch-cache health for the footer${CLAUDE_PLUGIN_ROOT}/scripts/vendor/cogni-wiki/skills/wiki-ingest/scripts/ — the vendored wiki_index_update.py / config_bump.py / backlink_audit.py write lockstep the --file-back deposit (Step 4) reuses${CLAUDE_PLUGIN_ROOT}/skills/knowledge-finalize/SKILL.md — the deep-rung synthesis deposit the shallow-rung --file-back mirrors (verified vs un-verified)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
knowledge-base, wiki-query, grounded-answer, cogni-knowledge
npx claudepluginhub cogni-work/insight-wave --plugin cogni-knowledge21 skills in this plugin
/knowledge-composePhase 5 of the inverted pipeline. Reads <project>/.metadata/plan.json + <project>/.metadata/ingest-manifest.json + the populated cogni-wiki, dispatches a wiki-composer pass (plus ONE bounded fail-soft zero-network coverage-gated re-dispatch when a sub-question has ingested evidence the draft left uncited), and lands <project>/output/draft-vN.md + <project>/.metadata/citation-manifest.json. Supports --source wiki to compose a report grounded only in the bound wiki + fetch-cache with no web crawl (default web unchanged; local/hybrid staged). Use this skill whenever the user says 'compose the draft', 'write the report from the wiki', 'wiki-only report', 'compose from the wiki only', 'no web crawl report', 'phase 5 of the knowledge pipeline', 'knowledge compose', 'draft v1', or 'run the writer'. After compose, knowledge-verify will run the zero-network claim alignment./knowledge-curatePhase 2 of the inverted pipeline. Reads plan.json, dispatches one source-curator agent per sub-question to WebSearch + score candidate sources AND fetch each survivor's body via WebFetch into the shared fetch-cache, then merges the per-sub-question batches into candidates.json via candidate-store.py. Each candidate carries a fetch sub-object. Use this skill whenever the user says 'curate sources for the eu-ai-act plan', 'discover candidates for project X', 'run the curators on plan.json', 'knowledge curate', 'phase 2 of the knowledge pipeline'. After curate, run knowledge-fetch (cobrowse reconcile; a near no-op unless --cobrowse)./knowledge-dashboardRender an HTML dashboard for a bound cogni-knowledge base — runs the vendored wiki-dashboard scripts (render_dashboard.py + build_graph.py) natively against the bound wiki and writes a knowledge-overlay.md sidecar that lists deposited research projects and the latest lint-audit claim_drift count. Use this skill whenever the user says 'show the dashboard for my <slug> base', 'knowledge dashboard', 'visualize my eu-ai-act knowledge base', 'render the knowledge base as HTML', 'knowledge-dashboard <slug>'. The sidecar makes the binding's contribution visible alongside the wiki's own dashboard./knowledge-distillPhase 4.5 of the inverted pipeline (between ingest and compose). Distills the run's source claims into recurring type:concept / type:entity / type:person pages, creating-or-merging them under a lock with claim-level dedup so the bound wiki compounds across runs (distilled pages get enriched, not duplicated). Also synthesizes a citable answer_claims: surface onto each type:question node from its findings' claims (Step 6.1). An optional cross-lingual pass merges DE↔EN twin claims on mixed-language bases (auto-skips otherwise). Fail-soft and optional: a distill failure never blocks compose. Use this skill whenever the user says 'distill the concepts', 'build the concept web', 'phase 4.5', 'knowledge distill', 'extract entities and concepts', 'answer the question nodes', or 'dedupe claims'. After distill, knowledge-compose reads the distilled pages as framing context./knowledge-fetchPhase 3 of the inverted pipeline. Builds fetch-manifest.json from the fetch results the curators already produced in Phase 2 (bodies are already fetched during curate). Cobrowse is OPT-IN (--cobrowse): the skill walks the user through enabling the Claude-in-Chrome extension, then dispatches source-fetcher sequentially to recover WebFetch misses AND to additively top up thin primary-tier sources (reading the fuller browser body beyond WebFetch's cap, superseding only if strictly longer). Use this skill whenever the user says 'fetch candidates for project X', 'build the fetch manifest', 'phase 3 of the knowledge pipeline', 'recover the failed sources', 'deepen the primary sources', 'knowledge fetch'. After fetch, run knowledge-ingest to deposit per-URL wiki pages./knowledge-finalizePhase 7 of the inverted pipeline — deposits the verified draft as a wiki synthesis page, closing the compounding loop. Reads the latest verified draft plus its verify and citation manifests, refuses self-citing loops, atomically writes the synthesis page into the bound wiki, updates the surrounding index, log, and binding state, then runs a fail-soft conformance gate plus advisory contradiction and structural-quality passes. The deposited synthesis becomes visible to future knowledge-compose runs as cross-source framing. Use this skill whenever the user says 'finalize the draft', 'deposit the synthesis', 'phase 7 of the knowledge pipeline', 'knowledge finalize', or 'land the verified draft'.Other plugins' skills for the same job