Continuous improvement starts with visibility. Kaizen analyzes code quality, complexity, and churn to identify technical debt and hotspots in your codebase. It generates health grades, actionable concerns, and interactive visualizations.
- π― A-F Health Grades with 0-100 scores across complexity, maintainability, churn, function size, and code structure
- π Cyclomatic & Cognitive Complexity, Halstead Metrics, Maintainability Index, and hotspot detection
- π Multi-Language β Go (native AST), Python, Kotlin & Swift (tree-sitter)
- π¨ Interactive Visualizations β HTML treemaps, Sankey diagrams, call graphs, terminal charts
- π‘οΈ CI Quality Gate β blast-radius detection with exit codes for pipelines
- π€ GitHub PR Action β automatic PR comments with score deltas, hotspot tracking, and call graph diffs
- π Historical Tracking β SQLite snapshots with trend analysis and diff reporting
- π₯ Code Ownership β CODEOWNERS-based team metrics and reports
Kaizen practices what it preaches. Here are the results from analyzing its own codebase:
Grade B β 88/100 β
| Metric | Value | Status |
|---|---|---|
| π Files Analyzed | 53 | |
| βοΈ Total Functions | 394 | |
| π§ Avg Cyclomatic Complexity | 4.5 | β Excellent |
| π§© Avg Cognitive Complexity | 4.9 | β Excellent |
| π Avg Function Length | 27 lines | β Excellent |
| π§ Avg Maintainability Index | 86.8 | β Good |
| π₯ Hotspots | 0 | β Perfect |
Component Scores:
| Component | Score | Rating |
|---|---|---|
| π§ Complexity | 77/100 | Good |
| π§ Maintainability | 87/100 | Good |
| π Function Size | 92/100 | Excellent |
| ποΈ Code Structure | 100/100 | Excellent |
| Grade | Score | Meaning |
|---|---|---|
| π’ A | 90β100 | Excellent β well-maintained, low risk |
| π’ B | 75β89 | Good β minor improvements suggested |
| π‘ C | 60β74 | Fair β consider refactoring |
| π΄ D | 40β59 | Poor β significant technical debt |
| π¨ F | 0β39 | Critical β urgent refactoring needed |
| Issue | Threshold | Why It Matters |
|---|---|---|
| π΄ High Complexity | CC > 10 | Error-prone, hard to test |
| π‘ Low Maintainability | MI < 20 | Hard to understand and modify |
| π΄ Long Functions | > 50 lines | Harder to test and review |
| π΄ Deep Nesting | > 4 levels | Confusing control flow |
| π‘ High Churn | > 10 commits | Unstable, frequently changing |
| π Hotspots | High CC + High churn | Top priority for refactoring |
Add Kaizen to any repository to get automatic code quality comments on every pull request.
Create .github/workflows/kaizen.yml in your repository:
name: Kaizen PR Analysis
on:
pull_request:
branches: [main]
jobs:
kaizen:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: acollie/kaizen@v0.1.0-beta
with:
path: "."
base-branch: mainEvery PR will receive a comment showing score changes, complexity metrics, and hotspot status. The comment is updated in-place on each push β never duplicated.
π See full Action docs for all inputs, outputs, and examples.
git clone https://github.com/acollie/kaizen.git
cd kaizen
./install.sh
kaizen --versioncd /path/to/your/project
kaizen analyze --path=.
kaizen visualize --format=html
kaizen report owners# π¨ Interactive heatmap
kaizen visualize --metric=complexity --format=html --open
# π‘οΈ CI quality gate
kaizen check --base=main --path=.
# π Function call graph
kaizen callgraph --path=. --format=html
# π Call graph filtered to changed functions only
kaizen callgraph --path=. --base=main --format=svg
# π Compare with previous analysis
kaizen diff --path=.
# π Track trends over time
kaizen trend overall_score --days=30
# π₯ Team ownership report
kaizen report owners --format=html
# π Code ownership Sankey diagram
kaizen sankey --input=kaizen-results.json
# π Analysis history
kaizen history list| Command | Description |
|---|---|
kaizen analyze |
π¬ Analyze a codebase and generate metrics (JSON output) |
kaizen visualize |
π¨ Generate interactive heatmaps (HTML, SVG, or terminal) |
kaizen check |
π‘οΈ CI quality gate β warn on high blast-radius function changes |
kaizen callgraph |
π Generate function call graph (HTML, SVG, or JSON) |
kaizen pr-comment |
π€ Generate a GitHub PR comment from base vs head analysis |
kaizen sankey |
π Generate Sankey diagram of code ownership flow |
kaizen diff |
π Compare current analysis with previous snapshot |
kaizen trend |
π Visualize metric trends over time (ASCII, HTML, or JSON) |
kaizen report owners |
π₯ Generate code ownership report |
kaizen history list |
π List all stored analysis snapshots |
kaizen history show |
π Display detailed snapshot information |
kaizen history prune |
ποΈ Remove old snapshots |
| Input | Description | Default |
|---|---|---|
path |
Directory to analyze | . |
base-branch |
Branch to compare against | main |
skip-churn |
Skip git churn analysis for faster runs | true |
github-token |
GitHub token for posting PR comments | ${{ github.token }} |
fail-on-regression |
Fail the action if the score drops | false |
languages |
Comma-separated list of languages to include | all |
include-callgraph |
Include SVG call graph of changed functions (Go only) | false |
| Output | Description |
|---|---|
score-delta |
Numeric score change between base and head |
grade |
Current grade letter (A-F) |
has-concerns |
Whether blast-radius concerns were found |
name: Kaizen PR Analysis
on:
pull_request:
branches: [main, develop]
jobs:
kaizen:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: acollie/kaizen@v0.1.0-beta
id: kaizen
with:
path: "."
base-branch: main
skip-churn: "true"
fail-on-regression: "true"
languages: "go,kotlin"
include-callgraph: "true"
- name: Check results
run: |
echo "Score delta: ${{ steps.kaizen.outputs.score-delta }}"
echo "Grade: ${{ steps.kaizen.outputs.grade }}"
echo "Has concerns: ${{ steps.kaizen.outputs.has-concerns }}"- π― Grade and Score β overall health grade (A-F) with numeric score out of 100
- π Score Delta β how much the score changed compared to the base branch
- π Metrics Table β overall score, avg complexity, maintainability, hotspot count, function count with deltas
- π₯ Hotspot Changes β new hotspots introduced, hotspots fixed, and persistent hotspots
- π₯ Blast-Radius Warnings β functions with high fan-in (many callers) that were modified
- π Call Graph (optional) β SVG artifact showing changed functions and their callers/callees
# Pin to a specific release (recommended)
- uses: acollie/kaizen@v0.1.0-beta
# Or track the latest on main (may include breaking changes)
- uses: acollie/kaizen@mainThe default ${{ github.token }} works for most cases. If you need to trigger other workflows from the comment, use a Personal Access Token or GitHub App token:
- uses: acollie/kaizen@v0.1.0-beta
with:
github-token: ${{ secrets.KAIZEN_TOKEN }}- π Web dashboard for team health monitoring
- π€ GitHub integration (automatic PR comments via reusable Action)
- π Complete Python analyzer with tree-sitter AST parsing
- π Advanced trend prediction
- π¦ Rust analyzer
- π± TypeScript/JavaScript analyzer
- β Java analyzer
- β‘ Performance optimization for massive codebases (100M+ LOC)
- π¬ Better error messages and recovery
- π§΅ Parallel analysis for multi-core systems
- π Incremental analysis (only changed files)
Kaizen uses a modular, language-agnostic architecture:
- π Interface-based language analyzers β easy to add new languages
- π³ Tree-sitter AST parsing β accurate syntax understanding (Python, Kotlin, Swift)
- πΉ Go's
astpackage β native support for Go analysis - πΎ SQLite time-series database β efficient historical tracking
- β¨οΈ Cobra CLI framework β professional command structure
π See Architecture Guide for technical details.
| Language | Status | Parser | Coverage |
|---|---|---|---|
| πΉ Go | β Full | go/ast | 95%+ |
| π Python | β Full | tree-sitter | 90%+ |
| π£ Kotlin | β Full | tree-sitter | 90%+ |
| π Swift | β Full | tree-sitter | 90%+ |
Per-File: lines of code, import count, duplication percentage
Per-Function: length, parameter count, cyclomatic complexity, cognitive complexity, nesting depth, Halstead metrics, maintainability index, fan-in/fan-out
πΊοΈ Interactive Heatmap β drill-down treemap with color-coded metrics. Color intensity = severity, box size = code volume, click to explore, hover for details.
π Call Graph β D3.js force-directed graph showing function call relationships. Node size = fan-in, color = complexity. Filter by --base to show only changed functions.
π Sankey Diagram β code ownership flow showing team-to-function dependencies. Flow width = call frequency.
π Terminal Charts β quick ASCII trend lines without opening a browser.
| Project Size | Estimated Time |
|---|---|
| 10K LOC | ~0.1-0.5s |
| 100K LOC | ~1-3s |
| 1M LOC | ~15-25s |
| 10M+ LOC | ~3-5m |
π‘ Use --skip-churn to disable git operations (adds 20-40% overhead). Run on SSD for 2-3x faster I/O. Exclude large directories with .kaizenignore.
We welcome contributions! See CONTRIBUTING.md for code style, testing requirements, and pull request process.
- Create
pkg/languages/<lang>/directory - Implement the
LanguageAnalyzerinterface - Register in
pkg/languages/registry.go - Add tests
- Submit PR
π See Adding Languages for the detailed guide.
- π Report Bug
- π‘ Request Feature
All code changes are tested across Go versions 1.21, 1.22, and 1.23 on Linux:
- π§ͺ Unit Tests: 50+ test files covering analyzers, metrics, and language parsers
- π Integration Tests: end-to-end analysis and visualization pipeline validation
- π Coverage Target: 50%+ on main branch with automated codecov checks
- π CI Pipeline: automated testing, linting (
golangci-lint), and build verification on every PR
- πΉ Go 1.21+
- π Git (optional β use
--skip-churnwithout it) - π³ Tree-sitter libraries for Kotlin/Swift (auto-installed)
- π Usage Guide β installation, configuration, daily workflow
- ποΈ Architecture Guide β internals, metrics, extending
- π Self-Analysis Report β Kaizen analyzing itself
- π¬ GitHub Discussions
MIT License β see LICENSE for details.
Built with go-tree-sitter, Cobra, D3.js, and GORM.
