Graph Commands
codeknit provides two powerful graph commands to help you understand and improve your codebase structure: graph show for interactive visualization and graph analyze for automated structural analysis.
graph show
Section titled “graph show”Generates an interactive HTML graph visualization of your codebase.
codeknit graph show <input-path>This command parses your codebase and produces a self-contained HTML file with an interactive graph visualization. Symbols (functions, classes, types) appear as nodes, and their relationships (calls, contains, implements) as edges. The visualization opens automatically in your default browser.
| Flag | Default | Description |
|---|---|---|
-o, --output |
./skeleton/codeknit-graph.html |
Output HTML file path |
--collect-test |
false |
Include test files in analysis |
--workers |
NumCPU |
Max concurrent parsing goroutines |
--verbose |
false |
Print progress information during processing |
Examples
Section titled “Examples”# Generate default visualizationcodeknit graph show ./myproject
# Custom output filecodeknit graph show ./myproject -o graph.html
# Include test filescodeknit graph show ./src --collect-testgraph analyze
Section titled “graph analyze”Runs structural graph algorithms on your codebase and emits an LLM-readable .skt report containing code quality insights.
codeknit graph analyze <input-path>This command detects common code quality issues such as cyclic dependencies, hub symbols, dead code, god classes, and architectural bottlenecks.
Algorithms
Section titled “Algorithms”The analysis includes 17 structural graph algorithms:
- Cyclic dependencies (Tarjan’s SCC)
- Hub detection (high fan-in/fan-out coupling)
- Orphan detection (dead code candidates)
- God class/function detection (excessive children)
- Instability metric (Robert C. Martin’s Ce/(Ca+Ce))
- Deep inheritance chains
- Betweenness centrality (bottleneck detection)
- Articulation points (single points of failure)
- PageRank (recursive importance)
- Transitive fan-in (blast radius)
- Change propagation simulation
- Circular package dependencies
- Layer violation detection
- Reachability from entry points
- Weakly connected components
- Dependency weight (package coupling strength)
- Distance from Main Sequence (A+I balance)
| Flag | Default | Description |
|---|---|---|
-o, --output |
./skeleton/graph_analysis.skt |
Output .skt file path |
--collect-test |
false |
Include test files in analysis |
--workers |
NumCPU |
Max concurrent parsing goroutines |
--verbose |
false |
Print progress information during processing |
--fan-threshold |
10 |
Minimum fan-in or fan-out to flag a hub symbol |
--god-threshold |
15 |
Minimum contains-edge count to flag a god class/function |
--max-inheritance-depth |
5 |
Flag inheritance chains deeper than this |
--top-n |
30 |
Cap ranked output sections; 0 = no limit |
--betweenness-threshold |
0.001 |
Minimum betweenness centrality value to report |
--propagation-cutoff |
0.05 |
Minimum probability to continue change propagation |
Examples
Section titled “Examples”# Run structural analysis with defaultscodeknit graph analyze ./myproject
# Custom output and thresholdscodeknit graph analyze ./myproject -o analysis.skt --fan-threshold 15
# Show more results per sectioncodeknit graph analyze ./myproject --top-n 50
# Include test filescodeknit graph analyze ./src --collect-test