kaizen-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -0
- package/agents/kaizen-builder.md +75 -0
- package/agents/kaizen-planner.md +243 -0
- package/agents/kaizen-reviewer.md +127 -0
- package/cli/install.ts +86 -0
- package/commands/kaizen-abort.md +5 -0
- package/commands/kaizen-approve.md +5 -0
- package/commands/kaizen-auto.md +6 -0
- package/commands/kaizen-backlog.md +5 -0
- package/commands/kaizen-init.md +5 -0
- package/commands/kaizen-install.md +5 -0
- package/commands/kaizen-plan.md +6 -0
- package/commands/kaizen-reject.md +6 -0
- package/commands/kaizen-review.md +6 -0
- package/commands/kaizen-run.md +5 -0
- package/commands/kaizen-status.md +5 -0
- package/package.json +35 -0
- package/skills/kaizen/README.md +279 -0
- package/skills/kaizen/SKILL.md +281 -0
- package/skills/kaizen/adapters.md +76 -0
- package/skills/kaizen/config.default.yml +82 -0
- package/skills/kaizen/spec-build.md +80 -0
- package/skills/kaizen/spec-main.md +102 -0
- package/skills/kaizen/spec-plan.md +141 -0
- package/skills/kaizen/spec-review.md +89 -0
- package/skills/kaizen/spec.md +130 -0
- package/skills/kaizen-help/SKILL.md +119 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Adapters — running kaizen outside Claude Code
|
|
2
|
+
|
|
3
|
+
`spec.md` plus its per-stage files (`spec-plan.md`, `spec-build.md`, `spec-review.md`,
|
|
4
|
+
`spec-main.md`) are the workflow. It does not mention any vendor, and it is the single
|
|
5
|
+
source of truth. An adapter is a thin file that points a given tool at it and
|
|
6
|
+
describes how that tool dispatches stages. Adapters never restate the stage rules;
|
|
7
|
+
duplicating them is how the tools drift apart.
|
|
8
|
+
|
|
9
|
+
The portability comes from `.kaizen/` being plain files in the repository. Any tool
|
|
10
|
+
that can read a directory can resume a run another tool started.
|
|
11
|
+
|
|
12
|
+
## Claude Code
|
|
13
|
+
|
|
14
|
+
Native. The skill in this directory dispatches each stage through the Agent tool
|
|
15
|
+
using the `kaizen-planner`, `kaizen-builder`, and `kaizen-reviewer` agent
|
|
16
|
+
definitions, and the main thread owns `state.json`.
|
|
17
|
+
|
|
18
|
+
## Codex — `AGENTS.md`
|
|
19
|
+
|
|
20
|
+
Codex reads `AGENTS.md` from the repository root. Append:
|
|
21
|
+
|
|
22
|
+
```markdown
|
|
23
|
+
## Kaizen workflow
|
|
24
|
+
|
|
25
|
+
Non-trivial work in this repo follows the staged workflow in
|
|
26
|
+
`.kaizen/spec.md`: plan, human approval, implement, independent review, bounded
|
|
27
|
+
fix loop. Read that file before starting, and read `.kaizen/config.yml` for the
|
|
28
|
+
mode and approval settings.
|
|
29
|
+
|
|
30
|
+
Run state lives in `.kaizen/runs/<id>/`. Always read `state.json` first and
|
|
31
|
+
continue from the stage it names. Never advance a run whose `awaiting` field is
|
|
32
|
+
non-null without a recorded human decision in `02-approval.md` — another tool or
|
|
33
|
+
session may be mid-run.
|
|
34
|
+
|
|
35
|
+
Codex has no separate subagents, so run the stages sequentially in one session,
|
|
36
|
+
but keep them clean: start each stage by reading only that stage's declared inputs
|
|
37
|
+
from its stage file, and write its artifact before moving on. When reviewing, judge the
|
|
38
|
+
diff on its own terms rather than defending the reasoning you used while writing it.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Copy `spec*.md` and `config.yml` into `.kaizen/` so the reference resolves
|
|
42
|
+
without this skill installed.
|
|
43
|
+
|
|
44
|
+
## Antigravity
|
|
45
|
+
|
|
46
|
+
Antigravity reads `AGENTS.md` as well; use the same block. If a workspace-level rules
|
|
47
|
+
file is configured instead, point it at `.kaizen/spec.md` and the stage file being run with the same three
|
|
48
|
+
paragraphs.
|
|
49
|
+
|
|
50
|
+
Where Antigravity can run parallel agents, map planner, builder, and reviewer onto
|
|
51
|
+
separate agents exactly as Claude Code does — the independent reviewer context is the
|
|
52
|
+
part worth preserving in any port.
|
|
53
|
+
|
|
54
|
+
## Handing a run between tools
|
|
55
|
+
|
|
56
|
+
Nothing special is required. Because every stage's input and output are files:
|
|
57
|
+
|
|
58
|
+
1. Tool A finishes a stage and updates `state.json`.
|
|
59
|
+
2. Tool B opens the repo, reads `state.json`, sees `stage: "review"` and
|
|
60
|
+
`awaiting: null`, and runs the reviewer.
|
|
61
|
+
|
|
62
|
+
The only rule is that whichever tool holds the run updates `state.json` when a stage
|
|
63
|
+
completes. A stale `state.json` is the one way this breaks.
|
|
64
|
+
|
|
65
|
+
## Installing the adapter files
|
|
66
|
+
|
|
67
|
+
`/kaizen init` writes `.kaizen/` with the `spec*.md` files, `config.yml`, and the gitignore
|
|
68
|
+
entry. `/kaizen install` additionally offers to append the `AGENTS.md` block above.
|
|
69
|
+
`.kaizen/spec*.md` and `.kaizen/config.yml` should be committed even though run state
|
|
70
|
+
is ignored — the workflow is shared, the run data is not:
|
|
71
|
+
|
|
72
|
+
```gitignore
|
|
73
|
+
.kaizen/*
|
|
74
|
+
!.kaizen/spec*.md
|
|
75
|
+
!.kaizen/config.yml
|
|
76
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Kaizen defaults. Copy to .kaizen/config.yml in a repository and override only the
|
|
2
|
+
# keys you care about; anything absent falls back to this file.
|
|
3
|
+
|
|
4
|
+
# plan-only | approve | auto | review-only
|
|
5
|
+
mode: approve
|
|
6
|
+
|
|
7
|
+
approvals:
|
|
8
|
+
# Stop after the plan, before any code is written.
|
|
9
|
+
plan: true
|
|
10
|
+
# Stop after the review, before the work is called done. Off by default: when
|
|
11
|
+
# auto_fix has already closed the findings at or above its threshold, this second
|
|
12
|
+
# stop mostly asks the user to approve a report they are about to read anyway.
|
|
13
|
+
review: false
|
|
14
|
+
# Confirm every individual file edit. Maximum control, slowest.
|
|
15
|
+
each_file: false
|
|
16
|
+
|
|
17
|
+
auto_fix:
|
|
18
|
+
# false: every finding stops the run and becomes a user decision.
|
|
19
|
+
# true: findings at or above min_severity are fixed and re-reviewed automatically.
|
|
20
|
+
enabled: true
|
|
21
|
+
# critical | high | medium | low
|
|
22
|
+
min_severity: high
|
|
23
|
+
# Fix/recheck rounds before remaining findings are escalated to the user. Each round
|
|
24
|
+
# is a full builder pass plus a full reviewer pass, so this is the most expensive
|
|
25
|
+
# knob in the file. A third round rarely closes what two could not.
|
|
26
|
+
max_iterations: 2
|
|
27
|
+
|
|
28
|
+
track:
|
|
29
|
+
# The kind of work a run is doing, which decides what "deliverable",
|
|
30
|
+
# "verification", and "finding" mean for every stage. It is INFERRED from the
|
|
31
|
+
# request by the planner and stated back in the plan's Framing for the user to
|
|
32
|
+
# correct at the approval — the user is never asked to categorize their own request.
|
|
33
|
+
# Set this only to pin a default for a repo that is always one kind of work
|
|
34
|
+
# (e.g. a docs repo). Leave empty to infer per run.
|
|
35
|
+
default: ""
|
|
36
|
+
|
|
37
|
+
review:
|
|
38
|
+
# Checks that run in every track.
|
|
39
|
+
checks:
|
|
40
|
+
- correctness
|
|
41
|
+
- plan_conformance
|
|
42
|
+
# Additional checks per track, chosen by what the run actually is. The planner may
|
|
43
|
+
# name a track not listed here; the reviewer then derives its checks from the
|
|
44
|
+
# track's "what would make it wrong".
|
|
45
|
+
track_checks:
|
|
46
|
+
software: [security, reuse_simplification, test_coverage]
|
|
47
|
+
# blast_radius and regression are universal — see spec-review.md — not listed here.
|
|
48
|
+
writing: [completeness, claim_accuracy, reader_usability]
|
|
49
|
+
communication: [claim_accuracy, audience_fit, voice_consistency]
|
|
50
|
+
operations: [prerequisites, rollback, executability]
|
|
51
|
+
research: [evidence_support, selection_bias, alternatives]
|
|
52
|
+
# Let the reviewer append durable lessons to .kaizen/memory.md.
|
|
53
|
+
write_memory: true
|
|
54
|
+
# Every stage of every future run reads memory.md, so cap it. Over this, the reviewer
|
|
55
|
+
# prunes stale or superseded lessons before appending rather than growing the file.
|
|
56
|
+
memory_max_lines: 100
|
|
57
|
+
|
|
58
|
+
backlog:
|
|
59
|
+
# Capture what a run deliberately did not do: out-of-scope suggestions the user did
|
|
60
|
+
# not take, findings below the fix threshold, and debts deferred at an approval.
|
|
61
|
+
# Written by the main thread at the plan approval and again at the final approval.
|
|
62
|
+
enabled: true
|
|
63
|
+
# Per run, beside its plan and review — provenance without a central file to sync.
|
|
64
|
+
file: 06-backlog.md
|
|
65
|
+
# Items are open | done | rejected. Only open ones are printed by /kaizen backlog;
|
|
66
|
+
# closed ones stay in their run's file as record.
|
|
67
|
+
statuses: [open, done, rejected]
|
|
68
|
+
# Before state.keep_runs prunes a run, its still-open items move here, relative to
|
|
69
|
+
# state.dir. Done and rejected items are pruned with the run.
|
|
70
|
+
orphan_file: backlog.md
|
|
71
|
+
|
|
72
|
+
state:
|
|
73
|
+
dir: .kaizen
|
|
74
|
+
# Keep this many completed runs before pruning the oldest. Pruning first rescues
|
|
75
|
+
# open backlog items into backlog.orphan_file, so it never destroys open work.
|
|
76
|
+
keep_runs: 20
|
|
77
|
+
|
|
78
|
+
git:
|
|
79
|
+
# Never commit, push, or open a PR unless the user explicitly asks.
|
|
80
|
+
auto_commit: false
|
|
81
|
+
# Create a branch before the implement stage when on the default branch.
|
|
82
|
+
branch_before_implement: true
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Kaizen — implement stage
|
|
2
|
+
|
|
3
|
+
Read with [`spec.md`](spec.md) (core: track, intake, resume). This file is the
|
|
4
|
+
builder's contract. The planner and reviewer do not read it.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
## Stage 2 — Implement
|
|
8
|
+
|
|
9
|
+
**Agent:** builder. **Input:** `01-plan.md`, `02-approval.md`, the track.
|
|
10
|
+
**Output:** the deliverable itself, plus `03-impl.md`.
|
|
11
|
+
|
|
12
|
+
The builder produces whatever the track's deliverable is — code, a chapter, the
|
|
13
|
+
campaign copy, the runbook — and nothing else. Rules:
|
|
14
|
+
|
|
15
|
+
- Work only within the plan's scope. Something out of scope that clearly needs doing
|
|
16
|
+
is written to `03-impl.md` as a note, not produced.
|
|
17
|
+
- If a step turns out to be impossible or wrong, stop and report. Do not improvise a
|
|
18
|
+
different approach — that silently discards the approval the plan received.
|
|
19
|
+
- Match what is already there: a codebase's conventions and idioms, a manuscript's
|
|
20
|
+
voice and structure, a brand's tone. New work should be indistinguishable in style
|
|
21
|
+
from the surrounding material.
|
|
22
|
+
- Carry out the plan's verification and record the real result, whatever the track's
|
|
23
|
+
verification is.
|
|
24
|
+
- Every technique the plan's `reason`-tier gate covers — a new dependency, a new
|
|
25
|
+
abstraction, a new file, a new section — is allowed, and costs one written line
|
|
26
|
+
saying what it serves. The line is the price of the technique, not a request for
|
|
27
|
+
permission. No line means the reviewer records a finding.
|
|
28
|
+
|
|
29
|
+
**Baseline first, in any track with an existing suite of checks.** Before changing
|
|
30
|
+
anything, run whatever already proves the existing material correct — the test suite,
|
|
31
|
+
the linter, the link checker, the fact-check pass — and record the result in
|
|
32
|
+
`03-impl.md`. Run it again after. Two results, before and after, are what turn "my
|
|
33
|
+
change works" into "nothing else broke". A check already failing before the change is
|
|
34
|
+
not this run's finding; a check that passed before and fails after is, and it stops
|
|
35
|
+
the stage.
|
|
36
|
+
|
|
37
|
+
**Read the plan's File manifest instead of searching.** The planner already located
|
|
38
|
+
every path this run touches. Search the material only for what the manifest does not
|
|
39
|
+
cover, and note in `03-impl.md` what was missing from it.
|
|
40
|
+
|
|
41
|
+
`03-impl.md` must list: what was produced or changed with a one-line reason each,
|
|
42
|
+
deviations from the plan and why, verification carried out with its actual result,
|
|
43
|
+
and anything deliberately left undone. Report failures honestly; a false claim of
|
|
44
|
+
success poisons the review stage, which trusts this report.
|
|
45
|
+
|
|
46
|
+
**The gate block closes the stage.** `03-impl.md` ends with one line per gate item
|
|
47
|
+
from the plan's Verification section:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
G-01 PASS: ran `php artisan test --filter=Payroll` — 214 passed, 0 failed
|
|
51
|
+
G-02 PASS: cash→transfer switch exercised in the UI; bank rows validated, 422 gone
|
|
52
|
+
G-03 FAIL: payslip PDF still prints the old label
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A `PASS` states what was actually done and what came back — the command and its
|
|
56
|
+
output, the page opened and what appeared, the person who read it and what they
|
|
57
|
+
understood. `PASS` on its own is not a result, and neither is a restatement of the
|
|
58
|
+
gate item; both are read as an admission the check did not happen.
|
|
59
|
+
|
|
60
|
+
**Work that was never executed cannot pass.** In any track where the deliverable can
|
|
61
|
+
be run, opened, or read by someone, doing so is part of building it: the suite run,
|
|
62
|
+
the page opened and clicked, the runbook walked start to finish, the copy read aloud.
|
|
63
|
+
A gate item whose evidence is an argument that the code should work is a `FAIL`.
|
|
64
|
+
|
|
65
|
+
The stage does not hand off with a `FAIL` standing. Fix it and re-run the gate, or —
|
|
66
|
+
if it cannot be fixed inside the plan's scope — stop and report, exactly as with an
|
|
67
|
+
impossible step. A `FAIL` carried into review wastes the reviewer's pass on something
|
|
68
|
+
already known to be broken.
|
|
69
|
+
|
|
70
|
+
## Stage 4 — Fix loop
|
|
71
|
+
|
|
72
|
+
Governed by `auto_fix`. See the skill's fix-loop section for the exact behavior.
|
|
73
|
+
|
|
74
|
+
Each iteration writes `05-iterations/NN-fix.md` (what the builder changed) and
|
|
75
|
+
`NN-recheck.md` (what the reviewer found afterward). The loop ends when the reviewer
|
|
76
|
+
reports nothing at or above the threshold, or `max_iterations` is reached.
|
|
77
|
+
|
|
78
|
+
A finding the loop could not close is escalated to the user with the reviewer's
|
|
79
|
+
description intact — never quietly downgraded to make the run look clean.
|
|
80
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Kaizen — main thread
|
|
2
|
+
|
|
3
|
+
Read with [`spec.md`](spec.md) (core: track, intake, resume). Backlog bookkeeping and
|
|
4
|
+
the final approval. No subagent reads this file.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
## Backlog
|
|
8
|
+
|
|
9
|
+
Every run produces work it deliberately does not do. Three sources, all already
|
|
10
|
+
written down by the time a run ends:
|
|
11
|
+
|
|
12
|
+
1. Out of scope suggestions the planner listed and the user did not fold into the
|
|
13
|
+
approved scope.
|
|
14
|
+
2. Findings below `auto_fix.min_severity`, and findings the fix loop could not close.
|
|
15
|
+
3. Debts deferred at an approval because they fell outside the approved scope.
|
|
16
|
+
|
|
17
|
+
Without capture these survive only in the conversation that produced them.
|
|
18
|
+
|
|
19
|
+
`backlog.enabled: false` skips both capture points — the `02-approval.md` append at
|
|
20
|
+
plan approval and the `06-backlog.md` append at final approval — for that run. The run
|
|
21
|
+
still executes normally; it simply ends without a backlog file.
|
|
22
|
+
|
|
23
|
+
**Where it lives.** Each run holds its own backlog at `runs/<id>/06-backlog.md`, beside
|
|
24
|
+
the plan and the review that produced the items. There is no central backlog file to
|
|
25
|
+
keep in sync, and no copying: provenance is the directory the item sits in.
|
|
26
|
+
|
|
27
|
+
`<state.dir>/backlog.md`, beside `memory.md`, exists for exactly one purpose — an
|
|
28
|
+
orphanage. Before `state.keep_runs` prunes a run directory, that run's **open** items
|
|
29
|
+
are moved into it, so pruning never destroys outstanding work. Items already `done` or
|
|
30
|
+
`rejected` are pruned with their run. Nothing else is ever written there, and
|
|
31
|
+
`06-backlog.md` is never replaced by it.
|
|
32
|
+
|
|
33
|
+
`/kaizen backlog` reads `<state.dir>/backlog.md` as well as every
|
|
34
|
+
`runs/*/06-backlog.md`, and prints its open items last, under an **Orphaned** group —
|
|
35
|
+
otherwise a rescued item would be invisible to the only command that lists outstanding
|
|
36
|
+
work. Orphaned items count towards the open backlog count `/kaizen status` reports.
|
|
37
|
+
|
|
38
|
+
An abandoned run — `stage: "abandoned"`, set by `/kaizen abort` — is not open work. Its
|
|
39
|
+
`06-backlog.md` is left as it stands, and its items are neither printed by `/kaizen
|
|
40
|
+
backlog` nor counted.
|
|
41
|
+
|
|
42
|
+
**Item format.** One item per line:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
- <status>: <item text> | <reason>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`<status>` is `open`, `done`, or `rejected`. A finding moved into the backlog keeps the
|
|
49
|
+
reviewer's line verbatim — `<where>: <severity>: <problem>. <fix>.` — so nothing is
|
|
50
|
+
rewritten in transit. `rejected` requires a reason after `|` on the same line; "not
|
|
51
|
+
doing this" with no reason is how the same suggestion returns three runs later. `done`
|
|
52
|
+
may carry a reason the same way, and usually names the run that closed it.
|
|
53
|
+
|
|
54
|
+
Items are appended, never deleted. Closing an item means editing its status in place;
|
|
55
|
+
it stays in its run's file as record. `/kaizen backlog` prints `open` items only, so
|
|
56
|
+
the active list is bounded by what is genuinely outstanding rather than by history.
|
|
57
|
+
|
|
58
|
+
Because a `<where>` reference must still resolve after its run closes, it is written as
|
|
59
|
+
a path relative to the repository, not to the run directory.
|
|
60
|
+
|
|
61
|
+
**Who writes it.** The main thread, at two file writes that already happen
|
|
62
|
+
unconditionally:
|
|
63
|
+
|
|
64
|
+
| Capture point | Stage | What gets appended |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| Writing `02-approval.md`, when the decision is an approval | Plan approval | Every out-of-scope suggestion not folded into the approved scope, and anything cut from scope at the approval |
|
|
67
|
+
| Setting `stage: "done"` | Final approval | Findings still open, findings below the fix threshold, and out-of-scope notes the builder wrote into `03-impl.md` |
|
|
68
|
+
|
|
69
|
+
Neither is optional and neither is a separate step to remember — a run cannot finish
|
|
70
|
+
without touching both files.
|
|
71
|
+
|
|
72
|
+
No subagent writes the backlog. The reviewer runs *before* the fix loop and cannot know
|
|
73
|
+
which of its findings will be closed; it would log items that get fixed minutes later.
|
|
74
|
+
The planner is not present at the approval where its suggestions are accepted or
|
|
75
|
+
declined. This also keeps the workflow working under adapters where there are no
|
|
76
|
+
subagents at all.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Final approval
|
|
81
|
+
|
|
82
|
+
Controlled by `approvals.review`, skipped in `auto`.
|
|
83
|
+
|
|
84
|
+
Report: what was built, verification results, findings fixed, findings still open,
|
|
85
|
+
and anything the builder noted as out of scope. Then stop. Committing, pushing, or
|
|
86
|
+
opening a pull request happens only if the user asks.
|
|
87
|
+
|
|
88
|
+
**Open findings are offered by number.** List them with the reviewer's numbering
|
|
89
|
+
intact and let the user name which to fix — "fix 2 and 5". A number not named is not
|
|
90
|
+
touched, and goes to the backlog as `open` like any other deferred item. This is the
|
|
91
|
+
same granularity the fix loop already works at; the only change is that the user
|
|
92
|
+
picks the subset instead of accepting or declining the whole review.
|
|
93
|
+
|
|
94
|
+
Before setting `stage: "done"`, append the same three categories just reported —
|
|
95
|
+
findings still open, findings below the fix threshold, and the builder's out-of-scope
|
|
96
|
+
notes from `03-impl.md` — to `runs/<id>/06-backlog.md`, each as `open`, in the format
|
|
97
|
+
given in *Backlog* above. Every input is already assembled at this moment; the only
|
|
98
|
+
change is that it is written down rather than spoken and discarded.
|
|
99
|
+
|
|
100
|
+
Set `stage: "done"` in `state.json` once the user accepts.
|
|
101
|
+
|
|
102
|
+
---
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Kaizen — plan stage
|
|
2
|
+
|
|
3
|
+
Read with [`spec.md`](spec.md) (core: track, intake, resume). This file is the
|
|
4
|
+
planner's and the plan approval's contract. The builder and reviewer do not read it.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
## Stage 1 — Plan
|
|
8
|
+
|
|
9
|
+
**Agent:** planner. **Input:** `00-request.md` (including the track), `memory.md`, and
|
|
10
|
+
the existing material — the codebase, the manuscript, the current campaign, whatever
|
|
11
|
+
this run builds on. **Output:** `01-plan.md`.
|
|
12
|
+
|
|
13
|
+
The request is usually one sentence. The planner's first job is to expand it — but by
|
|
14
|
+
proposing, not by interrogating. It restates the problem, brings the nearest good
|
|
15
|
+
solution, and names the assumptions it took, so the user reacts to something concrete
|
|
16
|
+
instead of answering a questionnaire. Correcting a proposal costs a sentence;
|
|
17
|
+
answering five questions costs the user the work they came with.
|
|
18
|
+
|
|
19
|
+
The planner has an opinion: it says which approach it would take and why, and says
|
|
20
|
+
plainly when the request as stated will not achieve what the user evidently wants. It
|
|
21
|
+
asks outright only when a proposal is genuinely impossible — two readings, materially
|
|
22
|
+
different work behind each, nothing available to break the tie — and even then brings
|
|
23
|
+
its recommendation with the question. Questions the existing material can answer are
|
|
24
|
+
never asked; that is the planner's own work.
|
|
25
|
+
|
|
26
|
+
The goals stay the user's. The planner may propose a better solution to what was
|
|
27
|
+
asked, or argue that the request as stated will not achieve what the user wants, but
|
|
28
|
+
it may not widen the goal on its own. Anything beyond the request goes in *Out of
|
|
29
|
+
scope suggestions* for a separate decision.
|
|
30
|
+
|
|
31
|
+
The planner reads code but writes none. Its plan must contain:
|
|
32
|
+
|
|
33
|
+
0. **Framing** — the problem in the planner's own words: what is wrong now, what
|
|
34
|
+
would be true instead, why it matters, the approach chosen, and the alternatives
|
|
35
|
+
rejected with a reason each. The human checks this first; a wrong restatement
|
|
36
|
+
makes everything after it wrong.
|
|
37
|
+
1. **Goal** — one paragraph, in the user's terms, on what will be true when done.
|
|
38
|
+
2. **Scope** — what is included, and an explicit *not included* list. The second list
|
|
39
|
+
is what prevents the builder from wandering.
|
|
40
|
+
3. **Existing material to reuse** — concrete references: `path:line` for code, section
|
|
41
|
+
or page for a document, the existing asset for anything else. A plan that proposes
|
|
42
|
+
building something that already exists is a failed plan, in any track.
|
|
43
|
+
4. **File manifest** — every path this run will read or change, as a flat list. The
|
|
44
|
+
planner already located them; the builder and the reviewer read this list instead
|
|
45
|
+
of searching the material again. A path missing here is a path the later stages
|
|
46
|
+
will have to find twice.
|
|
47
|
+
5. **Steps** — ordered, each naming what it touches and what changes.
|
|
48
|
+
6. **Verification** — how the result gets proven, in the track's terms: which tests
|
|
49
|
+
and commands for code; which claims get checked against which source for a
|
|
50
|
+
document; who reads it and understands what for communication work; who executes
|
|
51
|
+
it unaided for a runbook. "It should work" is not verification in any track.
|
|
52
|
+
|
|
53
|
+
Write this as a **numbered gate** — `G-01`, `G-02`, … — derived from the track's
|
|
54
|
+
third answer, *what would make it wrong*. The numbering is per run, not a standing
|
|
55
|
+
catalogue: the sixth kind of work still gets a real gate because its gate is
|
|
56
|
+
written from its own request rather than looked up. Each item is one checkable
|
|
57
|
+
question, and each carries a tier, which is where its severity comes from:
|
|
58
|
+
|
|
59
|
+
- **block** — the run is wrong if this fails. Reviewer severity `critical` or `high`.
|
|
60
|
+
- **reason** — the thing is allowed, but the builder must write down why. An
|
|
61
|
+
unexplained new dependency, abstraction, file, or section fails this tier.
|
|
62
|
+
Reviewer severity `medium`.
|
|
63
|
+
- **lock** — consistency with what is already there. Reviewer severity `low`.
|
|
64
|
+
|
|
65
|
+
Phrase every item so the answer is yes or no. "Handles errors well" is not a gate
|
|
66
|
+
item; "every new query path has a covering test" is. A tier fixes the severity
|
|
67
|
+
before the reviewer has an opinion, which is what stops the same class of problem
|
|
68
|
+
being `high` in one run and `medium` in the next.
|
|
69
|
+
7. **Risks** — what could break, what is irreversible, what needs a migration or a
|
|
70
|
+
backup taken first.
|
|
71
|
+
8. **Open questions** — assumptions that survived the interview. If this list is
|
|
72
|
+
non-empty, the approval must ask the user about it rather than defaulting.
|
|
73
|
+
9. **Out of scope suggestions** — worthwhile things noticed but not asked for, each
|
|
74
|
+
its own proposal. Never folded into a step.
|
|
75
|
+
|
|
76
|
+
The plan is a proposal, not a decision. It never edits files, runs migrations, or
|
|
77
|
+
installs packages.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Plan approval
|
|
82
|
+
|
|
83
|
+
Controlled by `approvals.plan` (default on), skipped in `auto`.
|
|
84
|
+
|
|
85
|
+
Present to the user, in this order:
|
|
86
|
+
|
|
87
|
+
1. The track, the goal, and the top risk — a few lines, not the whole plan file.
|
|
88
|
+
2. **The work list**, verbatim from the plan: plain bullets of what will actually be
|
|
89
|
+
done. This is the last thing the user sees before anything is produced, so it must
|
|
90
|
+
be readable on its own, without the plan's reasoning around it.
|
|
91
|
+
3. The open questions, **as a pick list** — see below.
|
|
92
|
+
|
|
93
|
+
Do not dump the whole plan into the terminal; point at its path for the detail.
|
|
94
|
+
|
|
95
|
+
**Ask with options, not open prose.** Every question the plan raises is put to the
|
|
96
|
+
user as a selectable choice with 2–4 concrete options, using whatever mechanism the
|
|
97
|
+
tool provides for structured questions (in Claude Code, the AskUserQuestion tool).
|
|
98
|
+
The planner writes the options; the main thread renders them, because a subagent
|
|
99
|
+
cannot prompt the user directly. Never add an "other" option by hand — a free-text
|
|
100
|
+
answer is always available, and the user may ignore the options entirely.
|
|
101
|
+
|
|
102
|
+
This applies to any question the workflow asks at any stage, not only at this
|
|
103
|
+
approval.
|
|
104
|
+
|
|
105
|
+
**This approval is a conversation, not a form.** The user does not have to type an
|
|
106
|
+
approval command. "Yes but drop step three", "do it", "no — I meant the other panel",
|
|
107
|
+
"what happens if it fails halfway?" are all valid responses and are handled as what
|
|
108
|
+
they plainly are. Answer questions at the approval without treating them as rejections;
|
|
109
|
+
a person interrogating the plan is doing exactly what the approval exists for.
|
|
110
|
+
|
|
111
|
+
Partial approval is normal: apply the modification to the plan, restate what changed
|
|
112
|
+
in one line, and proceed on the modified plan. A change large enough to alter the
|
|
113
|
+
goal goes back through the planner instead.
|
|
114
|
+
|
|
115
|
+
Write the outcome to `02-approval.md`: decision, reason, timestamp, and any
|
|
116
|
+
modification the user asked for. When the decision is an approval — full or partial —
|
|
117
|
+
the same write appends to `runs/<id>/06-backlog.md` every out-of-scope suggestion that
|
|
118
|
+
was not folded into the approved scope, plus anything cut from scope at this approval,
|
|
119
|
+
each as `open` — see *Backlog* below for the format. The backlog is a candidate list,
|
|
120
|
+
not a commitment list, so silence at the approval captures the item rather than losing
|
|
121
|
+
it. A rejection appends nothing: there is no approved scope yet to measure against, and
|
|
122
|
+
the approval of the revised plan is what captures the items, once.
|
|
123
|
+
|
|
124
|
+
**A rejection is one of two different things, and the reason says which.** "Do it
|
|
125
|
+
differently" is a revise: hand the file back to the planner with the reason, it
|
|
126
|
+
produces a new `01-plan.md`, and the run returns to this same approval. "Not doing
|
|
127
|
+
this" is a kill: the request itself was wrong, not just the approach — mark
|
|
128
|
+
`stage: "abandoned"` in `state.json` and stop; there is nothing to revise toward.
|
|
129
|
+
|
|
130
|
+
Read the reason to tell which. Revise-shaped: disagreement with an approach, a step,
|
|
131
|
+
a scope boundary, an assumption — anything where a different plan would be accepted.
|
|
132
|
+
Kill-shaped: the goal is no longer wanted, was based on a misunderstanding now
|
|
133
|
+
resolved outside the plan, or a "no" with no implied alternative. When genuinely
|
|
134
|
+
unclear, state which reading was taken in `02-approval.md` rather than guessing
|
|
135
|
+
silently — a wrong revise wastes one planner cycle; a wrong kill discards a plan that
|
|
136
|
+
should have been fixed instead, silently and without a record.
|
|
137
|
+
|
|
138
|
+
Either way, do not proceed to implementation on a rejected plan under any mode. A
|
|
139
|
+
revised plan returns through this same approval; a killed run's `stage` never advances
|
|
140
|
+
past `"abandoned"`.
|
|
141
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Kaizen — review stage
|
|
2
|
+
|
|
3
|
+
Read with [`spec.md`](spec.md) (core: track, intake, resume). This file is the
|
|
4
|
+
reviewer's contract. The planner and builder do not read it.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
## Stage 3 — Review
|
|
8
|
+
|
|
9
|
+
**Agent:** reviewer, with a context that has never seen the builder's reasoning.
|
|
10
|
+
**Input:** `01-plan.md` (its File manifest names what to read), `03-impl.md`, the
|
|
11
|
+
track, and the work produced.
|
|
12
|
+
**Output:** `04-review.md`.
|
|
13
|
+
|
|
14
|
+
The track's third answer — *what would make it wrong* — is the reviewer's primary
|
|
15
|
+
brief. It reads that first and hunts for it specifically.
|
|
16
|
+
|
|
17
|
+
Five checks are universal, in every track:
|
|
18
|
+
|
|
19
|
+
1. **Correctness** — is it true, and does it hold up? For code: logic errors,
|
|
20
|
+
unhandled cases, broken error paths, races, leaks. For a document: false claims,
|
|
21
|
+
internal contradictions, unsupported conclusions. For communication: overclaims,
|
|
22
|
+
and meaning the audience will not take as intended.
|
|
23
|
+
2. **Plan conformance** — did the work do what was approved, no more and no less?
|
|
24
|
+
Scope creep is a finding. So is a step quietly skipped.
|
|
25
|
+
3. **Blast radius** — what else touches what changed. A diff shows the lines that
|
|
26
|
+
moved; it does not show who depended on them. For every changed function, export,
|
|
27
|
+
schema field, config key, endpoint, or shared string, find its other callers and
|
|
28
|
+
readers and check each one still holds. This is the check a diff cannot contain,
|
|
29
|
+
and skipping it is how a run that passes its own verification breaks a feature
|
|
30
|
+
nobody looked at. In a non-code track the same question is "what else quoted,
|
|
31
|
+
linked to, or depended on the part that changed".
|
|
32
|
+
4. **Regression** — the builder's before-and-after results from `03-impl.md`, verified
|
|
33
|
+
rather than trusted: re-run the checks. A check that passed at baseline and fails
|
|
34
|
+
now is a `high` finding at minimum, whatever else the work achieved. If the builder
|
|
35
|
+
recorded no baseline, that absence is itself the finding.
|
|
36
|
+
|
|
37
|
+
5. **The plan's gate** — every `G-nn` item from the plan's Verification section,
|
|
38
|
+
re-answered against the work rather than against `03-impl.md`. A gate item the
|
|
39
|
+
builder marked `PASS` with no evidence behind it, or with evidence that only
|
|
40
|
+
restates the item, is treated as unproven and re-checked here; if it does not hold,
|
|
41
|
+
that is the finding. A `reason`-tier item fails when the technique is present and
|
|
42
|
+
the written reason is not.
|
|
43
|
+
|
|
44
|
+
Then the track's own checks. For software work: security, reuse and simplification,
|
|
45
|
+
test coverage. For a document: completeness against its own structure, accuracy of
|
|
46
|
+
every checkable claim, whether its intended reader can actually use it. For
|
|
47
|
+
operational work: missing prerequisites, absent rollback, steps that cannot be
|
|
48
|
+
executed as written. The plan's Verification section says what was promised; the
|
|
49
|
+
reviewer checks that promise was kept.
|
|
50
|
+
|
|
51
|
+
Each finding is one line, numbered from 1 within the review:
|
|
52
|
+
`<n>. <where>: <severity>: <problem>. <fix>. [G-nn]` Where is a `path:line` for code,
|
|
53
|
+
and a section, page, or step reference otherwise. Severity is one of `critical`,
|
|
54
|
+
`high`, `medium`, `low`. The number is what the user approves fixes by, and what the
|
|
55
|
+
fix loop and the backlog refer to afterward, so it never changes once written.
|
|
56
|
+
|
|
57
|
+
**A finding against a gate item cites it, and takes its severity from that item's
|
|
58
|
+
tier** — `block` is `critical` or `high`, `reason` is `medium`, `lock` is `low`. This
|
|
59
|
+
is what keeps the same class of problem from being graded differently run to run, and
|
|
60
|
+
it is not a judgment the reviewer re-litigates: the tier was set at the plan, which
|
|
61
|
+
the user approved. A finding outside the gate carries no id and is graded on its own
|
|
62
|
+
merits.
|
|
63
|
+
|
|
64
|
+
The reviewer verifies before reporting: a finding it cannot construct a concrete
|
|
65
|
+
failing input or scenario for is dropped, not softened into a maybe. No praise, no
|
|
66
|
+
summary of what the code does, no style nits that do not change meaning.
|
|
67
|
+
|
|
68
|
+
The reviewer also appends any durable lesson about this material to `memory.md` —
|
|
69
|
+
a recurring bug pattern, a non-obvious constraint, a convention worth keeping. Not
|
|
70
|
+
run-specific detail; only what the next run would want to know.
|
|
71
|
+
|
|
72
|
+
`memory.md` is read by every stage of every future run, so its size is a tax on all of
|
|
73
|
+
them. Keep it under `review.memory_max_lines` (default 100): before appending, drop
|
|
74
|
+
any lesson that is now wrong, already enforced by a test or a lint rule, or restated
|
|
75
|
+
by a newer entry. A memory file that only grows stops being read carefully.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Stage 4 — Fix loop
|
|
80
|
+
|
|
81
|
+
Governed by `auto_fix`. See the skill's fix-loop section for the exact behavior.
|
|
82
|
+
|
|
83
|
+
Each iteration writes `05-iterations/NN-fix.md` (what the builder changed) and
|
|
84
|
+
`NN-recheck.md` (what the reviewer found afterward). The loop ends when the reviewer
|
|
85
|
+
reports nothing at or above the threshold, or `max_iterations` is reached.
|
|
86
|
+
|
|
87
|
+
A finding the loop could not close is escalated to the user with the reviewer's
|
|
88
|
+
description intact — never quietly downgraded to make the run look clean.
|
|
89
|
+
|