Skip to content

Commit d707dd2

Browse files
committed
Make 'search' the default unified entrypoint
Introduce a unified `search` tool as the recommended default across docs and skills, with examples, parameter reference, and response envelope. Update decision trees and best-practices to auto-route intents to specialized tools (repo_search, context_answer, symbol_graph, etc.), add override parameters and usage guidance. Replace/rename neo4j_graph_query references to a generic graph_query (with symbol_graph fallback) and add predict_related commit co-change usage. Changes touch SKILL docs, tool-reference, and CLAUDE example to align tooling guidance and examples.
1 parent 31a5c8d commit d707dd2

File tree

4 files changed

+201
-51
lines changed

4 files changed

+201
-51
lines changed

.codex/skills/context-engine/SKILL.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,33 @@ Hybrid vector search (semantic + lexical) with neural reranking for codebase ret
1111

1212
```
1313
Need to find code?
14-
├── Simple lookup → info_request
15-
├── Need filters/control → repo_search
14+
├── UNSURE / GENERAL QUERY → search (RECOMMENDED DEFAULT)
15+
│ └── Auto-routes to the best tool based on query intent
16+
├── Simple lookup → search OR info_request
17+
├── Need filters/control → search OR repo_search
1618
├── Search across multiple repos → cross_repo_search
17-
├── Want LLM explanation → context_answer
19+
├── Want LLM explanation → search OR context_answer
1820
├── Find similar patterns → pattern_search (if enabled)
19-
├── Find relationships → symbol_graph (DEFAULT, always available)
21+
├── Find relationships → search OR symbol_graph (DEFAULT, always available)
2022
└── Store/recall knowledge → memory_store, memory_find
2123
```
2224

2325
## Primary Tools
2426

25-
**repo_search** - Main code search tool:
27+
**search** - Unified entry point (RECOMMENDED DEFAULT):
28+
```json
29+
{"query": "authentication middleware"}
30+
```
31+
Auto-detects intent and routes to the best tool. Returns:
32+
```json
33+
{
34+
"ok": true, "intent": "search", "confidence": 0.92,
35+
"tool": "repo_search", "result": {...}, "execution_time_ms": 245
36+
}
37+
```
38+
Handles: code search, Q&A, tests, config, symbols, imports. Use specialized tools only for cross-repo, memory, or admin operations.
39+
40+
**repo_search** - Direct code search (full control):
2641
```json
2742
{"query": "authentication middleware", "limit": 10, "include_snippet": true}
2843
```
@@ -77,12 +92,13 @@ Use `depth=2` for multi-hop (callers of callers).
7792

7893
## Best Practices
7994

80-
1. **NEVER use grep/cat/find for code exploration** - Use MCP tools instead
81-
2. **Start with `symbol_graph`** for all relationship queries
82-
3. **Use multi-query** for complex searches: pass 2-3 variations
83-
4. **Two-phase search**: Discovery (`limit=3, compact=true`) → Deep dive (`limit=8, include_snippet=true`)
84-
5. **Fire parallel calls** - Multiple independent searches in one message
85-
6. **Set session defaults early**: `set_session_defaults(output_format="toon", compact=true)`
95+
1. **Use `search` as your default tool** - Auto-routes to the best specialized tool
96+
2. **NEVER use grep/cat/find for code exploration** - Use MCP tools instead
97+
3. **Start with `symbol_graph`** for all relationship queries
98+
4. **Use multi-query** for complex searches: pass 2-3 variations
99+
5. **Two-phase search**: Discovery (`limit=3, compact=true`) → Deep dive (`limit=8, include_snippet=true`)
100+
6. **Fire parallel calls** - Multiple independent `search`, `repo_search`, `symbol_graph` in one message
101+
7. **Set session defaults early**: `set_session_defaults(output_format="toon", compact=true)`
86102

87103
## Filters (for repo_search)
88104

.codex/skills/context-engine/references/tool-reference.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
Complete parameter reference for all MCP tools.
44

