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.
1---2name: kaizen3description: 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.4---56# Kaizen (改善) — Codebase Continuous Improvement78Smallest changes compounding into significant quality. Every file you touch leaves better than found.910---1112## Input Modes1314### `/kaizen`15Run all seven dimensions across the codebase. Full improvement map.1617### `/kaizen "focus description"`18All dimensions, **weighted and prioritized** through user's lens.1920Examples:21- `/kaizen "file sizes — nothing should exceed 500 LOC"`22- `/kaizen "naming consistency across the API layer"`23- `/kaizen "dead code and unused imports"`24- `/kaizen "error handling patterns"`2526When focused:271. Still scan all seven dimensions (critical issues may lie outside focus)282. Lead the report with focus-specific findings293. Mark non-focus findings as `[ALSO NOTED]` — keep brief304. Issues matching focus are severity-promoted one level3132---3334## The Three Wastes (三大ムダ)3536Every finding maps to one. Classification taxonomy.3738### Muda (無駄) — Waste39Code consuming effort without adding value.4041| Type | Code manifestation |42|---|---|43| Defects | Bugs, broken tests, swallowed errors |44| Overproduction | Dead code, unused exports, premature abstractions |45| Waiting | Slow builds, blocking I/O without async |46| Transportation | Unnecessary data transformations, excessive layer mapping |47| Inventory | Stale TODOs (>6mo), commented-out code, stale branches |48| Motion | Excessive indirection, 5+ layer call chains for simple ops |49| Over-processing | Over-engineered abstractions, config for hypothetical flexibility |5051### Mura (斑) — Unevenness52Inconsistency forcing context-switching and guessing.5354| Signal | Example |55|---|---|56| Naming | `getUserData()` vs `fetchUserInfo()` vs `loadUserProfile()` for same pattern |57| Mixed paradigms | Callbacks + promises + async/await in same codebase |58| Structure | Different folder layouts across features |59| Error handling | Some throw, some return null, some use Result types |60| Test style | Mixed assertion libs, inconsistent AAA |6162### Muri (無理) — Overburden63Code units carrying too much.6465| Signal | Default threshold |66|---|---|67| God files | > 400 LOC |68| God functions | > 40 LOC or cyclomatic complexity > 10 |69| Too many params | > 5 parameters |70| God modules | > 15 exports/public methods |71| Coupling | Imported by > 60% of codebase |72| Deep nesting | > 3 levels |7374---7576## Seven Dimensions — Execute in Order7778### Shared Output Format7980Findings in D2–D4:8182```83[MUDA|MURA|MURI] [subtype]84📍 [file:line or pattern]85Finding: [one sentence]86Kaizen: [specific small change]87Effort: [trivial | small | medium]88```8990---9192### D1 — Gemba Walk (現場): See the Actual State9394*Observe the real state, not the idealized version.*95961. Map directory structure (2 levels deep)972. Count files by type, measure LOC distribution983. Identify largest files, deepest nesting, most-imported modules994. Read existing context files (README, ARCHITECTURE.md, .ctx, CLAUDE.md)1005. Note language, framework, build system101102```103GEMBA SNAPSHOT104Languages: [detected]105Framework: [detected]106Total files: [N] | Total LOC: [N]107Largest file: [path] ([N] lines)108Deepest nest: [path] ([N] levels)109Most imported: [module] (by [N] files)110Test coverage: [detected or unknown]111Context files: [list found]112```113114---115116### D2 — Muda Scan: Waste117118Scan each waste type. Prioritize:1191. Dead code (unused functions, unreachable branches, orphan exports)1202. Over-engineering (single-impl abstractions, one-setting config systems)1213. Stale artifacts (undated TODOs, deprecated code, outdated comments)1224. Redundancy (duplicated logic, copy-paste, overlapping utilities)1235. Unnecessary complexity (fewer lines without losing clarity)124125---126127### D3 — Mura Scan: Unevenness128129For each inconsistency, identify the **dominant pattern** (most common variant) — standardize on it.130131Additional fields:132```133Variants found: [list observed]134Dominant pattern: [most common — standardize on this]135```136137---138139### D4 — Muri Scan: Overburden140141Scan against Muri thresholds. Honor user-specified thresholds. Adjust upward where longer files are conventional (Java).142143Additional fields:144```145Metric: [what] = [measured] (threshold: [N])146Impact: [why this hurts — "hard to test", "merge conflict magnet"]147```148149---150151### D5 — 5S Audit (整理・整頓・清掃・清潔・躾)152153| 5S | Code equivalent | Check |154|---|---|---|155| Sort (整理) | Remove unneeded | Dead files, unused deps, orphaned configs |156| Set in Order (整頓) | Everything in its place | Correct directories, logical boundaries, organized imports |157| Shine (清掃) | Clean regularly | Lint errors, formatting, stale comments, debug artifacts |158| Standardize (清潔) | Consistent practices | Documented patterns, enforced conventions |159| Sustain (躾) | Maintain discipline | CI checks, pre-commit hooks, quality gates |160161Score each `🟢 Good | 🟡 Partial | 🔴 Needs work` with one-line evidence.162163---164165### D6 — Improvement Backlog (改善バックログ)166167**Primary deliverable.** Synthesize D2–D5, prioritized:168- **Impact** (1–3): waste/unevenness/overburden removed169- **Effort** (1=trivial, 2=small, 3=medium): time170- **Risk** (1=safe, 2=needs tests, 3=risky): can it break171- **Score**: Impact / (Effort × Risk) — higher better172173```174改善 IMPROVEMENT BACKLOG175# Type Score Effort Description Location1761 MUDA 3.0 trivial Remove 12 unused imports src/utils/*.ts1772 MURI 1.5 small Extract validation from handler src/api/orders.ts:45-1201783 MURA 1.5 small Standardize error returns src/services/*179...180```181182**Cap at 15 items.** If more, note "N additional — run `/kaizen` with a focus to drill in."183184---185186### D7 — PDCA Compass187188```189PLAN: [Top 3 improvements to tackle first and why]190DO: [Concrete next steps — "In your next PR, ..."]191CHECK: [How to verify improvements landed]192ACT: [Systemic prevention — linter rules, CI, conventions to document]193```194195---196197## Report Assembly1981991. **Header**: Codebase, focus (or "Full scan"), date2002. **Gemba Snapshot** (D1)2013. **5S Scorecard** (D5)2024. **Improvement Backlog** (D6) — hero section2035. **Detailed Findings**: Muda (D2), Mura (D3), Muri (D4)2046. **PDCA Compass** (D7)205206Close with: *"改善の精神: 今日の最善は、明日の出発点。"*207208---209210## Calibration Rules2112121. **Single-PR scope**: every suggestion achievable in one PR. Multi-day refactors need decomposition or "requires planning" flag.2132. **Respect existing decisions**: don't contradict ADRs/conventions. Note tensions instead.2143. **Evidence over opinion**: every finding cites file/line/pattern. No vague "could be cleaner."2154. **Compound priority**: prefer changes improving many files over isolated fixes.2165. **Don't manufacture findings**: if priority is one thing, say so. Honest beats padded.2176. **Focus discipline**: focus findings lead. Non-focus is brief bonus context.2187. **Threshold flexibility**: state thresholds used. Honor user-specified. Adjust for language conventions.