Claude-code-skills ln-020-codegraph
Builds and queries code knowledge graph for dependency analysis, references, implementations, and architecture overview. Use when starting work on unfamiliar codebase or before refactoring.
git clone https://github.com/levnikolaevich/claude-code-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/levnikolaevich/claude-code-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills-catalog/ln-020-codegraph" ~/.claude/skills/levnikolaevich-claude-code-skills-ln-020-codegraph && rm -rf "$T"
skills-catalog/ln-020-codegraph/SKILL.mdPaths: File paths are relative to skills repo root.
Code Knowledge Graph
Type: Standalone Utility Category: 0XX Dev Environment
Indexes codebase into a layered graph (tree-sitter AST → SQLite) and provides dependency analysis, path tracing, references, implementations, and architecture overview via MCP tools.
Inputs
| Input | Required | Source | Description |
|---|---|---|---|
| yes | args or CWD | Project root to index |
| no | args | Specific action: , , , , , |
When to Use
- Starting work on an unfamiliar codebase →
+indexarchitecture - Before refactoring a function/class →
+find_symbols
+inspect_symboltrace_paths - Understanding call flow →
trace_paths - Finding a symbol quickly →
search
Workflow
Phase 1: Index
Check if graph exists (
.hex-skills/codegraph/index.db in project root).
If NOT exists:
Call: index_project({ path: "{project_path}" })
If exists (re-index on demand):
Call: index_project({ path: "{project_path}" })
Idempotent — skips unchanged files automatically.
Phase 2: Query
Route based on user intent:
| User says | Tool | Parameters |
|---|---|---|
| "Show dependencies" / "What uses X?" | | |
| "Who calls X?" / "What does X call?" | | |
| "Tell me about X" / "Context of X" | | |
| "Project structure" / "Architecture" | | |
| "Find symbol X" | | |
"Find / / pattern" | | `{ path: "{project_path}", pattern: "app\.get\( |
| "Find duplicate code / hotspots / unused exports" | | |
| "Circular dependencies / module coupling" | | |
| "Implementations / overrides" | | |
| "Dataflow / propagation" | | |
| "Review a diff / worktree" | | |
| "Check what editing this range affects" | | |
Canonical selector rule: Semantic tools accept exactly one selector:
symbol_idworkspace_qualified_namequalified_name
+namefile
Preferred flow: use
find_symbols only after narrowing path as much as practical, then feed the returned workspace_qualified_name into inspect_symbol, trace_paths, find_references, or find_implementations for exact follow-up queries.
Query boundary rule:
find_symbols is name-based discovery only. For code fragments like export function or unresolved member-call patterns like app.get(...), use grep_search instead of treating them as symbols.
Ambiguity rule: if
find_symbols returns truncated: true or a large candidate_count, refine with path, then name + file or workspace_qualified_name instead of widening the graph query.
Path rule:
path may be the indexed project root or any file/subdirectory inside that indexed project.
Dataflow anchors:
trace_dataflow requires source.anchor and optional sink.anchor. Use:
for function parametersparam
for local variableslocal
for function returnsreturn
withproperty
for bounded property flowaccess_path
Precision controls:
inspect_symbol, trace_paths, and find_references support min_confidence (low, inferred, exact, precise) when the caller wants to suppress weaker parser-only facts.
Phase 3: Present Results
- Show MCP tool output directly (markdown tables)
- For code snippets referenced in results, use
with line ranges; addhex-line read_file
only when you intend to carry revision/checksums into an editedit_ready=true, verbosity="full" - Suggest follow-up queries based on results:
- After
with a clean top match → suggestfind_symbols
withinspect_symbolworkspace_qualified_name - After
withfind_symbols
→ suggest narrowingtruncated: true
or switching topath
before any deeper graph toolname + file - After
→ suggestinspect_symbol
if refactoringtrace_paths - After
→ suggesttrace_paths
orfind_references
depending on symbol kindfind_implementations - After empty
from a broad or module-level selector → suggesttrace_paths
orinspect_symbol
instead of assuming there are no dependenciesanalyze_architecture
Supported Languages
| Language | Extensions | Coverage |
|---|---|---|
| JavaScript | .js, .mjs, .cjs, .jsx | Strongest semantic coverage |
| TypeScript / TSX | .ts, .tsx | Strongest semantic coverage |
| Python | .py | Workspace-aware definitions, calls, imports, unused exports; optional precise overlay when provider is installed |
| C# | .cs | Workspace-aware definitions, calls, project/namespace ownership, type relations; optional precise overlay when provider is installed |
| PHP | .php | Workspace-aware definitions, calls, PSR-4 namespace imports, unused exports; optional precise overlay when provider is installed |
MCP Server Setup
Add to
.mcp.json:
{ "mcpServers": { "hex-graph": { "command": "node", "args": ["{skills_repo}/mcp/hex-graph-mcp/server.mjs"] } } }
Definition of Done
- Project indexed (index_project returns success)
- Query results shown to user
- Follow-up suggestions provided
Version: 0.1.0 Last Updated: 2026-03-20