5+
## search (UNIFIED - DEFAULT)
6+
7+
**Use this by DEFAULT for any code search, exploration, or question.** Automatically detects query intent and routes to the optimal specialized tool.
8+
9+
| Parameter | Type | Description |
10+
|-----------|------|-------------|
11+
| `query` | string | Natural language query describing what you need |
12+
| `collection` | string | Target a specific collection |
13+
| `limit` | int | Max results (default varies by detected intent) |
14+
| `language` | string | Filter by programming language |
15+
| `under` | string | Filter by directory path prefix |
16+
| `include_snippet` | bool | Include code snippets in results |
17+
| `compact` | bool | Compact output format |
18+
19+
**Returns:** `{ok, intent, confidence, tool, result, plan, execution_time_ms}`
20+
21+
**Dispatchable tools:** `repo_search`, `context_answer`, `search_tests_for`, `search_config_for`, `symbol_graph`, `search_callers_for`, `search_importers_for`, `info_request`, `context_search`
22+
523
## repo_search / code_search
624

725
Primary hybrid search tool. Reranking enabled by default.

docs/CLAUDE.example.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,55 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
9696
- Don't ignore per_path limits (duplicate results from same file)
9797
- Don't use context lines for pure discovery (unnecessary tokens)
9898

99+
Tool Selection Decision Tree:
100+
101+
```
102+
Need to search code?
103+
├── DEFAULT: Use search() — auto-routes to the best tool based on query intent
104+
├── Single repo, know collection → repo_search(collection="...")
105+
├── Single repo, need explanation → context_answer or info_request
106+
├── Multiple repos or unsure → cross_repo_search(discover="auto")
107+
├── Tracing frontend→backend flow → cross_repo_search(trace_boundary=true)
108+
├── Finding callers/definitions → symbol_graph
109+
└── Exact literal string only → grep (last resort)
110+
```
111+
112+
## Unified Search Tool (DEFAULT)
113+
114+
**Use `search` as your DEFAULT tool for any code search, exploration, or question.**
115+
It automatically detects query intent and routes to the optimal specialized tool.
116+
117+
```
118+
search_context-engine(query: "authentication middleware")
119+
# → Detects intent: "search", routes to repo_search
120+
# → Returns: {ok, intent, confidence, tool, result, plan, execution_time_ms}
121+
122+
search_context-engine(query: "how does the caching layer work?")
123+
# → Detects intent: "answer", routes to context_answer
124+
125+
search_context-engine(query: "who calls authenticate()")
126+
# → Detects intent: "symbol_callers", routes to symbol_graph
127+
128+
search_context-engine(query: "tests for payment processing")
129+
# → Detects intent: "search_tests", routes to search_tests_for
130+
```
131+
132+
**When to use `search` vs specialized tools:**
133+
- Use `search` by DEFAULT — it picks the right tool for you
134+
- Use specialized tools when you need specific parameters not exposed by search
135+
- Use `cross_repo_search` for explicit multi-repo scenarios
136+
- Use `memory_store`/`memory_find` for memory operations (not handled by search)
137+
99138
Tool Roles Cheat Sheet:
100139

101140
**Note:** All tools below have the `_context-engine` suffix when called (e.g., `repo_search_context-engine`).
102141

