| name | kaizen |
| description | One iteration of accidental-complexity reduction โ audit the codebase against craftsmanship principles via parallel agents, and file a groomed cleanup-issue for every candidate that clears the gate. Does NOT implement or ship โ specialized dev processes pick up the filed issues. Use when invoked as `/kaizen` (runs one iteration); use `/loop kaizen` to run it as an autonomous loop. The instance/tidy-altitude sibling of `/kaikaku`. Project-agnostic; reads simplicity heuristics from CLAUDE.md and project memory. |
/kaizen โ one audit-and-file simplification iteration
You run one iteration: scour the codebase for accidental complexity and file a groomed cleanup-issue for every candidate that clears the gate โ then declare the outcome. You do not implement the simplification or open a PR: kaizen is a find-and-file producer; the specialized dev processes (the shovel-ready queue / autodev / a human) implement the filed issues. /loop kaizen runs this on an autonomous loop.
This skill is a thin specialization over the shared file-cycle skeleton. Read dev-skills:file-cycle for the shared iteration machinery (labeling by validation, autonomous multi-output filing, dup-check, declaring the outcome). Looping โ cadence, idle escalation, re-arming โ is owned by /loop. This file owns:
- Phase 1 โ target acquisition (parallel-agent codebase audit).
- Phase 1.5 โ the kaizen-specific quality gate.
- Phase 4โฒ body โ the cleanup-issue template file-cycle files.
(Altitude note: kaizen is the instance / few-lines-to-tidy altitude. A finding that dissolves a whole class by changing a structure is a /kaikaku candidate; a latent correctness defect is a /bughunt candidate. All three file โ they differ only in altitude and gate.)
Specialization-specific invariants
(See file-cycle for the shared invariants โ multi-output, autonomous filing, quality-gate-beats-throughput, label-don't-block. These are additional.)
- Accidental complexity only โ defensive guards for model mistakes, fallbacks, retry loops that hide errors, multi-stage corrective pipelines, backwards-compat shims, near-duplicate code paths, state machines encoded across log scans. Don't propose rewriting legitimately complex domain logic that earns its lines.
- No new features, no behavior changes โ kaizen is structural. If the audit surfaces a real bug, it's a
/bughunt candidate, not a kaizen cleanup โ note it and move on.
- Propose, don't implement โ kaizen's deliverable is a decision-ready cleanup-issue, not a diff. Describe the target, the simpler form, and the expected shape of the change; the consumer makes it.
- Respect the project's stance โ read
CLAUDE.md and any feedback_* memories before picking. Project-specific anti-patterns weight your search heavily.
Phase 1 โ Parallel-agent audit
Dispatch multiple agents in parallel (single message, multiple Agent tool calls) covering different dimensions of craftsmanship. Each agent returns ranked findings; you synthesize.
Read the simplicity stance first
Before launching agents, read CLAUDE.md (project root) and any feedback_* / project_* memory files about complexity, style, simplicity priorities. Pass the relevant excerpts into each agent's prompt so their findings are calibrated to this project's bar.
Dispatch agents
Pick 4โ6 dimensions appropriate to the codebase. The standard set:
- Project invariants โ read
CLAUDE.md's invariants/anti-patterns sections. Find code that maintains the same invariant differently across sites, or violates it subtly.
- Structural duplication โ search for near-twin function names (
process_X + process_X_v2, defer_X + defer_retry_X), multi-site inlined state machines, copy-paste with slight variation.
- File-size + smell-words โ top-N largest files; grep for
fallback, legacy, compat_, TODO, XXX, HACK, FIXME, workaround, recover, repair, reconcile. Each match is a candidate, not a verdict.
- Broad excepts and error swallowing โ
except Exception: blocks that don't re-raise; symptom-suppression guards; "fail soft" handlers in places where "fail hard" is the project's stance.
- Multi-stage corrective pipelines โ modules whose docstrings advertise "replaces X + Y + Z with a single function". Sometimes load-bearing for crash recovery; sometimes a state machine fighting the architecture.
- Craftsmanship principles โ assess against: Clean (dead code, unclear purpose), Simple (over-engineering, clever solutions), Comprehensible (poor naming, high cognitive load), Well-Factored (mixed responsibilities, large functions), Single Responsibility (multi-purpose units), Testable (hard-to-test code, side effects), DRY (missed abstractions).
Each agent's prompt should include
- The relevant
CLAUDE.md excerpts and feedback_* memory excerpts so calibration matches the project.
- A rubric: rank findings by
(impact ร confidence) รท blast-radius, return top 3โ5.
- The instruction: "Don't fix anything; just identify and rank."
- A length cap (under 400 words per response) so synthesis stays manageable.
- A clear deliverable: ranked list with file:line references and a one-line rationale per finding.
Use subagent_type: general-purpose for the audit agents. They run parallel via a single message with multiple Agent tool calls. If invoked with --model=<value> (see file-cycle flags), include model: "<value>" on each Agent call so every audit subagent runs on the chosen Claude generation; otherwise omit model: and let them inherit the session's model.
Synthesize
Collect the ranked lists. Merge into a single global ranking โ same target appearing across multiple agents amplifies its score. Rank by: cross-agent corroboration first (multiple dimensions flagging it = signal), then per-dimension severity, then blast radius (smaller wins ties).
Read each candidate's file in detail
Before filing, read the actual file (not just the agent's excerpt) for every candidate you intend to file. Confirm:
- Does this complexity earn its lines, or is it accidental?
- Is there a near-twin elsewhere that could be unified?
- Does the same logic appear inline in N call sites without a helper?
- Does CLAUDE.md explicitly forbid the pattern?
This read is what separates a filed cleanup-issue from a finder's guess โ the consumer implements from your issue, so the analysis must be real.
If the audit produces no candidate at the depth applied, declare LOOP-OUTCOME: empty (file-cycle Phase 7) and end the iteration.
Phase 1.5 โ Kaizen quality gate
Apply file-cycle's quality-gate principle, per candidate โ kaizen is multi-output: every candidate that clears the gate is filed. A candidate clears only if all are true:
- Unambiguously accidental. The complexity does NOT earn its lines on second read. "Maybe load-bearing for crash recovery" or "might be intentional, hard to tell" fails the gate.
- Net deletion expected. A cleanup whose proposed change adds more lines than it removes is a yellow flag โ it's probably an abstraction posing as a simplification. Borderline net-positive cases need explicit justification or they fail the gate.
- Not contentious. If two equally-reasonable people would disagree on whether the code is better after the change, fail the gate. Kaizen files uncontroversial wins. (A contentious refactor is dropped, not filed with a hedge โ that's the
gate_killed path, or a /kaikaku candidate if it's really a structural call.)
- Bounded blast radius. A simplification that touches > ~5 files OR crosses module boundaries fails the kaizen gate โ that altitude is a
/kaikaku candidate. Route it there and move on.
If a candidate is a clean simplification but has one genuine open sub-decision (a naming choice, a which-of-two-forms question), don't drop it and don't ask โ file it needs-design with the fork stated (file-cycle Escalation). A contentious-whether-to-do-it-at-all candidate is different: that fails the gate.
If no candidate clears the gate: report what was found and why each was rejected, then declare LOOP-OUTCOME: gate_killed (the audit wasn't empty, but the iteration is non-productive โ /loop treats it as an idle increment). Don't file a borderline cleanup just because the audit produced output.
Phase 4โฒ โ The cleanup-issue (file-cycle files it)
For each candidate that clears Phase 1.5, author a cleanup-issue with the body below; file-cycle (Phase 4โฒ) owns the labeling, dup-check, autonomous filing, and outcome declaration.
- Current shape โ what the code does now, with the concrete loci (
file:line), and the near-twin(s) / inline-repeats if any.
- The accidental complexity โ precisely what's incidental (not domain-earned): the duplication, the dead path, the fallback, the mis-placed responsibility.
- Proposed simplification โ the simpler form that does the same job (call the existing helper, delete the shim, collapse the twins, inline-then-remove). Concrete enough to implement from.
- Expected LOC delta โ the net-deletion estimate (kaizen expects a negative). Flag and justify any net-positive.
- Blast radius โ files touched, and the regression bar (existing tests must still pass; note any fossil tests to delete alongside).
Label
- A clean, uncontroversial cleanup with a concrete plan โ the project's build-queue label (
shovel-ready).
- A clean cleanup with one open sub-decision โ
needs-design, fork stated.
(See file-cycle Phase 4โฒ for the labeling rule and the file / dup-check / record / report steps.)
Specialization-specific boundaries
(Additive to file-cycle's shared boundaries.)
- Don't file a target the user has already rejected (a previously-closed issue within memory) โ record filed/rejected targets so the next audit excludes them.
- Don't file a contentious refactor. Kaizen files present-tense, uncontroversial simplicity; a genuinely-arguable change fails the gate.
- Don't implement or open a PR. kaizen files; the consumer simplifies.
- Don't speculate on "future flexibility" in issue bodies.
Specialization-specific escalation
file-cycle's "label, don't block" governs โ kaizen runs unattended and does not stop to ask. The cases that once were questions become labels:
- A candidate straddling real-vs-accidental complexity that you couldn't resolve on a close read โ don't file it; it fails the "unambiguously accidental" gate (
gate_killed). Kaizen does not file coin-flips.
- A clean cleanup with a genuine open sub-decision (naming, which form) โ file
needs-design, fork stated.
When in doubt about whether the complexity is earned, drop it โ a wrong-target cleanup-issue teaches the consumer to distrust the queue.