Skip to content

Commit 5e8b6a5

Browse files
prosdevclaude
andcommitted
docs(agents): inline MCP tool usage into workflow steps
Remove the weak "MCP Tools — Conserve Context" preamble sections from all agents. These advisory blocks were being ignored — agents fell into Read/Grep habits. Instead, MCP tool calls are now embedded directly in the workflow steps where the agent makes decisions. Pattern: "Run dev_refs on the changed functions" (imperative, in-step) instead of "Before you Grep, ask if an MCP tool can help" (advisory, separate section). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 71f158a commit 5e8b6a5

8 files changed

Lines changed: 36 additions & 77 deletions

File tree

.claude/agents/bug-investigator.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,20 @@ color: orange
1010

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

13-
## MCP Tools — Conserve Context
14-
15-
This agent runs in a long session with a finite context window. Every Grep → Read cycle burns ~5,000 tokens on irrelevant matches. MCP tools return only what you need.
16-
17-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
18-
19-
- **`dev_search`** — Conceptual queries ("where does rate limiting happen"). Returns ranked snippets, not 200 grep matches.
20-
- **`dev_refs`** — Callers/callees of a function. Use `dependsOn` to trace dependency chains. Returns the call graph directly.
21-
- **`dev_map`** — Codebase structure with hot paths and subsystems. One call replaces dozens of ls/glob/read operations.
22-
23-
Only use Grep for exact string matches where you know the literal text. Only Read files when you need the full implementation.
24-
2513
## Investigation Framework
2614

2715
### Phase 1: Understand the Bug
2816

2917
1. What is the expected behavior?
3018
2. What is the actual behavior?
3119
3. What are the reproduction steps?
32-
4. When did it start happening? (check recent commits + `dev_map` for churn)
33-
5. Is it consistent or intermittent?
20+
4. Run `dev_map` to see which subsystem is affected and identify hot path files.
21+
5. Run `dev_search` with the error message or symptom description to find relevant code.
22+
6. When did it start happening? (check recent commits)
3423

3524
### Phase 2: Trace the Data Flow
3625

37-
Use `dev_refs` to trace caller/callee chains along these paths:
26+
Run `dev_refs` on the functions identified in Phase 1. Use `dependsOn` to trace the full dependency chain. Follow these paths:
3827

