Skip to content

Commit 5965fb4

Browse files
docs: add AI Agent Guide with 6-step workflow, command reference, and MCP mapping
New docs/ai-agent-guide.md covering token-saving patterns, the orient-locate- understand-context-impact-verify workflow, complete command reference with MCP tool mappings (17 tools), Claude Code hooks documentation, CLAUDE.md template, CI/CD integration, and agent tips. Updates README.md: MCP tool count 13→17, modernized CLAUDE.md template with context/explain/where commands, added AI Agent Guide cross-reference. Updates docs/recommended-practices.md: added cross-references to the new guide, updated MCP tools list with context/explain/where/list_repos, modernized the CLAUDE.md template.
1 parent 0e15f12 commit 5965fb4

3 files changed

Lines changed: 901 additions & 45 deletions

File tree

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Most code graph tools make you choose: **fast local analysis with no AI, or powe
9393
| **** | **Always-fresh graph** | Three-tier change detection: journal (O(changed)) → mtime+size (O(n) stats) → hash (O(changed) reads). Sub-second rebuilds even on large codebases. Competitors re-index everything from scratch; Merkle-tree approaches still require O(n) filesystem scanning |
9494
| **🔓** | **Zero-cost core, LLM-enhanced when you want** | Full graph analysis with no API keys, no accounts, no cost. Optionally bring your own LLM provider for richer embeddings and AI-powered search — your code only goes to the provider you already chose |
9595
| **🔬** | **Function-level, not just files** | Traces `handleAuth()``validateToken()``decryptJWT()` and shows 14 callers across 9 files break if `decryptJWT` changes |
96-
| **🤖** | **Built for AI agents** | 13-tool [MCP server](https://modelcontextprotocol.io/) — AI assistants query your graph directly. Single-repo by default, your code doesn't leak to other projects |
96+
| **🤖** | **Built for AI agents** | 17-tool [MCP server](https://modelcontextprotocol.io/) — AI assistants query your graph directly. Single-repo by default, your code doesn't leak to other projects |
9797
| **🌐** | **Multi-language, one CLI** | JS/TS + Python + Go + Rust + Java + C# + PHP + Ruby + HCL in a single graph — no juggling Madge, pyan, and cflow |
9898
| **💥** | **Git diff impact** | `codegraph diff-impact` shows changed functions, their callers, and full blast radius — ships with a GitHub Actions workflow |
9999
| **🧠** | **Semantic search** | Local embeddings by default, LLM-powered embeddings when opted in — multi-query with RRF ranking via `"auth; token; JWT"` |
@@ -132,7 +132,7 @@ Here is a cold, analytical breakdown to help you decide which tool fits your wor
132132
| Aspect | Optave Codegraph | Narsil-MCP |
133133
| :--- | :--- | :--- |
134134
| **Philosophy** | Lean, deterministic, AI-optimized | Comprehensive, feature-dense |
135-
| **AI Tool Count** | 13 focused tools | 90 distinct tools |
135+
| **AI Tool Count** | 17 focused tools | 90 distinct tools |
136136
| **Language Support** | 11 languages | 32 languages |
137137
| **Primary Interface** | CLI-first with MCP integration | MCP-first (CLI is secondary) |
138138
| **Supply Chain Risk** | Low (minimal dependency tree) | Higher (requires massive dependency graph for embedded ML/scanners) |
@@ -141,7 +141,7 @@ Here is a cold, analytical breakdown to help you decide which tool fits your wor
141141
#### Choose Codegraph if:
142142

143143
* **You need the fastest possible incremental rebuilds.** Codegraph’s three-tier change detection (journal → mtime+size → hash) achieves true O(changed) when the watcher is running — only touched files are processed. Narsil’s Merkle trees still require O(n) filesystem scanning to recompute hashes on every rebuild, even when nothing changed. On a 3,000-file project, this is the difference between near-instant and noticeable.
144-
* **You want to optimize AI agent reasoning.** Large Language Models degrade in performance and hallucinate when overwhelmed with choices. Codegraph’s tight 13-tool surface area ensures agents quickly understand their capabilities without wasting context window tokens.
144+
* **You want to optimize AI agent reasoning.** Large Language Models degrade in performance and hallucinate when overwhelmed with choices. Codegraph’s tight 17-tool surface area ensures agents quickly understand their capabilities without wasting context window tokens.
145145
* **You are concerned about supply chain attacks.** To support 90 tools, SBOMs, and neural embeddings, a tool must pull in a massive dependency tree. Codegraph keeps its dependencies minimal, dramatically reducing the risk of malicious code sneaking onto your machine.
146146
* **You want deterministic blast-radius checks.** Features like `diff-impact` are built specifically to tell you exactly how a changed function cascades through your codebase before you merge a PR.
147147
* **You value a strong standalone CLI.** You want to query your code graph locally without necessarily spinning up an AI agent.
@@ -190,7 +190,7 @@ codegraph deps src/index.ts # file-level import/export map
190190
| 📤 | **Export** | DOT (Graphviz), Mermaid, and JSON graph export |
191191
| 🧠 | **Semantic search** | Embeddings-powered natural language search with multi-query RRF ranking |
192192
| 👀 | **Watch mode** | Incrementally update the graph as files change |
193-
| 🤖 | **MCP server** | 13-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo |
193+
| 🤖 | **MCP server** | 17-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo |
194194
| 🔒 | **Your code, your choice** | Zero-cost core with no API keys. Optionally enhance with your LLM provider — your code only goes where you send it |
195195

196196
## 📦 Commands
@@ -391,7 +391,7 @@ Metrics are normalized per file for cross-version comparability. Times above are
391391

392392
### MCP Server
393393

394-
Codegraph includes a built-in [Model Context Protocol](https://modelcontextprotocol.io/) server with 13 tools, so AI assistants can query your dependency graph directly:
394+
Codegraph includes a built-in [Model Context Protocol](https://modelcontextprotocol.io/) server with 17 tools, so AI assistants can query your dependency graph directly:
395395

396396
```bash
397397
codegraph mcp # Single-repo mode (default) — only local project
@@ -405,20 +405,35 @@ codegraph mcp --repos a,b # Multi-repo with allowlist
405405

406406
### CLAUDE.md / Agent Instructions
407407

408-
Add this to your project's `CLAUDE.md` to help AI agents use codegraph:
408+
Add this to your project's `CLAUDE.md` to help AI agents use codegraph (full template in the [AI Agent Guide](docs/ai-agent-guide.md#claudemd-template)):
409409

410410
```markdown
411411
## Code Navigation
412412

413413
This project uses codegraph. The database is at `.codegraph/graph.db`.
414414

415-
- **Before modifying a function**: `codegraph fn <name> --no-tests`
416-
- **Before modifying a file**: `codegraph deps <file>`
417-
- **To assess PR impact**: `codegraph diff-impact --no-tests`
418-
- **To find entry points**: `codegraph map`
419-
- **To trace breakage**: `codegraph fn-impact <name> --no-tests`
420-
421-
Rebuild after major structural changes: `codegraph build`
415+
### Before modifying code, always:
416+
1. `codegraph where <name>` — find where the symbol lives
417+
2. `codegraph explain <file-or-function>` — understand the structure
418+
3. `codegraph context <name> -T` — get full context (source, deps, callers)
419+
4. `codegraph fn-impact <name> -T` — check blast radius before editing
420+
421+
### After modifying code:
422+
5. `codegraph diff-impact --staged -T` — verify impact before committing
423+
424+
### Other useful commands
425+
- `codegraph build .` — rebuild the graph (incremental by default)
426+
- `codegraph map` — module overview
427+
- `codegraph fn <name> -T` — function call chain
428+
- `codegraph deps <file>` — file-level dependencies
429+
- `codegraph search "<query>"` — semantic search (requires `codegraph embed`)
430+
- `codegraph cycles` — check for circular dependencies
431+
432+
### Flags
433+
- `-T` / `--no-tests` — exclude test files (use by default)
434+
- `-j` / `--json` — JSON output for programmatic use
435+
- `-f, --file <path>` — scope to a specific file
436+
- `-k, --kind <kind>` — filter by symbol kind
422437

423438
### Semantic search
424439

@@ -456,6 +471,8 @@ See **[docs/recommended-practices.md](docs/recommended-practices.md)** for integ
456471
- **Developer workflow** — watch mode, explore-before-you-edit, semantic search
457472
- **Secure credentials**`apiKeyCommand` with 1Password, Bitwarden, Vault, macOS Keychain, `pass`
458473

474+
For AI-specific integration, see the **[AI Agent Guide](docs/ai-agent-guide.md)** — a comprehensive reference covering the 6-step agent workflow, complete command-to-MCP mapping, Claude Code hooks, and token-saving patterns.
475+
459476
## 🔁 CI / GitHub Actions
460477

461478
Codegraph ships with a ready-to-use GitHub Actions workflow that comments impact analysis on every pull request.

0 commit comments

Comments
 (0)