You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Update Claude instructions to discourage direct codegraph tool usage in main session
Changes guidance to recommend spawning Explore agents for exploration questions instead of using codegraph_explore/codegraph_context directly in main session to avoid filling up context with large amounts of source code. Adds completeness signal to codegraph_explore output so agents know not to re-read files that already have source code included.
Copy file name to clipboardExpand all lines: src/installer/claude-md-template.ts
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -16,21 +16,25 @@ CodeGraph builds a semantic knowledge graph of codebases for faster, smarter cod
16
16
17
17
### If \`.codegraph/\` exists in the project
18
18
19
-
**Use codegraph tools directly in the main session.** Codegraph replaces the need for Explore agents in most cases. Instead of spawning an agent (which takes 30+ tool calls and 1+ minutes), use codegraph MCP tools directly for fast, structured answers:
19
+
**NEVER call \`codegraph_explore\` or \`codegraph_context\` directly in the main session.** These tools return large amounts of source code that fills up main session context. Instead, ALWAYS spawn an Explore agent for any exploration question (e.g., "how does X work?", "explain the Y system", "where is Z implemented?").
20
20
21
-
| Tool | Use For |
22
-
|------|---------|
23
-
| \`codegraph_explore\` | **Deep exploration** — comprehensive context for a topic in ONE call (replaces Explore agents) |
24
-
| \`codegraph_context\` | Quick context for a task (lighter than explore) |
25
-
| \`codegraph_search\` | Find symbols by name (functions, classes, types) |
26
-
| \`codegraph_callers\` | Find what calls a function |
27
-
| \`codegraph_callees\` | Find what a function calls |
28
-
| \`codegraph_impact\` | See what's affected by changing a symbol |
29
-
| \`codegraph_node\` | Get details + source code for a symbol |
21
+
**When spawning Explore agents**, include this instruction in the prompt:
22
+
23
+
> This project has CodeGraph initialized (.codegraph/ exists). Use \`codegraph_explore\` as your PRIMARY tool — it returns full source code sections from all relevant files in one call.
24
+
>
25
+
> **Rules:**
26
+
> 1. Make at most 3 \`codegraph_explore\` calls — one broad query, then up to 2 focused follow-ups.
27
+
> 2. Do NOT re-read files that codegraph_explore already returned source code for. The source sections are complete and authoritative.
28
+
> 3. Only fall back to grep/glob/read for files listed under "Additional relevant files" if you need more detail, or if codegraph returned no results.
30
29
31
-
**For deep exploration questions** (e.g., "how does the undo/redo system work?"), use \`codegraph_explore\` directly. It returns full source code sections from all relevant files in a single call — no need to spawn an Explore agent.
30
+
**The main session may only use these lightweight tools directly** (for targeted lookups before making edits, not for exploration):
32
31
33
-
**Do NOT tell Explore agents to use codegraph tools.** Testing shows Explore agents use codegraph for discovery then still read all the same files — making them slower, not faster. Codegraph's value is in the main session where it replaces the need for exhaustive file reading.
Copy file name to clipboardExpand all lines: src/mcp/tools.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -849,6 +849,11 @@ export class ToolHandler {
849
849
}
850
850
}
851
851
852
+
// Add completeness signal so agents know they don't need to re-read these files
853
+
lines.push('');
854
+
lines.push('---');
855
+
lines.push(`> **Complete source code is included above for ${filesIncluded} files.** You do NOT need to re-read these files — the relevant sections are already shown in full. Only use Read/Grep for files listed under "Additional relevant files" if you need more detail.`);
0 commit comments