/ask
Ask a question to the wiki knowledge base. The LLM reads context_brief.md for global context,
retrieves relevant pages, synthesizes an answer with citations. Good answers can be
crystallized back into the wiki — written to outputs/ or as new concept/claim pages —
so exploration compounds like ingestion does.
Inputs
question: natural-language question (e.g. "What is the core difference between LoRA and Adapter?")
--crystallize (optional): if specified, crystallize the answer back into the wiki (default: answer only, no write)
--format (optional): output format, default markdown, options: table / timeline / bullets
Outputs
- Always: terminal output of synthesized answer (with
[[slug]] citations)
- If crystallize:
wiki/outputs/{query-slug}.md — query result page (default crystallize target)
- or
wiki/concepts/{slug}.md — if the answer reveals a new cross-paper concept
- or
wiki/claims/{slug}.md — if the answer surfaces a new verifiable assertion
- updated
wiki/graph/edges.jsonl (relationships produced by crystallize)
- updated
wiki/index.md and wiki/log.md
Wiki Interaction
Reads
wiki/graph/context_brief.md — global compressed context (claims, gaps, failed ideas, papers, edges)
wiki/index.md — page catalog for locating relevant pages
wiki/graph/open_questions.md — open questions, helps identify whether the question touches known gaps
wiki/papers/*.md — paper pages relevant to the question
wiki/concepts/*.md — concept pages relevant to the question
wiki/claims/*.md — claim pages relevant to the question
wiki/topics/*.md — topic pages relevant to the question
wiki/people/*.md — if the question involves specific researchers
wiki/ideas/*.md — if the question involves research ideas or failed ideas
wiki/experiments/*.md — if the question involves experiment results
wiki/Summary/*.md — if the question involves domain-wide landscape
Writes (crystallize mode only)
wiki/outputs/{query-slug}.md — CREATE (query result page)
wiki/concepts/{slug}.md — CREATE (newly discovered concept) or EDIT (supplement existing concept)
wiki/claims/{slug}.md — CREATE (newly discovered assertion) or EDIT (add evidence)
wiki/graph/edges.jsonl — APPEND (relationships produced by crystallize)
wiki/graph/context_brief.md — REBUILD (if crystallize created new pages)
wiki/graph/open_questions.md — REBUILD (if crystallize created new pages)
wiki/index.md — EDIT (if crystallize created new pages)
wiki/log.md — APPEND
Graph edges created (crystallize only)
output → paper: derived_from (papers cited in the answer)
output → concept: derived_from (concepts cited in the answer)
output → claim: derived_from (claims cited in the answer)
concept → paper: supports (if a new concept is generalized from papers)
claim → paper: supports (if a new claim is extracted from papers)
Workflow
Precondition: confirm working directory is the wiki project root (containing wiki/, raw/, tools/).
Set WIKI_ROOT=wiki/.
Step 1: Load Global Context
- Read
wiki/graph/context_brief.md — get compressed snapshot of wiki's current knowledge (claims, gaps, papers, edges)
- Read
wiki/graph/open_questions.md — understand known open questions and knowledge gaps
- If both are missing, rebuild first:
python3 tools/research_wiki.py rebuild-context-brief wiki/
python3 tools/research_wiki.py rebuild-open-questions wiki/
Step 2: Retrieve Relevant Pages
- Read
wiki/index.md, match relevant slugs against question keywords
- Extract claims and papers semantically related to the question from context_brief.md
- Sort by relevance, select top-K pages (K ≤ 15 to avoid exceeding context window)
- Read full content of selected pages
- If the question involves relationships (e.g. "difference between X and Y"), additionally read edges connecting X and Y from
wiki/graph/edges.jsonl
Step 3: Synthesize Answer
- Synthesize an answer to the user's question based on collected page content
- Answer requirements:
- Cited: every key claim must include a
[[slug]] wikilink pointing to its source page
- Structured: organize output according to
--format parameter (markdown / table / timeline / bullets)
- Acknowledge uncertainty: clearly flag "insufficient evidence in wiki" for parts with weak support
- Flag knowledge gaps: if the question touches a known gap in open_questions.md, call it out explicitly
- Cite claim confidence: when referencing claims, note their confidence and status
- If the question exceeds the wiki's current knowledge, honestly say so and suggest:
- which papers to ingest to fill the gap
- possible search directions (arXiv keywords, Semantic Scholar queries)
Step 4: Assess Crystallize Value
- Judge whether the answer is worth writing back to the wiki (make a recommendation even if
--crystallize was not specified)
- Signals that crystallize is worthwhile:
- The answer synthesizes information from multiple papers, forming a new cross-paper insight
- The answer reveals a concept not yet explicitly recorded in the wiki
- The answer surfaces a new verifiable assertion (claim)
- The answer addresses a known gap in open_questions.md
- Signals that crystallize is not worthwhile:
- The answer merely restates the content of a single page
- The question is a simple factual lookup (e.g. "What year was LoRA published?")
- The answer relies primarily on inference rather than wiki evidence
- Append a crystallize recommendation at the end of the answer:
💡 Crystallize recommendation: [worthwhile / not needed] — [reason]
Step 5: Crystallize Back to Wiki (if user confirms or --crystallize was specified)
Choose the crystallize target based on answer content:
Case A — Write to outputs/ (default):
- Generate slug:
python3 tools/research_wiki.py slug "<query-summary>"
- Create
wiki/outputs/{query-slug}.md:---
title: ""
slug: ""
query: "" # original question
source_pages: [] # slugs of all pages cited in the answer
date_created: YYYY-MM-DD
---
Body is the answer content (preserve wikilinks)
- Add a graph edge for each cited source page:
python3 tools/research_wiki.py add-edge wiki/ --from outputs/<slug> --to papers/<source-slug> --type derived_from --evidence "query answer"
Case B — Create new concept:
- If the answer reveals a new concept: create
wiki/concepts/{slug}.md using the CLAUDE.md concept template
- maturity: emerging
- key_papers: extracted from answer citations
- Add graph edges (concept → papers)
- Append reverse links to relevant paper pages under
## Related
Case C — Create new claim:
- If the answer surfaces a new assertion: create
wiki/claims/{slug}.md using the CLAUDE.md claim template
- status: proposed (synthesized from query, not direct experimental evidence)
- confidence: set initial value based on strength of cited evidence
- source_papers: extracted from answer citations
- Add graph edges (claim → papers)
- Append reverse links to relevant paper pages under
## Related
Step 6: Update Navigation and Graph (crystallize only)
- index.md: append new page entries under the appropriate category
- log.md:
python3 tools/research_wiki.py log wiki/ "ask | <question-summary> | crystallized: <target-path>"
If not crystallized:python3 tools/research_wiki.py log wiki/ "ask | <question-summary> | answer-only"
- Rebuild derived graph files (only if crystallize created new pages):
python3 tools/research_wiki.py rebuild-context-brief wiki/
python3 tools/research_wiki.py rebuild-open-questions wiki/
Step 7: Report to User
Output a summary including:
- Number and list of retrieved pages
- Answer (with citations and formatting)
- Knowledge gap annotations (if any)
- Crystallize recommendation or execution result
- Follow-up suggestions (papers recommended for ingestion, related open questions)
Constraints
- No fabrication: answers must be grounded in actual wiki content; do not invent from LLM pre-training knowledge
- Citations must exist: every
[[slug]] must point to a page that actually exists in the wiki
- raw/ is read-only: do not modify files under
raw/
- graph/ only via tools: do not hand-edit files under
graph/
- Crystallize requires confirmation: unless the user explicitly specifies
--crystallize, only recommend but do not write
- Context limit: retrieve at most 15 pages to stay within context window
- Cite claim confidence: when referencing claims, always note their confidence value and status
- Flag gaps: if the question touches a known gap in open_questions.md, explicitly call it out
- outputs/ frontmatter must include query and source_pages: ensures traceability
Error Handling
- context_brief.md missing: run
python3 tools/research_wiki.py rebuild-context-brief wiki/ to rebuild, then retry
- wiki is empty: inform the user to first run
/init or /ingest to build the knowledge base
- no matching pages: honestly report that no relevant content exists in the wiki, suggest search and ingest directions
- crystallize slug conflict: append a numeric suffix (e.g.
query-result-2)
- index.md missing: run
python3 tools/research_wiki.py init wiki/ to initialize, then retry
Dependencies
Tools(via Bash)
python3 tools/research_wiki.py slug "<title>" — slug generation
python3 tools/research_wiki.py add-edge wiki/ --from <id> --to <id> --type <type> --evidence "<text>" — add graph edge
python3 tools/research_wiki.py rebuild-context-brief wiki/ — rebuild compressed context
python3 tools/research_wiki.py rebuild-open-questions wiki/ — rebuild knowledge gap map
python3 tools/research_wiki.py log wiki/ "<message>" — append log entry
python3 tools/research_wiki.py init wiki/ — initialize wiki (fallback)
Skills(via Skill tool)
/ingest — referenced when suggesting the user supplement knowledge
Shared References
.claude/skills/shared-references/citation-verification.md (created in Phase 3)
1---2name: ask3description: Ask the wiki a question, retrieve and synthesize relevant pages, optionally crystallize the answer back into the wiki4---56# /ask78> Ask a question to the wiki knowledge base. The LLM reads context_brief.md for global context,9> retrieves relevant pages, synthesizes an answer with citations. Good answers can be10> crystallized back into the wiki — written to outputs/ or as new concept/claim pages —11> so exploration compounds like ingestion does.1213## Inputs1415- `question`: natural-language question (e.g. "What is the core difference between LoRA and Adapter?")16- `--crystallize` (optional): if specified, crystallize the answer back into the wiki (default: answer only, no write)17- `--format` (optional): output format, default `markdown`, options: `table` / `timeline` / `bullets`1819## Outputs2021- **Always**: terminal output of synthesized answer (with `[[slug]]` citations)22- **If crystallize**:23 - `wiki/outputs/{query-slug}.md` — query result page (default crystallize target)24 - or `wiki/concepts/{slug}.md` — if the answer reveals a new cross-paper concept25 - or `wiki/claims/{slug}.md` — if the answer surfaces a new verifiable assertion26 - updated `wiki/graph/edges.jsonl` (relationships produced by crystallize)27 - updated `wiki/index.md` and `wiki/log.md`2829## Wiki Interaction3031### Reads32- `wiki/graph/context_brief.md` — global compressed context (claims, gaps, failed ideas, papers, edges)33- `wiki/index.md` — page catalog for locating relevant pages34- `wiki/graph/open_questions.md` — open questions, helps identify whether the question touches known gaps35- `wiki/papers/*.md` — paper pages relevant to the question36- `wiki/concepts/*.md` — concept pages relevant to the question37- `wiki/claims/*.md` — claim pages relevant to the question38- `wiki/topics/*.md` — topic pages relevant to the question39- `wiki/people/*.md` — if the question involves specific researchers40- `wiki/ideas/*.md` — if the question involves research ideas or failed ideas41- `wiki/experiments/*.md` — if the question involves experiment results42- `wiki/Summary/*.md` — if the question involves domain-wide landscape4344### Writes (crystallize mode only)45- `wiki/outputs/{query-slug}.md` — CREATE (query result page)46- `wiki/concepts/{slug}.md` — CREATE (newly discovered concept) or EDIT (supplement existing concept)47- `wiki/claims/{slug}.md` — CREATE (newly discovered assertion) or EDIT (add evidence)48- `wiki/graph/edges.jsonl` — APPEND (relationships produced by crystallize)49- `wiki/graph/context_brief.md` — REBUILD (if crystallize created new pages)50- `wiki/graph/open_questions.md` — REBUILD (if crystallize created new pages)51- `wiki/index.md` — EDIT (if crystallize created new pages)52- `wiki/log.md` — APPEND5354### Graph edges created (crystallize only)55- `output → paper`: `derived_from` (papers cited in the answer)56- `output → concept`: `derived_from` (concepts cited in the answer)57- `output → claim`: `derived_from` (claims cited in the answer)58- `concept → paper`: `supports` (if a new concept is generalized from papers)59- `claim → paper`: `supports` (if a new claim is extracted from papers)6061## Workflow6263**Precondition**: confirm working directory is the wiki project root (containing `wiki/`, `raw/`, `tools/`).64Set `WIKI_ROOT=wiki/`.6566### Step 1: Load Global Context67681. Read `wiki/graph/context_brief.md` — get compressed snapshot of wiki's current knowledge (claims, gaps, papers, edges)692. Read `wiki/graph/open_questions.md` — understand known open questions and knowledge gaps703. If both are missing, rebuild first:71 ```bash72 python3 tools/research_wiki.py rebuild-context-brief wiki/73 python3 tools/research_wiki.py rebuild-open-questions wiki/74 ```7576### Step 2: Retrieve Relevant Pages77781. Read `wiki/index.md`, match relevant slugs against question keywords792. Extract claims and papers semantically related to the question from context_brief.md803. Sort by relevance, select top-K pages (K ≤ 15 to avoid exceeding context window)814. Read full content of selected pages825. If the question involves relationships (e.g. "difference between X and Y"), additionally read edges connecting X and Y from `wiki/graph/edges.jsonl`8384### Step 3: Synthesize Answer85861. Synthesize an answer to the user's question based on collected page content872. Answer requirements:88 - **Cited**: every key claim must include a `[[slug]]` wikilink pointing to its source page89 - **Structured**: organize output according to `--format` parameter (markdown / table / timeline / bullets)90 - **Acknowledge uncertainty**: clearly flag "insufficient evidence in wiki" for parts with weak support91 - **Flag knowledge gaps**: if the question touches a known gap in open_questions.md, call it out explicitly92 - **Cite claim confidence**: when referencing claims, note their confidence and status933. If the question exceeds the wiki's current knowledge, honestly say so and suggest:94 - which papers to ingest to fill the gap95 - possible search directions (arXiv keywords, Semantic Scholar queries)9697### Step 4: Assess Crystallize Value98991. Judge whether the answer is worth writing back to the wiki (make a recommendation even if `--crystallize` was not specified)1002. Signals that crystallize is worthwhile:101 - The answer synthesizes information from multiple papers, forming a new cross-paper insight102 - The answer reveals a concept not yet explicitly recorded in the wiki103 - The answer surfaces a new verifiable assertion (claim)104 - The answer addresses a known gap in open_questions.md1053. Signals that crystallize is not worthwhile:106 - The answer merely restates the content of a single page107 - The question is a simple factual lookup (e.g. "What year was LoRA published?")108 - The answer relies primarily on inference rather than wiki evidence1094. Append a crystallize recommendation at the end of the answer:110 ```111 💡 Crystallize recommendation: [worthwhile / not needed] — [reason]112 ```113114### Step 5: Crystallize Back to Wiki (if user confirms or --crystallize was specified)115116Choose the crystallize target based on answer content:117118**Case A — Write to outputs/ (default):**1191. Generate slug: `python3 tools/research_wiki.py slug "<query-summary>"`1202. Create `wiki/outputs/{query-slug}.md`:121 ```yaml122 ---123 title: ""124 slug: ""125 query: "" # original question126 source_pages: [] # slugs of all pages cited in the answer127 date_created: YYYY-MM-DD128 ---129 ```130 Body is the answer content (preserve wikilinks)1313. Add a graph edge for each cited source page:132 ```bash133 python3 tools/research_wiki.py add-edge wiki/ --from outputs/<slug> --to papers/<source-slug> --type derived_from --evidence "query answer"134 ```135136**Case B — Create new concept:**1371. If the answer reveals a new concept: create `wiki/concepts/{slug}.md` using the CLAUDE.md concept template1382. maturity: emerging1393. key_papers: extracted from answer citations1404. Add graph edges (concept → papers)1415. Append reverse links to relevant paper pages under `## Related`142143**Case C — Create new claim:**1441. If the answer surfaces a new assertion: create `wiki/claims/{slug}.md` using the CLAUDE.md claim template1452. status: proposed (synthesized from query, not direct experimental evidence)1463. confidence: set initial value based on strength of cited evidence1474. source_papers: extracted from answer citations1485. Add graph edges (claim → papers)1496. Append reverse links to relevant paper pages under `## Related`150151### Step 6: Update Navigation and Graph (crystallize only)1521531. **index.md**: append new page entries under the appropriate category1542. **log.md**:155 ```bash156 python3 tools/research_wiki.py log wiki/ "ask | <question-summary> | crystallized: <target-path>"157 ```158 If not crystallized:159 ```bash160 python3 tools/research_wiki.py log wiki/ "ask | <question-summary> | answer-only"161 ```1623. **Rebuild derived graph files** (only if crystallize created new pages):163 ```bash164 python3 tools/research_wiki.py rebuild-context-brief wiki/165 python3 tools/research_wiki.py rebuild-open-questions wiki/166 ```167168### Step 7: Report to User169170Output a summary including:171- Number and list of retrieved pages172- Answer (with citations and formatting)173- Knowledge gap annotations (if any)174- Crystallize recommendation or execution result175- Follow-up suggestions (papers recommended for ingestion, related open questions)176177## Constraints178179- **No fabrication**: answers must be grounded in actual wiki content; do not invent from LLM pre-training knowledge180- **Citations must exist**: every `[[slug]]` must point to a page that actually exists in the wiki181- **raw/ is read-only**: do not modify files under `raw/`182- **graph/ only via tools**: do not hand-edit files under `graph/`183- **Crystallize requires confirmation**: unless the user explicitly specifies `--crystallize`, only recommend but do not write184- **Context limit**: retrieve at most 15 pages to stay within context window185- **Cite claim confidence**: when referencing claims, always note their confidence value and status186- **Flag gaps**: if the question touches a known gap in open_questions.md, explicitly call it out187- **outputs/ frontmatter must include query and source_pages**: ensures traceability188189## Error Handling190191- **context_brief.md missing**: run `python3 tools/research_wiki.py rebuild-context-brief wiki/` to rebuild, then retry192- **wiki is empty**: inform the user to first run `/init` or `/ingest` to build the knowledge base193- **no matching pages**: honestly report that no relevant content exists in the wiki, suggest search and ingest directions194- **crystallize slug conflict**: append a numeric suffix (e.g. `query-result-2`)195- **index.md missing**: run `python3 tools/research_wiki.py init wiki/` to initialize, then retry196197## Dependencies198199### Tools(via Bash)200- `python3 tools/research_wiki.py slug "<title>"` — slug generation201- `python3 tools/research_wiki.py add-edge wiki/ --from <id> --to <id> --type <type> --evidence "<text>"` — add graph edge202- `python3 tools/research_wiki.py rebuild-context-brief wiki/` — rebuild compressed context203- `python3 tools/research_wiki.py rebuild-open-questions wiki/` — rebuild knowledge gap map204- `python3 tools/research_wiki.py log wiki/ "<message>"` — append log entry205- `python3 tools/research_wiki.py init wiki/` — initialize wiki (fallback)206207### Skills(via Skill tool)208- `/ingest` — referenced when suggesting the user supplement knowledge209210### Shared References211- `.claude/skills/shared-references/citation-verification.md` (created in Phase 3)