Skip to content

Commit 33a2d06

Browse files
rodion-mclaude
andcommitted
Align skills and agent with new MCP tools, remove legacy parameters
- Rename agent: codealive-code-explorer → codealive-context-explorer - Agent: add Grep/Glob tools, all 5 CodeAlive scripts (search, grep, fetch, relationships, datasources), remove --mode/--include-content - SKILL.md: mark chat as "not recommended", remove deprecated aliases from MCP table, add explicit user-request-only policy for chat - query-patterns.md: replace legacy Search Mode Selection and Include Content Decision with search.py vs grep.py guidance and fetch/ relationships workflow - workflows.md: rewrite all workflows to use fetch.py + relationships.py instead of chat.py; remove --mode deep, --include-content, --description-detail; remove Conversation Continuity section - datasources.py: replace chat.py references with grep.py in usage hints Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e859d7 commit 33a2d06

6 files changed

Lines changed: 236 additions & 204 deletions

File tree

agents/codealive-code-explorer.md

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
name: codealive-context-explorer
3+
description: Iterative code exploration across indexed repositories using CodeAlive semantic search, grep, artifact fetch, and relationship inspection. Use when investigating a codebase question, tracing cross-service patterns, understanding architecture, debugging, or gathering context from external repos. Offloads exploration to a lightweight subagent to save main conversation context.
4+
tools: Bash, Read, Grep, Glob
5+
model: haiku
6+
---
7+
8+
# CodeAlive Context Explorer
9+
10+
You are a code exploration specialist. Your job is to iteratively search indexed codebases using CodeAlive tools, fetch real source code, and return a focused, structured summary.
11+
12+
## How You Work
13+
14+
You receive a question or task about a codebase. You search iteratively — refine queries based on results, follow leads, fetch full source when needed, and build a complete picture before responding.
15+
16+
## Available Tools
17+
18+
### 1. Discover data sources
19+
```bash
20+
python scripts/datasources.py
21+
```
22+
23+
### 2. Semantic search (default discovery — finds code by meaning)
24+
```bash
25+
python scripts/search.py "<query>" <data_source> [--max-results N] [--path PATH] [--ext EXT]
26+
```
27+
- `<query>`: Natural-language description of what to find
28+
- `<data_source>`: Repository name or `workspace:<name>` (can specify multiple)
29+
- `--max-results N`: Cap number of returned artifacts
30+
- `--path PATH`: Restrict to a directory (repeatable)
31+
- `--ext EXT`: Restrict to file extension like `.py` or `.cs` (repeatable)
32+
33+
### 3. Grep search (finds code containing exact text or regex)
34+
```bash
35+
python scripts/grep.py "<pattern>" <data_source> [--regex] [--max-results N] [--path PATH] [--ext EXT]
36+
```
37+
Use when you know the exact identifier, error message, config key, or regex pattern.
38+
39+
### 4. Fetch full source (for external repos you can't Read locally)
40+
```bash
41+
python scripts/fetch.py "<identifier1>" ["<identifier2>"...]
42+
```
43+
Pass `identifier` values from search/grep results. Max 20 per call. Returns numbered source code with a relationship preview (up to 3 calls per direction).
44+
45+
### 5. Drill into relationships
46+
```bash
47+
python scripts/relationships.py "<identifier>" [--profile callsOnly|inheritanceOnly|allRelevant|referencesOnly] [--max-count N]
48+
```
49+
Use after search or fetch to expand an artifact's call graph, inheritance, or references.
50+
51+
The scripts directory is relative to the skill location. If the path fails, check `${CLAUDE_PLUGIN_ROOT}/skills/codealive-context-engine/scripts/`.
52+
53+
## Search Strategy
54+
55+
1. **Start broad**`search.py` with the main topic to understand scope
56+
2. **Pin exact names**`grep.py` for specific identifiers, error messages, config keys found in step 1
57+
3. **Fetch real source**`fetch.py` for the most relevant identifiers (descriptions are triage pointers only — never reason from them)
58+
4. **Trace relationships**`relationships.py` to understand call graphs or inheritance when needed
59+
5. **Cross-reference locally** — use `Grep` and `Glob` for files in the working directory; use `Read` for local files
60+
6. **Refine** — rephrase queries, try different angles; 2-5 rounds is typical
61+
7. **Stop when sufficient** — don't over-search
62+
63+
**Choosing between search.py and grep.py:**
64+
- You describe behavior or concept ("authentication middleware") -> `search.py`
65+
- You know the exact text ("AuthService", "TODO: fix", regex pattern) -> `grep.py`
66+
67+
## Output Format
68+
69+
Return a structured summary:
70+
71+
```
72+
## Summary
73+
<1-3 sentence answer to the original question>
74+
75+
## Key Findings
76+
- <finding 1 with file:line references>
77+
- <finding 2>
78+
- ...
79+
80+
## Relevant Files
81+
- `path/to/file.ext:line` - description
82+
- ...
83+
84+
## Search Queries Used
85+
1. search.py "<query 1>" -> <what it revealed>
86+
2. grep.py "<query 2>" -> <what it revealed>
87+
3. fetch.py "<identifier>" -> <what the source confirmed>
88+
```
89+
90+
## Rules
91+
92+
- Always include file paths and line numbers in findings
93+
- If the first search returns no useful results, try at least 2 different query phrasings before concluding
94+
- Use `grep.py` when you know exact names; use `search.py` when exploring concepts
95+
- Fetch full source via `fetch.py` before drawing conclusions — descriptions and line previews are triage evidence only
96+
- For local repos, prefer `Grep`/`Glob`/`Read` over `fetch.py` — faster and free
97+
- If authentication fails, report the error and stop — do not retry
98+
- Do not use chat.py — use search, grep, fetch, and relationships to gather evidence directly
99+
- Keep your response concise — the goal is to save the caller's context window

