Knowledge graphs
Graph model
The knowledge graph is a directed graph stored in SQLite and serialized to .genome/graph.json.
- File nodes — one per source file (
file:path/to/module.py) - Symbol nodes — functions, classes, methods with qualified names
- Import edges — module dependencies
- Call edges — resolved invocations where possible
- Inheritance edges — class hierarchies
Incremental builds
After the first full scan, Codegenome can update only changed files. The scan cache at .genome/scan_cache.db avoids re-parsing unchanged content.
Use codegenome analyze . for a standard incremental build, or the legacy CLI:
python -m codegenome --workspace . --build python -m codegenome --workspace . --build --full
Graph intelligence
Built-in analysis includes:
- Dead code detection
- Entry points
- God nodes (high betweenness)
- Circular dependencies
- Complexity and churn rankings
- Community detection (Leiden clustering on macro graphs)
These power MCP tools like get_dead_code and get_god_nodes. See MCP tools.
Timeline snapshots
Each build can append a snapshot to .genome/watcher.db, enabling:
- Timeline dumps per node
- Diffs between snapshot IDs
- Churn rankings over time
Query via legacy CLI flags: --dump-timeline, --dump-changes, --dump-churn.
Artifacts
All paths are relative to your workspace root (the project you analyze). Details: Workspace artifacts.