| name | kaizen |
| description | Apply kaizen continuous improvement philosophy to any codebase โ identifying waste, unevenness, and overburden at the code level and producing small, actionable improvement opportunities. Triggers on '/kaizen', 'kaizen this codebase', 'continuous improvement audit', 'find waste in this code', 'what small improvements can we make?', 'improve this codebase incrementally', 'code health check', 'codebase hygiene', 'tech debt sweep', or any request to find incremental improvement opportunities in code. Also trigger when the user says 'clean up', 'tidy up', 'make this codebase better', or expresses frustration about code quality without wanting a full rewrite. This is NOT a code review skill for PRs or diffs โ kaizen operates on the codebase as a whole or a focus area, looking for systemic improvement opportunities. Use this skill even for small codebases โ the philosophy scales down gracefully. |
Kaizen (ๆนๅ) โ Codebase Continuous Improvement
Smallest changes compounding into significant quality. Every file you touch leaves better than found.
Input Modes
/kaizen
Run all seven dimensions across the codebase. Full improvement map.
/kaizen "focus description"
All dimensions, weighted and prioritized through user's lens.
Examples:
/kaizen "file sizes โ nothing should exceed 500 LOC"
/kaizen "naming consistency across the API layer"
/kaizen "dead code and unused imports"
/kaizen "error handling patterns"
When focused:
- Still scan all seven dimensions (critical issues may lie outside focus)
- Lead the report with focus-specific findings
- Mark non-focus findings as
[ALSO NOTED] โ keep brief
- Issues matching focus are severity-promoted one level
The Three Wastes (ไธๅคงใ ใ)
Every finding maps to one. Classification taxonomy.
Muda (็ก้ง) โ Waste
Code consuming effort without adding value.
| Type | Code manifestation |
|---|
| Defects | Bugs, broken tests, swallowed errors |
| Overproduction | Dead code, unused exports, premature abstractions |
| Waiting | Slow builds, blocking I/O without async |
| Transportation | Unnecessary data transformations, excessive layer mapping |
| Inventory | Stale TODOs (>6mo), commented-out code, stale branches |
| Motion | Excessive indirection, 5+ layer call chains for simple ops |
| Over-processing | Over-engineered abstractions, config for hypothetical flexibility |
Mura (ๆ) โ Unevenness
Inconsistency forcing context-switching and guessing.
| Signal | Example |
|---|
| Naming | getUserData() vs fetchUserInfo() vs loadUserProfile() for same pattern |
| Mixed paradigms | Callbacks + promises + async/await in same codebase |
| Structure | Different folder layouts across features |
| Error handling | Some throw, some return null, some use Result types |
| Test style | Mixed assertion libs, inconsistent AAA |
Muri (็ก็) โ Overburden
Code units carrying too much.
| Signal | Default threshold |
|---|
| God files | > 400 LOC |
| God functions | > 40 LOC or cyclomatic complexity > 10 |
| Too many params | > 5 parameters |
| God modules | > 15 exports/public methods |
| Coupling | Imported by > 60% of codebase |
| Deep nesting | > 3 levels |
Seven Dimensions โ Execute in Order
Shared Output Format
Findings in D2โD4:
[MUDA|MURA|MURI] [subtype]
๐ [file:line or pattern]
Finding: [one sentence]
Kaizen: [specific small change]
Effort: [trivial | small | medium]
D1 โ Gemba Walk (็พๅ ด): See the Actual State
Observe the real state, not the idealized version.
- Map directory structure (2 levels deep)
- Count files by type, measure LOC distribution
- Identify largest files, deepest nesting, most-imported modules
- Read existing context files (README, ARCHITECTURE.md, .ctx, CLAUDE.md)
- Note language, framework, build system
GEMBA SNAPSHOT
Languages: [detected]
Framework: [detected]
Total files: [N] | Total LOC: [N]
Largest file: [path] ([N] lines)
Deepest nest: [path] ([N] levels)
Most imported: [module] (by [N] files)
Test coverage: [detected or unknown]
Context files: [list found]
D2 โ Muda Scan: Waste
Scan each waste type. Prioritize:
- Dead code (unused functions, unreachable branches, orphan exports)
- Over-engineering (single-impl abstractions, one-setting config systems)
- Stale artifacts (undated TODOs, deprecated code, outdated comments)
- Redundancy (duplicated logic, copy-paste, overlapping utilities)
- Unnecessary complexity (fewer lines without losing clarity)
D3 โ Mura Scan: Unevenness
For each inconsistency, identify the dominant pattern (most common variant) โ standardize on it.
Additional fields:
Variants found: [list observed]
Dominant pattern: [most common โ standardize on this]
D4 โ Muri Scan: Overburden
Scan against Muri thresholds. Honor user-specified thresholds. Adjust upward where longer files are conventional (Java).
Additional fields:
Metric: [what] = [measured] (threshold: [N])
Impact: [why this hurts โ "hard to test", "merge conflict magnet"]
D5 โ 5S Audit (ๆด็ใปๆด้ ใปๆธ
ๆใปๆธ
ๆฝใป่บพ)
| 5S | Code equivalent | Check |
|---|
| Sort (ๆด็) | Remove unneeded | Dead files, unused deps, orphaned configs |
| Set in Order (ๆด้ ) | Everything in its place | Correct directories, logical boundaries, organized imports |
| Shine (ๆธ
ๆ) | Clean regularly | Lint errors, formatting, stale comments, debug artifacts |
| Standardize (ๆธ
ๆฝ) | Consistent practices | Documented patterns, enforced conventions |
| Sustain (่บพ) | Maintain discipline | CI checks, pre-commit hooks, quality gates |
Score each ๐ข Good | ๐ก Partial | ๐ด Needs work with one-line evidence.
D6 โ Improvement Backlog (ๆนๅใใใฏใญใฐ)
Primary deliverable. Synthesize D2โD5, prioritized:
- Impact (1โ3): waste/unevenness/overburden removed
- Effort (1=trivial, 2=small, 3=medium): time
- Risk (1=safe, 2=needs tests, 3=risky): can it break
- Score: Impact / (Effort ร Risk) โ higher better
ๆนๅ IMPROVEMENT BACKLOG
# Type Score Effort Description Location
1 MUDA 3.0 trivial Remove 12 unused imports src/utils/*.ts
2 MURI 1.5 small Extract validation from handler src/api/orders.ts:45-120
3 MURA 1.5 small Standardize error returns src/services/*
...
Cap at 15 items. If more, note "N additional โ run /kaizen with a focus to drill in."
D7 โ PDCA Compass
PLAN: [Top 3 improvements to tackle first and why]
DO: [Concrete next steps โ "In your next PR, ..."]
CHECK: [How to verify improvements landed]
ACT: [Systemic prevention โ linter rules, CI, conventions to document]
Report Assembly
- Header: Codebase, focus (or "Full scan"), date
- Gemba Snapshot (D1)
- 5S Scorecard (D5)
- Improvement Backlog (D6) โ hero section
- Detailed Findings: Muda (D2), Mura (D3), Muri (D4)
- PDCA Compass (D7)
Close with: "ๆนๅใฎ็ฒพ็ฅ: ไปๆฅใฎๆๅใฏใๆๆฅใฎๅบ็บ็นใ"
Calibration Rules
- Single-PR scope: every suggestion achievable in one PR. Multi-day refactors need decomposition or "requires planning" flag.
- Respect existing decisions: don't contradict ADRs/conventions. Note tensions instead.
- Evidence over opinion: every finding cites file/line/pattern. No vague "could be cleaner."
- Compound priority: prefer changes improving many files over isolated fixes.
- Don't manufacture findings: if priority is one thing, say so. Honest beats padded.
- Focus discipline: focus findings lead. Non-focus is brief bonus context.
- Threshold flexibility: state thresholds used. Honor user-specified. Adjust for language conventions.