skills/codealive-context-engine/SKILL.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ Do NOT retry the failed script until setup completes successfully.
4242
| **Grep Search** | `grep.py` | Fast | Low | Finds code containing a specific string or regex (identifiers, literals, patterns) |
4343
| **Fetch Artifacts** | `fetch.py` | Fast | Low | Retrieving full content for search results |
4444
| **Artifact Relationships** | `relationships.py` | Fast | Low | Drilling into call graph, inheritance, references for one artifact |
45-
| **Chat with Codebase** | `chat.py` | Slow | High | Synthesized answers, architectural explanations |
45+
| **Chat with Codebase** | `chat.py` | Slow | High | **Not recommended.** Call ONLY when the user explicitly asks (e.g. "use chat"). |
4646

47-
**Cost guidance:** `semantic_search` and `grep_search` are the default starting point. Chat with Codebase invokes an LLM on the server side, can take up to 30 seconds, and is significantly more expensive per call — use it only when you need a synthesized, ready-to-use answer rather than raw search results.
47+
**Cost guidance:** `semantic_search` and `grep_search` are the default starting point — fast and cheap. Use `fetch_artifacts` to load full source and `get_artifact_relationships` to trace call graphs. All four tools are low-cost.
4848

49-
**Highest-confidence guidance:** If your agent supports subagents and the task needs maximum reliability or depth, prefer a subagent-driven workflow that combines `search.py`, `grep.py`, `fetch.py`, `relationships.py`, and local file reads. `chat.py` is optional synthesis, not the default path.
49+
**Chat is not recommended:** `chat.py` invokes an LLM on the server side, can take up to 30 seconds, and is significantly more expensive per call. Do NOT call it unless the user has explicitly requested it (e.g. "use chat", "use codebase_consultant", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" do NOT qualify — they refer to search tools.
50+
51+
**Highest-confidence guidance:** If your agent supports subagents and the task needs maximum reliability or depth, prefer a subagent-driven workflow that combines `search.py`, `grep.py`, `fetch.py`, `relationships.py`, and local file reads.
5052

5153
**Three-step workflow (search → triage → load real content):**
5254
1. **Search** — find relevant code locations with descriptions and identifiers
@@ -118,13 +120,15 @@ python scripts/relationships.py "my-org/backend::src/models.py::User" --profile
118120
python scripts/relationships.py "my-org/backend::src/svc.py::Service" --profile allRelevant --max-count 200
119121
```
120122

121-
### 5. Chat with codebase (slower, optional synthesis)
123+
### 5. Chat with codebase (not recommended — only if user explicitly asks)
122124

123125
```bash
124126
python scripts/chat.py "Explain the authentication flow" my-backend
125127
python scripts/chat.py "What about security considerations?" --continue CONV_ID
126128
```
127129

130+
**Do not call chat unless the user explicitly asks for it.** Use search, grep, fetch, and relationships for all other tasks.
131+
128132
## Tool Reference
129133

130134
### `datasources.py` — List Data Sources
@@ -218,11 +222,13 @@ python scripts/relationships.py <identifier> [--profile PROFILE] [--max-count N]
218222
| `--max-count N` | Max related artifacts per relationship type (1–1000, default 50) |
219223
| `--json` | Emit the raw JSON response instead of the formatted view |
220224

221-
### `chat.py` — Chat with Codebase
225+
### `chat.py` — Chat with Codebase (not recommended)
226+
227+
**Do NOT call unless the user explicitly asks** (e.g. "use chat", "use codebase_consultant", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" refer to search tools, not chat.
222228

223229
Sends your question to an AI consultant that has full context of the indexed codebase. Returns synthesized, ready-to-use answers. Supports conversation continuity for follow-ups.
224230

225-
**This is more expensive than search** because it runs an LLM inference on the server side. Prefer search when you just need to locate code. Use chat when you need explanations, comparisons, or architectural analysis after search. It can take up to 30 seconds.
231+
**This is slow and expensive** runs an LLM on the server side, up to 30 seconds per call. For all standard tasks (finding code, understanding architecture, debugging), use `search.py`, `grep.py`, `fetch.py`, and `relationships.py` instead.
226232

227233
```bash
228234
python scripts/chat.py <question> <data_sources...> [options]
@@ -300,7 +306,7 @@ This skill works standalone, but delivers the best experience when combined with
300306
| Component | What it provides |
301307
|-----------|-----------------|
302308
| **This skill** | Query patterns, workflow guidance, cost-aware tool selection |
303-
| **MCP server** | Direct `semantic_search`, `grep_search`, `fetch_artifacts`, `get_artifact_relationships`, `chat`, `get_data_sources` tools plus deprecated aliases |
309+
| **MCP server** | Direct `semantic_search`, `grep_search`, `fetch_artifacts`, `get_artifact_relationships`, `get_data_sources` tools via MCP protocol |
304310

305311
When both are installed, prefer the MCP server's tools for direct operations and this skill's scripts for guided workflows.
306312

skills/codealive-context-engine/references/query-patterns.md

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -171,55 +171,42 @@ Start broad, then narrow based on results:
171171
3. Specific: "JWT validation middleware error handling"
172172
```
173173

174-
### Search Mode Selection
174+
### Choosing Between search.py and grep.py
175175

176-
**Auto Mode** (default) - Use for most queries:
177-
- Balanced speed and depth
178-
- Intelligent semantic understanding
179-
- Good for 80% of use cases
176+
**Use `search.py` (semantic search)** — the default:
177+
- You describe behavior or a concept: "authentication middleware", "retry logic"
178+
- You don't know exact names in the codebase
179+
- Architectural or cross-cutting questions
180+
- Good for 80% of discovery tasks
180181

181-
**Fast Mode** - Use for obvious/simple queries:
182-
- Known function/class names
183-
- Exact technical terms
184-
- Quick lookups
182+
**Use `grep.py` (exact text / regex):**
183+
- Known identifiers: class names, function names, config keys
184+
- Literal strings: error messages, URLs, import paths
185+
- Finding ALL occurrences of a symbol across the codebase
186+
- Regex patterns: `def test_.*async`, `Status\.(Alive|Failed)`
185187

186-
**Deep Mode** - Use sparingly for complex queries:
187-
- Cross-cutting concerns
188-
- Abstract architectural questions
189-
- When auto mode misses results
190-
- Resource-intensive - use only when needed
188+
### Getting Full Source Code
191189

192-
### Include Content Decision
190+
Search results contain a `description` field — this is a **triage pointer only**.
191+
Do NOT reason about code based on descriptions. For every relevant result:
193192

194-
**include_content=false** (default for current repo):
195-
```
196-
Use when:
197-
- Searching your current working repository
198-
- Results are file paths for further investigation
199-
- You'll use file read tool to examine files
200-
- Want concise results
201-
```
193+
- **Current working repo:** read the file at the shown path with your editor's file-read tool
194+
- **External repos (no local access):** `python fetch.py <identifier>`
202195

203-
**include_content=true** (for external repos):
204-
```
205-
Use when:
206-
- Searching external dependencies/libraries
207-
- No file system access to the repository
208-
- Need immediate code visibility
209-
- Analyzing patterns across repos
210-
```
196+
Treat only the real `content` as ground truth.
211197

212198
### Combining Tools
213199

214-
**Search → Read → Ask Pattern:**
215-
1. `search.py` to find relevant files
216-
2. Use file read tool to examine specific files
217-
3. `chat.py` to ask questions about what you found
200+
**Search → Triage → Fetch → Relationships Pattern (recommended):**
201+
1. `search.py` or `grep.py` to find relevant code locations
202+
2. Review results — pick the most relevant by path, kind, description
203+
3. `fetch.py <identifier>` to load full source for external repos (or `Read` for local)
204+
4. `relationships.py <identifier>` to expand call graph, inheritance, or references
218205

219-
**AskSearchAsk Pattern:**
220-
1. `chat.py` for architectural overview
221-
2. `search.py` to find specific implementations
222-
3. `chat.py` again with more context
206+
**GrepFetchRelationships Pattern (when you know exact names):**
207+
1. `grep.py "ExactClassName"` to find all occurrences
208+
2. `fetch.py` for the definition you want to inspect
209+
3. `relationships.py` to see who calls it and what it calls
223210

224211
## Anti-Patterns (Avoid These)
225212

@@ -298,7 +285,8 @@ Use when:
298285
1. **Use natural language** - CodeAlive understands intent, not just keywords
299286
2. **Be specific about context** - Include domain/layer info (API, database, frontend)
300287
3. **Leverage workspaces** - Search across multiple repos for patterns
301-
4. **Start with search** - Use semantic search first, then grep when the literal pattern matters; only use chat after you have evidence and still need synthesis
302-
5. **Iterate** - Use follow-up questions to drill deeper
303-
6. **Combine with local tools** - CodeAlive for discovery, Read for details
304-
7. **Think like a librarian** - Focus on "what" and "why", not "where"
288+
4. **Start with search, not chat** - Use `search.py` for concepts, `grep.py` for exact text; always fetch real source before reasoning
289+
5. **Fetch before concluding** - Descriptions are triage hints; use `fetch.py` or local `Read` to get ground truth
290+
6. **Drill into relationships** - Use `relationships.py` to trace call graphs and inheritance after finding a key artifact
291+
7. **Combine with local tools** - CodeAlive for discovery, `Read` for local details, `fetch.py` for external repos
292+
8. **Think like a librarian** - Focus on "what" and "why", not "where"

0 commit comments

Comments
 (0)