Skip to content

Commit 14ec0ab

Browse files
prosdevclaude
andcommitted
docs: update CLAUDE.md and agents for dev refs CLI and graph caching
- Add dev refs to CLI commands section with usage examples - Document graph caching (dependency-graph.json) in MCP tools section - Update dev_refs description to mention dependsOn parameter - Update agent prompts (bug-investigator, plan-reviewer, research-planner, quick-scout) to reference dependsOn for dependency chain tracing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f89069b commit 14ec0ab

8 files changed

Lines changed: 58 additions & 21 deletions

File tree

.claude/agents/bug-investigator.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ color: orange
1010

1111
Systematically traces issues through the dev-agent monorepo. Reproduces, traces, fixes, and prevents regression.
1212

13-
## MCP Tools — Use These First
13+
## MCP Tools — Save Tokens, Extend Sessions
1414

15-
- **`dev_search`** — Start here for any conceptual query ("where does rate limiting happen", "how are embeddings stored"). Semantic search finds code by meaning, not just keywords.
16-
- **`dev_refs`** — Trace callers/callees of a function to map the data flow. Use this instead of grepping for function names when tracing how data moves across packages.
17-
- **`dev_map`** — Check change frequency to see what files changed recently. Useful for "when did it break?" — high-churn files near the bug timeframe are prime suspects.
15+
Use MCP tools to get focused results instead of Grep → Read cycles. See CLAUDE.md for the token savings table.
1816

19-
Fall back to Grep/Glob for exact string matches or file patterns.
17+
- **`dev_search`** — Conceptual queries ("where does rate limiting happen"). Returns ranked snippets — no file reading needed.
18+
- **`dev_refs`** — Callers/callees of a function. Use `dependsOn` to trace dependency chains between files.
19+
- **`dev_map`** — Codebase structure with hot paths and subsystems. One call replaces dozens of ls/glob/read operations.
20+
21+
Reserve Grep/Glob for exact string matches where you know the literal text.
2022

2123
## Investigation Framework
2224

.claude/agents/logic-reviewer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ Every finding MUST include confidence: **HIGH** (verified from code), **MEDIUM**
6565

6666
### Cross-Package Data Flow (Deep+ Effort)
6767

68-
Use `dev_refs` to trace caller/callee chains across package boundaries. Use `dev_search` to find related code by concept when the function name isn't obvious.
68+
Use MCP tools to trace cross-package flows without reading every file (see CLAUDE.md for token savings). `dev_refs` returns the call graph directly, `dev_search` finds related code by concept, `dev_patterns` compares error handling across files.
6969

7070
- [ ] Core exports consumed correctly by CLI, MCP server, and subagents — verify with `dev_refs`
71+
- [ ] Dependency chains make sense — use `dev_refs` with `dependsOn` to trace file-to-file paths
7172
- [ ] Type boundaries between packages match (no `any` casting to bridge mismatches)
7273
- [ ] Logger (@prosdevlab/kero) configuration consistent across consumers
7374
- [ ] Error handling patterns are consistent with existing code (verify with `dev_patterns`)