142+
- search (UNIFIED - DEFAULT):
143+
- **Use this by DEFAULT for any code search, exploration, or question.**
144+
- Automatically detects intent (search, answer, tests, config, callers, etc.) and routes to the optimal tool.
145+
- Returns unified envelope: `{ok, intent, confidence, tool, result, plan, execution_time_ms}`.
146+
- Think: "find auth middleware", "how does caching work?", "who calls authenticate()".
147+
- Use specialized tools only when you need parameters not exposed by search.
103148
- repo_search / code_search:
104149
- Use for: finding relevant files/spans and inspecting raw code.
105150
- Think: "where is X implemented?", "show me usages of Y".
@@ -125,13 +170,13 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
125170
- Think: "who calls this function?", "where is this class defined?".
126171
- **Note**: Results are "hydrated" with ~500-char source snippets for immediate context.
127172
- Supports `depth` for multi-hop traversals (depth=2 = callers of callers).
128-
- Use this FIRST for any graph query. Do NOT attempt neo4j_graph_query unless it's in your tool list.
129-
- neo4j_graph_query (OPTIONAL — only when NEO4J_GRAPH=1):
130-
- **Only available when NEO4J_GRAPH=1. If not in your tool list, use symbol_graph instead.**
173+
- Use this FIRST for any graph query. Do NOT attempt graph_query unless it's in your tool list.
174+
- graph_query (OPTIONAL — only when NEO4J_GRAPH=1 or MEMGRAPH_GRAPH=1):
175+
- **Only available when NEO4J_GRAPH=1 or MEMGRAPH_GRAPH=1. If not in your tool list, use symbol_graph instead.**
131176
- Use for: advanced graph traversals that grep CANNOT do.
132177
- Query types: `callers`, `callees`, `transitive_callers`, `transitive_callees`, `impact`, `dependencies`, `cycles`.
133178
- Think: "what would break if I change X?" (impact), "callers of callers" (transitive_callers), "circular deps?" (cycles).
134-
- Example: `neo4j_graph_query(symbol="normalize_path", query_type="impact", depth=2)` → finds all code that would break.
179+
- Example: `graph_query(symbol="normalize_path", query_type="impact", depth=2)` → finds all code that would break.
135180
- **Never error or warn about Neo4j being unavailable — just use symbol_graph.**
136181
- info_request:
137182
- Use for: rapid broad discovery and architectural overviews.
@@ -148,6 +193,9 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
148193
- Step 3 – Pull commit lineage for a specific behavior:
149194
- Use search_commits_for with short behavior phrases plus an optional path filter, e.g. `search_commits_for_context-engine(query: "remote upload timeout retry", path: "scripts/remote_upload_client.py")`.
150195
- Read lineage_goal / lineage_symbols / lineage_tags to understand intent and related concepts.
196+
- Step 3b – Predict co-changing files:
197+
- Use `search_commits_for_context-engine(path: "scripts/remote_upload_client.py", predict_related: true)` to get ranked files that historically change alongside the target file, with commit messages explaining why.
198+
- Read lineage_goal / lineage_symbols / lineage_tags to understand intent and related concepts.
151199
- Step 4 – Optionally summarize current behavior:
152200
- After you have the right file/symbol from repo_search, use context_answer to explain what the module does now; treat commit lineage as background, not as primary code context.
153201
- For exact line-level changes (e.g. "when did this literal constant change?"), use lineage tools to narrow candidate commits, then inspect diffs with git tooling; do not guess purely from summaries.
@@ -170,10 +218,11 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
170218

171219
- Indexer / Qdrant tools:
172220
- qdrant_index_root, qdrant_index, qdrant_prune
173-
- qdrant_list, qdrant_status
221+
- qdrant_status, qdrant_list
174222
- workspace_info, list_workspaces, collection_map
175223
- set_session_defaults
176224
- Search / QA tools:
225+
- search (UNIFIED - DEFAULT entry point, auto-routes to specialized tools)
177226
- repo_search, code_search, context_search, context_answer
178227
- pattern_search (optional; structural code pattern matching, cross-language)
179228
- search_tests_for, search_config_for, search_callers_for, search_importers_for
@@ -192,7 +241,7 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
192241
- You're unsure which collection to target
193242

194243
```
195-
qdrant_list_context-engine()
244+
qdrant_status_context-engine(list_all: true)
196245
collection_map_context-engine(include_samples: true)
197246
```
198247

@@ -304,5 +353,5 @@ The ONLY acceptable use of grep/Read: confirming exact literal strings (e.g., `R
304353

305354
- context_answer timeout → repo_search + info_request(include_explanation=true)
306355
- pattern_search unavailable → repo_search with structural query terms
307-
- neo4j_graph_query unavailable → symbol_graph (Qdrant-backed, ALWAYS available — this is the DEFAULT)
356+
- graph_query unavailable → symbol_graph (Qdrant-backed, ALWAYS available — this is the DEFAULT)
308357
- grep / Read File → repo_search, symbol_graph, info_request (ALWAYS use MCP instead)

0 commit comments

Comments
 (0)