Search Query Analysis
Query Optimization Skill
Codanna's semantic search works best with technical terms and specific concepts. Analyze the situation and optimize your codebase explore queries for code search:
Examples:
- If vague (e.g., "that parsing thing") → Make it specific (e.g., "language parser implementation")
- If a question (e.g., "how does parsing work?") → Extract keywords (e.g., "parsing implementation process")
- If conversational (e.g., "the stuff that handles languages") → Use technical terms (e.g., "language handler processor")
- If too broad (e.g., "errors") → Add context (e.g., "error handling exception management")
OptimizedQuery: {Claude: I will write my optimized query here, then use it below}
Execute this command with your optimized query:
Your Workflow
Gather Context
Use the Bash tool to perform semantic code search:
Execute: codanna mcp semantic_search_with_context query:"$OptimizedQuery" limit:5
What Codanna returns:
- Relevance scores (how well each result matches)
- Symbol signatures and documentation
- Relationships (calls, called_by, implements, defines)
- File locations with line ranges
Your Workflow
Analyze the results with their relevance scores (focus on results with score > 0.6 (if possible))
To see actual implementation of interesting results:
- Use the line range from the Location field to read just the relevant code
- Example: If you see "at
src/io/exit_code.rs:108-120"
- Use the Read tool with:
file_path: src/io/exit_code.rs (use the working directory from your environment context to construct the absolute path)
offset: 108 (start line)
limit: 13 (calculated as: 120 - 108 + 1)
- Formula:
limit = end_line - start_line + 1
- Example:
Read(file_path="/full/path/to/src/io/exit_code.rs", offset=108, limit=13)
When relationships are shown (called_by, calls, defines, implements):
- If a relationship looks relevant to answering the query, investigate it
- Execute:
codanna retrieve describe <relationship_symbol_name|symbol_id:ID>
- Example: If you see "Called by:
initialize_registry [symbol_id:123]", run: codanna retrieve describe initialize_registry or describe symbol_id:123
- Note: Following 1-2 key relationships per result is typically sufficient
Build a complete picture by following key relationships and reading relevant code sections
If needed, repeat <Step_1: GatherContext> with a refined query based on what you learned.
Tips for Efficient Exploration
The results include:
- Relevance scores (how well each result matches the query)
- Symbol documentation and signatures
- Relationships (who calls this, what it calls, what it defines)
- System guidance for follow-up investigation
sed (native on unix only):
You can also see actual implementation with sed: (works native on Unix based environments):
- Use the line range from the Location field to read just the relevant code
- Example: If you see "Location:
src/io/exit_code.rs:108-120"
- Execute:
sed -n '108,120p' src/io/exit_code.rs to read lines 108-120
- This shows the actual code implementation, not just the signature. It works like the Read tool.
Add lang:rust (or python, typescript, etc.) to narrow results by language if you work on multi-language projects
Follow relationships that appear in multiple results (they're likely important)
Use the describe command to get full details about interesting relationships
Token awareness:
- Each search uses ~500 tokens
- Each relationship follow uses ~300 tokens
- Each file read uses ~100-500 tokens (depends on size)
- Staying efficient keeps your context window clean for deeper analysis
This command is for exploration:
- Build understanding of the codebase
- Identify patterns and integration points
- Present findings and await user direction
- Don't start implementing or making changes yet
Based on the gathered context, engage with the user to narrow focus and help the user with further request.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: codebase-explorer3description: Deep codebase exploration using semantic search and relationship mapping. Use when you need to understand the current codebase. Use when this capability is needed.4---56## Search Query Analysis78### Query Optimization Skill910Codanna's semantic search works best with technical terms and specific concepts. Analyze the situation and optimize your codebase explore queries for code search:1112Examples:131. **If vague** (e.g., "that parsing thing") → Make it specific (e.g., "language parser implementation")142. **If a question** (e.g., "how does parsing work?") → Extract keywords (e.g., "parsing implementation process")153. **If conversational** (e.g., "the stuff that handles languages") → Use technical terms (e.g., "language handler processor")164. **If too broad** (e.g., "errors") → Add context (e.g., "error handling exception management")1718**OptimizedQuery**: _{Claude: I will write my optimized query here, then use it below}_1920Execute this command with your optimized query:2122## Your Workflow <Workflow>2324### Gather Context <Step_1 GatherContext>2526Use the Bash tool to perform semantic code search:2728Execute: `codanna mcp semantic_search_with_context query:"$OptimizedQuery" limit:5`2930**What Codanna returns:**31- Relevance scores (how well each result matches)32- Symbol signatures and documentation33- Relationships (calls, called_by, implements, defines)34- File locations with line ranges3536### Your Workflow <Step_2 YourWorkflow>37381. Analyze the results with their relevance scores (focus on results with score > 0.6 (if possible))39402. **To see actual implementation** of interesting results:41 - Use the line range from the Location field to read just the relevant code42 - Example: If you see "at `src/io/exit_code.rs:108-120`"43 - Use the Read tool with:44 - `file_path`: `src/io/exit_code.rs` (use the working directory from your environment context <env> to construct the absolute path)45 - `offset`: 108 (start line)46 - `limit`: 13 (calculated as: 120 - 108 + 1)47 - Formula: `limit = end_line - start_line + 1`48 - Example: `Read(file_path="/full/path/to/src/io/exit_code.rs", offset=108, limit=13)`49503. **When relationships are shown** (called_by, calls, defines, implements):51 - If a relationship looks relevant to answering the query, investigate it52 - Execute: `codanna retrieve describe <relationship_symbol_name|symbol_id:ID>`53 - Example: If you see "Called by: `initialize_registry [symbol_id:123]`", run: `codanna retrieve describe initialize_registry` or `describe symbol_id:123`54 - Note: Following 1-2 key relationships per result is typically sufficient55564. Build a complete picture by following key relationships and reading relevant code sections57585. **If needed**, repeat <Step_1: GatherContext> with a refined query based on what you learned.5960---6162## Tips for Efficient Exploration6364**The results include:**65- Relevance scores (how well each result matches the query)66- Symbol documentation and signatures67- Relationships (who calls this, what it calls, what it defines)68- System guidance for follow-up investigation6970**sed (native on unix only):**71- You can also see actual implementation with `sed`: (works native on Unix based environments):72 - Use the line range from the Location field to read just the relevant code73 - Example: If you see "Location: `src/io/exit_code.rs:108-120`"74 - Execute: `sed -n '108,120p' src/io/exit_code.rs` to read lines 108-12075 - This shows the actual code implementation, not just the signature. It works like the Read tool.7677- Add `lang:rust` (or python, typescript, etc.) to narrow results by language if you work on multi-language projects78- Follow relationships that appear in multiple results (they're likely important)79- Use the `describe` command to get full details about interesting relationships8081**Token awareness:**82- Each search uses ~500 tokens83- Each relationship follow uses ~300 tokens84- Each file read uses ~100-500 tokens (depends on size)85- Staying efficient keeps your context window clean for deeper analysis8687**This command is for exploration:**88- Build understanding of the codebase89- Identify patterns and integration points90- Present findings and await user direction91- Don't start implementing or making changes yet9293Based on the gathered context, engage with the user to narrow focus and help the user with further request.9495---96> Converted and distributed by [TomeVault](https://tomevault.io/claim/madeinoz67) — claim your Tome and manage your conversions.97<!-- tomevault:4.0:skill_md:2026-04-11 -->