.claude/agents/plan-reviewer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Read the plan as a senior engineer. Use `dev_map` to verify structure claims, `d
2121
1. **Context** — Does it accurately describe what exists today? (Verify with `dev_map` and reading actual code)
2222
2. **Architecture** — Does the proposed design fit the existing monorepo structure?
2323
3. **Parts breakdown** — Are parts sized correctly? (Each should be 1-2 commits)
24-
4. **Dependencies** — Are cross-package dependencies identified? (Verify with `dev_refs`)
24+
4. **Dependencies** — Are cross-package dependencies identified? (Verify with `dev_refs`. Use `dependsOn` to trace dependency chains between files.)
2525
5. **Build order** — Does the implementation order respect the build dependency chain?
2626
6. **Breaking changes** — Are they identified and migration paths described?
2727

.claude/agents/quality-reviewer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Maximum **5 SUGGESTION items** per review. If more found, pick the top 5 and not
4848

4949
### Readability & Simplification
5050

51-
Use `dev_patterns` to find similar code and detect duplication. Use `dev_search` to check if a utility already exists before flagging missing abstractions.
51+
Use MCP tools to check for duplication without reading every file (see CLAUDE.md for token savings). `dev_patterns` compares patterns across similar files. `dev_search` checks if a utility exists by meaning, not just name.
5252

5353
- [ ] No code duplicating existing utilities — verify with `dev_patterns` and `dev_search`
5454
- [ ] Functions reasonably sized (consider splitting if >50 lines)

.claude/agents/quick-scout.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ color: blue
1010

1111
Lightweight explorer optimized for speed and cost. Finds code, traces flows, maps dependencies.
1212

13+
## Token Efficiency
14+
15+
Use MCP tools to get focused results instead of Grep → Read cycles. See CLAUDE.md for the token savings table. Every file Read costs tokens — let the tools do the reading.
16+
1317
## Capability Boundaries
1418

1519
You excel at:
@@ -25,10 +29,10 @@ Do NOT guess at architectural reasoning or make recommendations.
2529

2630
## Workflow
2731

28-
1. **Search**Always start with `dev_search`. It finds code by meaning, not just keywords. Only fall back to Grep for exact string matches or Glob for file patterns.
29-
2. **Trace** — For "who calls X?" or "what does X call?", use `dev_refs`. Do not grep for function names when `dev_refs` can trace the graph directly.
30-
3. **Map** — For "what's the structure?" or "what changed recently?", use `dev_map`.
31-
4. **Verify** — Read the file to confirm the match
32+
1. **Search**Start with `dev_search` for conceptual queries. Returns ranked snippets without reading files. Only fall back to Grep for exact string matches.
33+
2. **Trace** — For "who calls X?", use `dev_refs`. For "how does A depend on B?", use `dev_refs` with `dependsOn`. Returns the call graph directly — no grepping for function names.
34+
3. **Map** — For "what's the structure?", use `dev_map`. One call replaces dozens of ls/glob/read operations.
35+
4. **Verify**Only Read a file when you need the full implementation, not just the location.
3236
5. **Report** — Concise, factual answer with file paths and line numbers
3337

3438
## Dev-Agent Quick Reference

.claude/agents/research-planner.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ Plans investigations before jumping into implementation. Produces a structured r
1212

1313
This agent **NEVER writes code**. It produces investigation plans.
1414

15-
## MCP Tools — Use These to Map the Territory
15+
## MCP Tools — Save Tokens, Extend Sessions
1616

17-
- **`dev_search`** — Find relevant code areas by meaning. Start broad ("authentication middleware", "vector storage") to discover what exists before diving in.
18-
- **`dev_map`** — Get codebase structure with change frequency. Use early to understand scope and identify hot spots.
19-
- **`dev_patterns`** — Analyze existing patterns before proposing new ones. Find similar implementations, error handling conventions, and type patterns.
20-
- **`dev_refs`** — Trace cross-package dependencies. Understand what depends on what before proposing changes.
17+
Use MCP tools to map the territory without burning tokens on Grep → Read cycles. See CLAUDE.md for the token savings table.
18+
19+
- **`dev_search`** — Find relevant code areas by meaning. Returns ranked snippets — no file reading needed.
20+
- **`dev_map`** — Codebase structure with hot paths and subsystems. One call replaces dozens of ls/glob/read operations.
21+
- **`dev_patterns`** — Compare patterns across similar files without reading each one.
22+
- **`dev_refs`** — Trace cross-package dependencies. Use `dependsOn` to trace dependency chains between files.
2123

2224
## When to Use
2325

.claude/agents/security-reviewer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Security-focused review for a TypeScript monorepo that processes repository data
1212

1313
This agent **NEVER modifies code**. It reports issues for the developer to fix.
1414

15+
## Token Efficiency
16+
17+
Use MCP tools to avoid expensive Grep → Read cycles. See CLAUDE.md for the token savings table. `dev_search` returns ranked snippets, `dev_refs` traces input flow directly, `dev_patterns` scans for similar vulnerability patterns — all without reading files manually.
18+
1519
## Checklist
1620

1721
Use `dev_search` to find security-sensitive code ("user input", "shell execution", "token handling"). Use `dev_patterns` to find similar patterns across the codebase — if one injection vector exists, the same pattern likely appears elsewhere. Use `dev_refs` to trace how user input flows through the system.

CLAUDE.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Everything runs on your machine. No data leaves.
2222
```
2323
packages/
2424
core/ # Scanner (ts-morph, tree-sitter for Python/Go), vector storage (Antfly), services
25-
cli/ # Commander.js CLI — dev index, dev mcp install, etc.
25+
cli/ # Commander.js CLI — dev index, dev search, dev refs, dev map, dev mcp install
2626
mcp-server/ # MCP server with 5 built-in adapters
2727
subagents/ # Coordinator, explorer, planner, PR agents
2828
integrations/ # Claude Code, VS Code, Cursor
@@ -139,16 +139,33 @@ See `.claude/da-plans/README.md` for status and format details.
139139

