| name | wiki_ask |
| description | Chat with the knowledge base. Answers user questions by dynamically employing RAG context extraction, graph database queries, and targeted keyword searches to provide cited, hallucination-free answers. |
| commands | {"ask":"Answer a user question based strictly on the contents of the knowledge base."} |
LLM Wiki — Knowledge Base Q&A Skill (wiki_ask)
Resolving script paths (read first): Commands below invoke scripts as <BIN>/X.py (and a few as <SKILLS>/...). Resolve these to absolute paths once before running anything:
<SKILL_DIR> = the directory this SKILL.md lives in.
<SKILLS> = the skills/ folder containing this skill = <SKILL_DIR>/..
<BIN> = the bin/ folder beside it = <SKILL_DIR>/../../bin
Do not hardcode a fixed prefix like .agents/bin or ../bin: shell relative paths resolve against the current working directory (usually the topic root), not this skill's location. Once resolved, <BIN> is typically .agents/bin when invoked from the hub root, or .claude/bin from inside a topic directory.
This skill transforms the agent into a conversational interface for the knowledge base. When the user asks a question, you must intelligently deploy a combination of deterministic search tools to retrieve context and provide a highly rigorous, cited answer.
Tooling (framework-agnostic): This skill is written tool-agnostic. Where it says file-read tool, use your agent's equivalent (Read in Claude Code, view_file in Antigravity, cat/open elsewhere). Shell commands run via Bash/PowerShell (Claude Code) or your framework's shell tool.
Core Rule: Zero Hallucination
CRITICAL INSTRUCTION: Do NOT answer questions using your parametric memory. Every factual claim or summary you provide MUST be grounded in the local knowledge base and explicitly cited using Obsidian wikilinks (e.g., [[Concept Name]] or [[Paper Title]]).
Execution Flow
When tasked with answering a question, follow these strategies depending on the nature of the inquiry:
Strategy 1: Concept Extraction (RAG)
If the user asks about the definition, lineage, or application of a specific concept (e.g., "What is Haag Duality?"):
- Run the context extractor script:
python <BIN>/extract_concept_context.py --name "Target Concept" --topic-dir "<TOPIC_DIR>"
- Read the resulting
scratch/concept_context_<slug>.md file with your file-read tool.
- Synthesize your answer directly from this condensed RAG context, citing the sources listed in the context file.
Strategy 2: Graph Traversal
If the user asks broad survey questions or inquiries about relationships (e.g., "What papers discuss quantum error correction?"):
- Query the local SQLite graph database using:
python <BIN>/query-graph.py "<SQL>"
- Graph DB Schema (MANDATORY): Do not guess table names. Use only this schema:
nodes(id TEXT PRIMARY KEY, path TEXT, title TEXT, type TEXT, category TEXT, summary TEXT, created TEXT, updated TEXT)
edges(source_id TEXT, target_id TEXT, type TEXT)
tags(node_id TEXT, tag TEXT)
aliases(node_id TEXT, alias TEXT)
- NOTE on
type: every node has a non-empty type — taken from frontmatter when present (papers use type='papers'), otherwise derived from the containing folder (concept, reference, thesis, topic). category is the broader bucket (concept/reference/topic). You can filter by either column.
- Example Queries:
SELECT title, summary FROM nodes WHERE type='papers' AND id IN (SELECT node_id FROM tags WHERE tag='quantum-error-correction')
SELECT title, summary FROM nodes WHERE type='concept' AND id IN (SELECT node_id FROM tags WHERE tag='duality')
SELECT n.title, e.type FROM nodes n JOIN edges e ON n.id = e.target_id WHERE e.source_id = 'some-concept-id'
Strategy 3: Targeted Search
If the user asks highly specific, detail-oriented questions requiring deep dives into math or specific mechanisms:
- First, use Strategy 2 to narrow down the relevant files.
- Run the targeted search script:
python <BIN>/search-wiki.py "<regex>" <files...>
- Read the most promising returned files with your file-read tool.
Strategy 4: Path Finding & Multi-Hop Reasoning
If the user asks about the connection or path between two distinct concepts (e.g., "How is Concept A connected to Concept B?"):
- Query the local SQLite graph database using a
WITH RECURSIVE SQL query to find paths up to 3 hops.
- Example Path-Finding Query:
python <BIN>/query-graph.py "WITH RECURSIVE undirected_edges(node1, node2) AS (SELECT source_id, target_id FROM edges UNION SELECT target_id, source_id FROM edges), path_search(current_node, path, depth) AS (SELECT 'node-A-id', 'node-A-id', 0 UNION ALL SELECT u.node2, p.path || ' -> ' || u.node2, p.depth + 1 FROM undirected_edges u JOIN path_search p ON u.node1 = p.current_node WHERE p.depth < 3 AND p.path NOT LIKE '%' || u.node2 || '%') SELECT path FROM path_search WHERE current_node = 'node-B-id' LIMIT 5"
- Analyze the returned path and read the intermediate concepts if needed to explain why they are connected.
Synthesizing the Final Answer
Once you have gathered sufficient context using the strategies above:
- Draft a clear, conversational response.
- Ensure every major claim is immediately followed by its source: "As demonstrated in [[2023-06-12-graph_gauge_theory]], the mechanism..."
- If you cannot find the answer using these tools, explicitly state: "I could not find information regarding this in the current knowledge base." Do not attempt to fill in the blanks with external knowledge.
Error Handling
- If any script exits with non-zero code, report the full stderr output to the user and stop.
- If a file cannot be read or parsed, log a warning and continue with remaining files.
- Do NOT silently skip errors or proceed with partial results without reporting.