| name | code-graph |
| description | This skill should be used when understanding code structure, finding dependencies between functions/classes, tracing call graphs, or exploring code relationships. Trigger phrases include 'code graph', 'call graph', 'who calls', 'what calls', 'find dependencies', 'code structure', 'inheritance', 'find paths'. |
Code Graph Skill
You own the full cgraph lifecycle: database, indexing, and querying. The user should never need to run cgraph commands manually.
Ownership Rules
- If
cgraph commands fail with connection errors, run cgraph ensure-db first.
- If
cgraph is not found, see management.md for installation instructions.
- Index at session start or after significant code changes:
cgraph index . --ignore node_modules --ignore venv --ignore .git --ignore __pycache__
- No need to re-index between consecutive queries if no code has changed.
- All command output is JSON on stdout. Status/progress goes to stderr.
--repo defaults to the current directory name if omitted.
Indexing
cgraph index . --ignore node_modules --ignore venv --ignore .git --ignore __pycache__
cgraph index /path/to/project --repo my-project --ignore node_modules
cgraph index-repo https://github.com/org/repo --ignore node_modules
Searching
cgraph search get_user
cgraph search parse
cgraph search MyClass
Results return JSON with node id, labels (File, Class, Function, etc.), and properties (name, path, src_start, src_end). Use the id for follow-up queries.
Exploring Relationships
cgraph neighbors 42 --repo my-project
cgraph neighbors 42 --rel CALLS
cgraph neighbors 42 --rel DEFINES
cgraph neighbors 42 --label Function
cgraph neighbors 42 55 --repo my-project
Finding Paths
cgraph paths 42 99 --repo my-project
Follows CALLS edges to find how one function reaches another.
Repository Info
cgraph list
cgraph info --repo my-project
Working with Results
- Search results include
path, src_start, src_end โ use the Read tool to load the actual source code at those locations.
- Node labels: File, Class, Function, Interface, Struct
- Edge types: DEFINES (hierarchy), CALLS (call graph), EXTENDS (inheritance), IMPLEMENTS (interfaces), RETURNS (return types), PARAMETERS (param types)
- See
querying.md for detailed JSON structures and common query patterns.