Installer now creates/updates CLAUDE.md with CodeGraph instructions

- Added claude-md-template.ts with the instructions template
- Installer writes to ~/.claude/CLAUDE.md (global) or ./.claude/CLAUDE.md (local)
- Smart detection: updates existing CodeGraph section or appends if not found
- Uses HTML comment markers for reliable section replacement on upgrades

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Colby McHenry
2026-01-19 15:30:13 -06:00
co-authored by Claude Opus 4.5
parent 1ca43a85e0
commit 8d1fb680e5
4 changed files with 163 additions and 4 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* CLAUDE.md template for CodeGraph instructions
*
* This template is injected into ~/.claude/CLAUDE.md (global) or ./.claude/CLAUDE.md (local)
* Keep this in sync with the README.md "Recommended: Add Global Instructions" section
*/
// Markers to identify CodeGraph section for updates
export const CODEGRAPH_SECTION_START = '<!-- CODEGRAPH_START -->';
export const CODEGRAPH_SECTION_END = '<!-- CODEGRAPH_END -->';
export const CLAUDE_MD_TEMPLATE = `${CODEGRAPH_SECTION_START}
## CodeGraph
CodeGraph builds a semantic knowledge graph of codebases for faster, smarter code exploration.
### If \`.codegraph/\` exists in the project
**Use codegraph tools for faster exploration.** These tools provide instant lookups via the code graph instead of scanning files:
| Tool | Use For |
|------|---------|
| \`codegraph_search\` | Find symbols by name (functions, classes, types) |
| \`codegraph_context\` | Get relevant code context for a task |
| \`codegraph_callers\` | Find what calls a function |
| \`codegraph_callees\` | Find what a function calls |
| \`codegraph_impact\` | See what's affected by changing a symbol |
| \`codegraph_node\` | Get details + source code for a symbol |
**When spawning Explore agents in a codegraph-enabled project:**
Tell the Explore agent to use codegraph tools for faster exploration.
**For quick lookups in the main session:**
- Use \`codegraph_search\` instead of grep for finding symbols
- Use \`codegraph_callers\`/\`codegraph_callees\` to trace code flow
- Use \`codegraph_impact\` before making changes to see what's affected
### If \`.codegraph/\` does NOT exist
At the start of a session, ask the user if they'd like to initialize CodeGraph:
"I notice this project doesn't have CodeGraph initialized. Would you like me to run \`codegraph init -i\` to build a code knowledge graph?"
${CODEGRAPH_SECTION_END}`;