Query Skill
Answer questions using the brain's knowledge with 3-layer search and synthesis.
Contract
This skill guarantees:
- Every answer is grounded in brain content (no hallucination)
- Every claim has a citation tracing back to a specific page slug
- Gaps are flagged explicitly ("the brain doesn't have information on X")
- Source precedence is respected (user statements > compiled truth > timeline > external)
- Conflicting sources are noted with both citations
Phases
- Decompose the question into search strategies:
- Keyword search for specific names, dates, terms
- Semantic query for conceptual questions
- Structured queries (list by type, backlinks) for relational questions
- Execute searches:
- Keyword search gbrain for FTS matches (search)
- Hybrid search gbrain for semantic+keyword with expansion (query)
- List pages in gbrain by type or check backlinks for structural queries
- Read top results. Read the top 3-5 pages from gbrain to get full context.
- Synthesize answer with citations. Every claim traces back to a specific page slug.
- Flag gaps. If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating.
Anti-Patterns
- Answering from general knowledge when the brain has relevant content
- Hallucinating facts not in the brain
- Silently picking one source when sources conflict
- Loading full pages when search chunks are sufficient
- Ignoring source precedence (user statements are highest authority)
Output Format
Answers should include:
- Direct response to the question
- Citations: "According to [Source: people/jane-doe, compiled truth]..."
- Gap flags: "The brain doesn't have information on X"
- Conflict notes when sources disagree
Quality Rules
- Never hallucinate. Only answer from brain content.
- Cite sources: "According to concepts/do-things-that-dont-scale..."
- Flag stale results: if a search result shows [STALE], note that the info may be outdated
- For "who" questions, use backlinks and typed links to find connections
- For "what happened" questions, use timeline entries
- For "what do we know" questions, read compiled_truth directly
Token-Budget Awareness
Search returns chunks, not full pages. Read the excerpts first before deciding
whether to load a full page.
gbrain search / gbrain query return ranked chunks with context snippets.
These are often enough to answer the question directly.
- Only use
gbrain get <slug> to load the full page when a chunk confirms the
page is relevant and you need more context (e.g., compiled truth, timeline).
- "Tell me about X" -- get the full page (the user wants the complete picture).
- "Did anyone mention Y?" -- search results are enough (the user wants a yes/no with evidence).
Source precedence
When multiple sources provide conflicting information, follow this precedence:
- User's direct statements (highest authority -- what the user told you directly)
- Compiled truth (the brain's synthesized, cited understanding)
- Timeline entries (raw evidence, reverse-chronological)
- External sources (web search, API enrichment -- lowest authority)
When sources conflict, note the contradiction with both citations. Don't silently
pick one.
Citation in Answers
When referencing brain pages in your answer, propagate inline citations:
- Cite the page: "According to [Source: people/jane-doe, compiled truth]..."
- When brain pages have inline
[Source: ...] citations, propagate them so
the user can trace facts to their origin
- When you synthesize across multiple pages, cite all sources
Graph Traversal (v0.10.1+)
For relationship questions ("who knows who at X?", "connections between A and B",
"who works at Acme?", "who attended the standup?"), use the graph layer instead
of full-text search:
gbrain graph-query <slug> --type <link_type> --depth N --direction in|out|both
- Available link types:
attended, works_at, invested_in, founded, advises, mentions, source
--direction in answers "who points to X?" (e.g., who works at company X)
--direction out answers "what does X point to?" (default)
--depth N controls multi-hop traversal (default 5)
Examples:
- "Who works at Acme?" →
gbrain graph-query companies/acme --type works_at --direction in
- "Who attended Demo Day W26?" →
gbrain graph-query meetings/demo-day-w26 --type attended --direction out
- "What companies has Emily advised?" →
gbrain graph-query people/emily --type advises --direction out
- "Who has Alice met (via meetings)?" →
gbrain graph-query people/alice --type attended --depth 2
Combine with gbrain query for queries that need BOTH semantic similarity AND
graph structure. Search results are ranked with a small backlink boost so well-
connected entities surface higher.
Search Quality Awareness
If search results seem off (wrong results, missing known pages, irrelevant hits):
- Run
gbrain doctor --json to check index health
- Check embedding coverage -- partial embeddings degrade hybrid search
- Compare keyword search (
gbrain search) vs hybrid search (gbrain query)
for the same query to isolate whether the issue is embedding-related
- Report search quality issues in the maintain workflow (see maintain skill)
Tools Used
- Keyword search gbrain (search)
- Hybrid search gbrain (query)
- Read a page from gbrain (get_page)
- List pages in gbrain with filters (list_pages)
- Check backlinks in gbrain (get_backlinks)
- Traverse the link graph in gbrain (traverse_graph)
- View timeline entries in gbrain (get_timeline)
Source: garrytan/gbrain → skills/query/SKILL.md
1---2name: query3description: | Answer questions using the brain's knowledge with 3-layer search, synthesis, and citation propagation. Use when the user asks a question, wants a lookup, or needs information from the brain.4---5
6
7# Query Skill
8
9Answer questions using the brain's knowledge with 3-layer search and synthesis.
10
11## Contract
12
13This skill guarantees:
14- Every answer is grounded in brain content (no hallucination)
15- Every claim has a citation tracing back to a specific page slug
16- Gaps are flagged explicitly ("the brain doesn't have information on X")
17- Source precedence is respected (user statements > compiled truth > timeline > external)
18- Conflicting sources are noted with both citations
19
20## Phases
21
221. **Decompose the question** into search strategies:
23 - Keyword search for specific names, dates, terms
24 - Semantic query for conceptual questions
25 - Structured queries (list by type, backlinks) for relational questions
262. **Execute searches:**
27 - Keyword search gbrain for FTS matches (search)
28 - Hybrid search gbrain for semantic+keyword with expansion (query)
29 - List pages in gbrain by type or check backlinks for structural queries
303. **Read top results.** Read the top 3-5 pages from gbrain to get full context.
314. **Synthesize answer** with citations. Every claim traces back to a specific page slug.
325. **Flag gaps.** If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating.
33
34## Anti-Patterns
35
36- Answering from general knowledge when the brain has relevant content
37- Hallucinating facts not in the brain
38- Silently picking one source when sources conflict
39- Loading full pages when search chunks are sufficient
40- Ignoring source precedence (user statements are highest authority)
41
42## Output Format
43
44Answers should include:
45- Direct response to the question
46- Citations: "According to [Source: people/jane-doe, compiled truth]..."
47- Gap flags: "The brain doesn't have information on X"
48- Conflict notes when sources disagree
49
50## Quality Rules
51
52- Never hallucinate. Only answer from brain content.
53- Cite sources: "According to concepts/do-things-that-dont-scale..."
54- Flag stale results: if a search result shows [STALE], note that the info may be outdated
55- For "who" questions, use backlinks and typed links to find connections
56- For "what happened" questions, use timeline entries
57- For "what do we know" questions, read compiled_truth directly
58
59## Token-Budget Awareness
60
61Search returns **chunks**, not full pages. Read the excerpts first before deciding
62whether to load a full page.
63
64- `gbrain search` / `gbrain query` return ranked chunks with context snippets.
65 These are often enough to answer the question directly.
66- Only use `gbrain get <slug>` to load the full page when a chunk confirms the
67 page is relevant and you need more context (e.g., compiled truth, timeline).
68- **"Tell me about X"** -- get the full page (the user wants the complete picture).
69- **"Did anyone mention Y?"** -- search results are enough (the user wants a yes/no with evidence).
70
71### Source precedence
72
73When multiple sources provide conflicting information, follow this precedence:
74
751. **User's direct statements** (highest authority -- what the user told you directly)
762. **Compiled truth** (the brain's synthesized, cited understanding)
773. **Timeline entries** (raw evidence, reverse-chronological)
784. **External sources** (web search, API enrichment -- lowest authority)
79
80When sources conflict, note the contradiction with both citations. Don't silently
81pick one.
82
83## Citation in Answers
84
85When referencing brain pages in your answer, propagate inline citations:
86- Cite the page: "According to [Source: people/jane-doe, compiled truth]..."
87- When brain pages have inline `[Source: ...]` citations, propagate them so
88 the user can trace facts to their origin
89- When you synthesize across multiple pages, cite all sources
90
91## Graph Traversal (v0.10.1+)
92
93For relationship questions ("who knows who at X?", "connections between A and B",
94"who works at Acme?", "who attended the standup?"), use the graph layer instead
95of full-text search:
96
97- `gbrain graph-query <slug> --type <link_type> --depth N --direction in|out|both`
98- Available link types: `attended`, `works_at`, `invested_in`, `founded`, `advises`, `mentions`, `source`
99- `--direction in` answers "who points to X?" (e.g., who works at company X)
100- `--direction out` answers "what does X point to?" (default)
101- `--depth N` controls multi-hop traversal (default 5)
102
103Examples:
104- "Who works at Acme?" → `gbrain graph-query companies/acme --type works_at --direction in`
105- "Who attended Demo Day W26?" → `gbrain graph-query meetings/demo-day-w26 --type attended --direction out`
106- "What companies has Emily advised?" → `gbrain graph-query people/emily --type advises --direction out`
107- "Who has Alice met (via meetings)?" → `gbrain graph-query people/alice --type attended --depth 2`
108
109Combine with `gbrain query` for queries that need BOTH semantic similarity AND
110graph structure. Search results are ranked with a small backlink boost so well-
111connected entities surface higher.
112
113## Search Quality Awareness
114
115If search results seem off (wrong results, missing known pages, irrelevant hits):
116- Run `gbrain doctor --json` to check index health
117- Check embedding coverage -- partial embeddings degrade hybrid search
118- Compare keyword search (`gbrain search`) vs hybrid search (`gbrain query`)
119 for the same query to isolate whether the issue is embedding-related
120- Report search quality issues in the maintain workflow (see maintain skill)
121
122## Tools Used
123
124- Keyword search gbrain (search)
125- Hybrid search gbrain (query)
126- Read a page from gbrain (get_page)
127- List pages in gbrain with filters (list_pages)
128- Check backlinks in gbrain (get_backlinks)
129- Traverse the link graph in gbrain (traverse_graph)
130- View timeline entries in gbrain (get_timeline)
131
132---
133
134**Source:** [`garrytan/gbrain`](https://github.com/garrytan/gbrain) → `skills/query/SKILL.md`