Graph Commands
codeknit provides graph commands to visualize structure, run automated analysis, and combine the current dependency graph with Git change history.
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 22 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)
- Shotgun surgery detection
- Feature envy detection
- Stable dependency violations
- Interface segregation violations
- Containment depth
| 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-testgraph hotspots
Section titled “graph hotspots”Ranks files that are both frequently changed and structurally important:
codeknit graph hotspots <input-path>The score combines commit frequency, line churn, and recency with file-level PageRank, transitive fan-in, and betweenness centrality. The report also identifies temporal coupling between files that repeatedly change in the same commits.
Merge commits are excluded by default. Commits changing more than 50 files are also excluded so generated, vendored, or mechanical bulk changes do not distort the results.
| Flag | Default | Description |
|---|---|---|
-o, --output |
./skeleton/hotspots.skt |
Output file path |
--format |
skt |
Output format: skt or json |
--since |
12mo |
History window, such as 180d, 12mo, or 2y |
--max-commits |
2000 |
Maximum commits to inspect |
--max-files-per-commit |
50 |
Exclude commits changing more files |
--min-cochanges |
3 |
Minimum shared commits for temporal coupling |
--top-n |
30 |
Maximum results per report section |
--include-merges |
false |
Include merge commits |
--collect-test |
false |
Include test files |
--workers |
NumCPU |
Maximum concurrent parsing goroutines |
--verbose |
false |
Print progress information |
Examples
Section titled “Examples”# Analyze the last 12 monthscodeknit graph hotspots ./myproject
# Analyze two years and emit JSONcodeknit graph hotspots ./myproject --since 2y --format json -o hotspots.json
# Include larger commits and require stronger couplingcodeknit graph hotspots . --max-files-per-commit 100 --min-cochanges 5