3928
**MCP path:**
4029
```
@@ -55,7 +44,7 @@ dev index → Indexer → Scanner (ts-morph/tree-sitter) → Antfly (embed + sto
5544

5645
### Phase 3: Identify Root Cause
5746

58-
Use `dev_search` to find code related to each symptom area:
47+
Run `dev_search` for each symptom area to find related code:
5948

6049
| Symptom | Likely Cause | Where to Look |
6150
|---------|--------------|---------------|

.claude/agents/code-reviewer.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,15 @@ specialist agents, and produce a unified report.
1414

1515
This agent **NEVER modifies code**. It reports issues for the developer to fix.
1616

17-
## MCP Tools — Conserve Context
18-
19-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
20-
21-
Use MCP tools in the planning phase to understand the change before delegating:
22-
- **`dev_refs`** — What depends on the changed code? What does it call?
23-
- **`dev_map`** — How central are these files? What subsystem are they in?
24-
- **`dev_patterns`** — Do the changes follow existing conventions?
25-
- **`dev_search`** — Are there similar implementations elsewhere?
26-
2717
## Workflow
2818

2919
### Phase 1: Understand the change
3020

3121
1. Get the diff: `git diff main...HEAD` or staged changes
32-
2. Use `dev_refs` on the key changed functions — who calls them? What do they call?
33-
3. Use `dev_map` — are these hot path files? Which subsystem?
34-
4. Read the diff carefully. Identify the areas of highest risk.
22+
2. Run `dev_refs` on the key changed functions — who calls them? What do they call?
23+
3. Run `dev_map` — are these hot path files? Which subsystem?
24+
4. Run `dev_patterns` on the changed files — do they follow existing conventions?
25+
5. Read the diff carefully. Identify the areas of highest risk.
3526

3627
### Phase 2: Plan specialist tasks
3728

.claude/agents/logic-reviewer.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ Every finding MUST include confidence: **HIGH** (verified from code), **MEDIUM**
6565

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

68-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?** `dev_refs` returns the call graph directly, `dev_search` finds related code by concept, `dev_patterns` compares error handling across files — each saves ~3,000-5,000 tokens vs manual file reading.
69-
70-
- [ ] 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
68+
Start by running these MCP tools on the changed functions:
69+
1. `dev_refs` on each modified function — trace callers and callees across packages.
70+
2. `dev_refs` with `dependsOn` on the changed files — trace file-to-file dependency paths.
71+
3. `dev_patterns` on changed files — compare error handling patterns against similar files.
72+
73+
Then verify:
74+
- [ ] Core exports consumed correctly by CLI, MCP server, and subagents (from `dev_refs` results)
75+
- [ ] Dependency chains make sense (from `dependsOn` results)
7276
- [ ] Type boundaries between packages match (no `any` casting to bridge mismatches)
7377
- [ ] Logger (@prosdevlab/kero) configuration consistent across consumers
74-
- [ ] Error handling patterns are consistent with existing code (verify with `dev_patterns`)
78+
- [ ] Error handling patterns consistent with existing code (from `dev_patterns` results)
7579

7680
## Design Echo Pass (Deep+ Effort)
7781

.claude/agents/plan-reviewer.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,22 @@ Two-pass review of execution plans in `.claude/da-plans/`. Validates completenes
1212

1313
This agent **NEVER modifies plans**. It reports issues for the author to fix.
1414

15-
## MCP Tools — Conserve Context
16-
17-
This agent runs in a long session with a finite context window. Every Grep → Read cycle burns ~5,000 tokens on irrelevant matches. MCP tools return only what you need.
18-
19-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
20-
21-
- **`dev_map`** — Verify structure claims in the plan against actual codebase layout.
22-
- **`dev_refs`** — Confirm dependency assertions. Use `dependsOn` to trace dependency chains between files.
23-
- **`dev_patterns`** — Check if proposed patterns match existing conventions.
24-
2515
## Two-Pass Review
2616

2717
### Pass 1: Engineer Review
2818

29-
Read the plan as a senior engineer. Use `dev_map` to verify structure claims, `dev_refs` to confirm dependency assertions, and `dev_patterns` to check if proposed patterns match existing conventions.
30-
31-
1. **Context** — Does it accurately describe what exists today? (Verify with `dev_map` and reading actual code)
32-
2. **Architecture** — Does the proposed design fit the existing monorepo structure?
33-
3. **Parts breakdown** — Are parts sized correctly? (Each should be 1-2 commits)
34-
4. **Dependencies** — Are cross-package dependencies identified? (Verify with `dev_refs`. Use `dependsOn` to trace dependency chains between files.)
35-
5. **Build order** — Does the implementation order respect the build dependency chain?
36-
6. **Breaking changes** — Are they identified and migration paths described?
19+
Read the plan as a senior engineer. Start by gathering context with MCP tools before evaluating.
20+
21+
1. Run `dev_map` to see the current codebase structure. Compare against the plan's architecture claims.
22+
2. Run `dev_refs` on the key functions the plan modifies. Use `dependsOn` to trace dependency chains between files the plan touches.
23+
3. Run `dev_patterns` on files the plan proposes to change. Check if the proposed code follows existing conventions.
24+
4. Now evaluate with the context you gathered:
25+
- **Context** — Does the plan accurately describe what exists today?
26+
- **Architecture** — Does the proposed design fit the actual structure you saw in `dev_map`?
27+
- **Parts breakdown** — Are parts sized correctly? (Each should be 1-2 commits)
28+
- **Dependencies** — Do the `dev_refs` results confirm the plan's dependency claims?
29+
- **Build order** — Does the implementation order respect the dependency chain?
30+
- **Breaking changes** — Are they identified and migration paths described?
3731

3832
### Pass 2: Test Engineer Review
3933

.claude/agents/quality-reviewer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ Maximum **5 SUGGESTION items** per review. If more found, pick the top 5 and not
4848

4949
### Readability & Simplification
5050

51-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?** `dev_patterns` compares patterns across similar files (~500 tokens vs ~3,000 for manual reads). `dev_search` checks if a utility exists by meaning, not just name.
51+
Run `dev_patterns` on changed files to find similar code and detect duplication. Run `dev_search` to check if a utility already exists before flagging missing abstractions.
5252

53-
- [ ] No code duplicating existing utilities — verify with `dev_patterns` and `dev_search`
53+
- [ ] No code duplicating existing utilities (from `dev_patterns` and `dev_search` results)
5454
- [ ] Functions reasonably sized (consider splitting if >50 lines)
5555
- [ ] Complex logic has comments explaining "why", not "what"
5656
- [ ] No premature abstractions for one-time operations

.claude/agents/quick-scout.md

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

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

13-
## MCP Tools — Conserve Context
14-
15-
This agent runs in a long session with a finite context window. Every Grep → Read cycle burns ~5,000 tokens on irrelevant matches. MCP tools return only what you need.
16-
17-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
18-
1913
## Capability Boundaries
2014

2115
You excel at:

.claude/agents/research-planner.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ sub-agents for external evidence.
1515

1616
This agent **NEVER writes code**. It produces research plans backed by evidence.
1717

18-
## MCP Tools — Conserve Context
19-
20-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
21-
22-
- **`dev_search`** — Find relevant code areas by meaning. Returns ranked snippets.
23-
- **`dev_map`** — Codebase structure with hot paths and subsystems.
24-
- **`dev_patterns`** — Compare patterns across similar files without reading each one.
25-
- **`dev_refs`** — Trace cross-package dependencies. Use `dependsOn` to trace chains.
26-
2718
## When to Use
2819

2920
- Before starting a feature that touches unfamiliar parts of the codebase

.claude/agents/security-reviewer.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@ 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-
## MCP Tools — Conserve Context
15+
## Before the Checklist
1616

17-
This agent runs in a long session with a finite context window. Every Grep → Read cycle burns ~5,000 tokens on irrelevant matches. MCP tools return only what you need.
18-
19-
**Before you Grep or Read, ask: can an MCP tool answer this without reading files?**
20-
21-
- **`dev_search`** — Find security-sensitive code ("user input", "shell execution", "token handling"). Returns ranked snippets.
22-
- **`dev_patterns`** — If one injection vector exists, the same pattern likely appears elsewhere. Scan for similar patterns across files.
23-
- **`dev_refs`** — Trace how user input flows through the system. Use `dependsOn` to trace dependency chains.
17+
1. Run `dev_search "user input"`, `dev_search "shell execution"`, `dev_search "token handling"` to find security-sensitive code in the diff area.
18+
2. Run `dev_refs` on any function that handles user input — trace how that input flows through the system.
19+
3. Run `dev_patterns` on files with injection vectors — if one exists, the same pattern likely appears elsewhere.
2420

2521
## Checklist
2622

0 commit comments

Comments
 (0)