140140
---
141141

142-
## MCP tools (5 adapters)
142+
## MCP tools — token-efficient context
143+
144+
MCP tools return pre-ranked, pre-snippeted results. Use them to avoid expensive Grep → Read cycles that burn thousands of tokens on irrelevant context.
145+
146+
| Instead of | Use | Tokens saved |
147+
|------------|-----|-------------|
148+
| Grep "auth" → read 10 files | `dev_search "authentication"` | ~5,000 |
149+
| Grep function name → read callers | `dev_refs "functionName"` | ~3,000 |
150+
| ls + glob + read READMEs | `dev_map` | ~2,000 |
151+
| Read multiple files to compare patterns | `dev_patterns filePath` | ~3,000 |
152+
153+
Reserve Grep/Glob for exact string matches where you know the literal text.
154+
155+
### 5 adapters
143156

144157
| Tool | Purpose |
145158
|------|---------|
146159
| `dev_search` | Hybrid code search — BM25 + vector + RRF (use FIRST for conceptual queries) |
147-
| `dev_refs` | Find callers/callees of functions |
148-
| `dev_map` | Codebase structure with change frequency |
160+
| `dev_refs` | Find callers/callees of functions. `dependsOn` traces the dependency chain between files. |
161+
| `dev_map` | Codebase structure with PageRank hot paths and connected subsystems |
149162
| `dev_patterns` | File pattern analysis (similar code, error handling, types). Takes `filePath`, not `query`. |
150163
| `dev_status` | Repository indexing status + Antfly stats + health checks (`section="health"`) |
151164

165+
**Graph caching:** `dev index` builds a dependency graph (`dependency-graph.json`) saved alongside the index.
166+
`dev_map` and `dev_refs` load the cached graph instead of fetching all docs — scales to 50k+ docs.
167+
File watcher incrementally updates the graph on save.
168+
152169
---
153170

154171
## Adding a new MCP adapter
@@ -172,6 +189,13 @@ dev setup # One-time: start Antfly
172189
dev index # Index repository
173190
dev mcp install # Install for Claude Code
174191
dev mcp install --cursor # Install for Cursor
192+
193+
# CLI tools (no MCP server needed)
194+
dev search "authentication" # Semantic code search
195+
dev refs "functionName" # Find callers/callees
196+
dev refs "fn" --depends-on "src/db.ts" # Trace dependency chain
197+
dev map # Codebase structure overview
198+
dev map --focus packages/core --depth 3 # Focused map
175199
```
176200

177201
---

0 commit comments

Comments
 (0)