Semantic code search by meaning. Use codebase_peek to find WHERE code is (saves tokens), codebase_search to see actual code. For exact identifiers, use grep instead.
The indexed codebase contains two types of content:
add_knowledge_base (MCP/OpenCode) or knowledge_base_add (Pi).| Scenario | Tool | Why |
|---|---|---|
| Code/library/API question | codebase_search |
Search local knowledge first |
| Just need file locations | codebase_peek |
Metadata only, saves ~90% tokens |
| Need to see actual code | codebase_search |
Returns full code content |
| Find duplicates/patterns | find_similar |
Given code snippet β similar code |
| Understand code flow | call_graph |
Find callers/callees of any function |
| Trace dependency paths | call_graph_path |
Find a shortest known path between two symbols |
| Analyze PR blast radius | pr_impact |
Find affected symbols, communities, hub nodes, and risk |
| Don't know function/class names | codebase_peek or codebase_search |
Natural language β code |
| Know exact identifier names | grep |
Faster, more precise |
| Need ALL occurrences | grep |
Semantic returns top N only |
| Access specific URL | webfetch |
Direct URL access, no codebase search needed |
| Local search fails | websearch |
Fallback when codebase has no results |
| Local and web search fails | suggest adding knowledge base | Notify user to add related folder |
Search local codebase first, then web search if needed.
Question received
β
Is this about code/library/API/framework?
β YES
codebase_search(query)
β
Found relevant results? β YES β Return answer
β NO
websearch(query)
β
Found relevant results? β YES β Return answer
β NO
Suggest: "η₯θ―εΊδΈζͺζΎε°ηΈε
³δΏ‘ζ―οΌζ―ε¦ζ·»ε ηΈε
³ζζ‘£ζδ»Άε€ΉοΌ"
codebase_search for code/library/API questionswebsearchcodebase_peek("authentication flow") β get likely locations before grep or graph toolscodebase_search("ADC channels ESP32") β inspect implementation or knowledge-base matchesRead the specific files you needcall_graph, call_graph_path, pr_impact, or OMO CodeGraph once you know the relevant symbolgrep "validateToken" for exact matchescodebase_peekFind WHERE code is. Returns metadata only (file, line, name, type).
codebase_peek(query="validation logic", chunkType="function", directory="src/utils")
codebase_peek(query="authentication flow", blameAuthor="jane@example.com")
codebase_searchFind code with full content. Use when you need to see implementation.
codebase_search(query="error handling middleware", fileType="ts", contextLines=2)
codebase_search(query="rate limiter", blameSince="2025-01-01", blameUntil="2025-01-31")
find_similarFind code similar to a given snippet. Use for duplicate detection, pattern discovery, refactoring.
find_similar(code="function validate(input) { return input.length > 0; }", excludeFile="src/current.ts", blameSince="2025-01-01")
call_graphQuery callers or callees of a function/method.
call_graph(name="validateToken", direction="callers")
index_codebaseManually trigger indexing. Required before first search.
index_statusCheck if indexed and ready.
add_knowledge_base(path="/path/to/docs")list_knowledge_basesremove_knowledge_base(path="/path/to/docs")knowledge_base_add(path="/path/to/docs")knowledge_base_listknowledge_base_remove(path="/path/to/docs")Describe behavior, not syntax:
"function that hashes passwords securely""hashPassword" (use grep for exact names)Search across documentation:
"how to configure WiFi in ESP-IDF""GPIO initialization example"| Filter | Example |
|---|---|
chunkType |
function, class, interface, type, method |
directory |
"src/api", "tests" |
fileType |
"ts", "py", "rs" |
blameAuthor |
"jane@example.com" or "Jane Doe" |
blameSha |
"abc1234" |
blameSince |
"2025-01-01" |
blameUntil |
"2025-01-31" |