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.
@@ -0,0 +1,130 @@
1
+ # Kaizen workflow specification
2
+
3
+ This file is the tool-neutral contract. Claude Code, Codex, and Antigravity all
4
+ follow this document; only the way stages are dispatched differs per tool. If an
5
+ adapter and this file disagree, this file wins.
6
+
7
+ A stage may only start when the previous stage's artifact exists on disk and the approval
8
+ between them, if enabled, has been resolved.
9
+
10
+ ---
11
+
12
+ ## The track
13
+
14
+ Kaizen is not a software workflow. The stage structure — frame, approve, produce,
15
+ review independently, fix under a bound — holds for a book, a marketing campaign, a
16
+ migration runbook, or a research memo just as well as for code. What changes per kind
17
+ of work is what the words *deliverable*, *verification*, and *finding* mean.
18
+
19
+ That meaning is fixed once, at intake, and recorded as the run's **track**. Every
20
+ later stage reads it and adapts. A reviewer hunting race conditions in a book
21
+ manuscript is worse than no reviewer at all, and a track is what prevents it.
22
+
23
+ **The track is inferred, never asked.** Reading a request and recognizing what kind
24
+ of work it is — an app, a chapter, a campaign, a runbook — is the workflow's job, not
25
+ the user's. Asking "is this software or writing?" hands back the analysis they came
26
+ here to have done, and a request almost always says which it is: what it names, the
27
+ verbs it uses, where the material lives, what the person is evidently trying to
28
+ produce. Read it and decide.
29
+
30
+ Do not classify against a fixed taxonomy of work types; the sixth kind of work will
31
+ not be on the list. Establish the track by answering three questions from the request
32
+ itself, and only then ask about what genuinely cannot be read from it:
33
+
34
+ 1. **What is the deliverable?** A merged code change, a chapter, a landing page, a
35
+ decision memo, a set of ad variants, a runbook someone else will execute.
36
+ 2. **What counts as done?** The concrete, checkable condition. Tests pass. The
37
+ chapter reads end to end without contradicting chapter two. A colleague can follow
38
+ the runbook without asking a question. Someone in the audience understands the
39
+ offer in one read.
40
+ 3. **What would make it wrong?** The failure this work must not have. A security
41
+ hole. A claim that is not true. A tone that alienates the reader. A step that
42
+ silently loses data.
43
+
44
+ Answer three is what the reviewer becomes. Answer two is what the builder must
45
+ demonstrate. Draft all three yourself from the request, then state them back as
46
+ conclusions — "this is a book chapter; done means it reads end to end without
47
+ contradicting chapter two; wrong means a claim that is not true" — so the user
48
+ corrects a reading rather than performing a classification. A wrong reading stated
49
+ plainly is easy to fix; a question about categories is work handed back.
50
+
51
+ Only where the request genuinely leaves the outcome open — two plausible readings
52
+ with materially different work behind them — does this become a question, and even
53
+ then ask about the outcome the user wants, never about which category the work
54
+ belongs to.
55
+
56
+ Common shapes, as illustration only — never as a menu to force a request into:
57
+
58
+ | Shape | Deliverable | Done means | Wrong means |
59
+ |---|---|---|---|
60
+ | Enhancing existing software | A change in this repo | Tests and the plan's checks pass | Regression, security hole, scope creep |
61
+ | Building something new | A working first version | It runs and does the named thing | Wrong foundation, unnecessary complexity |
62
+ | Writing and documentation | A document | Complete, accurate, follows its own structure | False claim, contradiction, unusable for its reader |
63
+ | Marketing and communication | Copy, campaign, positioning | The audience takes the intended meaning | Overclaim, wrong audience, off-brand |
64
+ | Operations and process | A runbook, a config, a migration | Someone else can execute it unaided | Missing rollback, unstated prerequisite |
65
+ | Research and analysis | Findings and a recommendation | The conclusion follows from evidence shown | Unsupported leap, cherry-picked data |
66
+
67
+ A run may be a mix. Record it as a mix — the honest description beats the nearest
68
+ label.
69
+
70
+ Record the track in `state.json` as `track`, with the three answers written into
71
+ `00-request.md`. Every subsequent stage reads them before starting, and the words
72
+ *build*, *verify*, and *finding* below are always to be read in the track's terms.
73
+
74
+ ---
75
+
76
+ ## Stage 0 — Intake
77
+
78
+ **Input:** the user's request.
79
+ **Output:** `runs/<id>/00-request.md`, `state.json`.
80
+
81
+ Create the run id as `YYYY-MM-DD-<short-kebab-slug>`. Write the request verbatim —
82
+ do not summarize it, since later stages read this instead of the conversation and a
83
+ summary is where requirements quietly disappear.
84
+
85
+ Verbatim includes the mess. Requests arrive as thinking out loud: half-formed,
86
+ out of order, self-correcting, with the decisive constraint tucked into an aside near
87
+ the end. Capture all of it, in the order it was said, including the parts that were
88
+ later revised — the revision only makes sense next to what it revised. Making sense
89
+ of that material is the planner's work, not the user's, and the user is never asked
90
+ to restate a request more precisely.
91
+
92
+ Then read the request and infer the track, per the section above. This is the one
93
+ moment where the direction of the whole run is set: whether it is an enhancement, a
94
+ build from nothing, a document, or work with no code in it at all. Getting it wrong
95
+ here is not recoverable later — every stage will do good work aimed at the wrong
96
+ target.
97
+
98
+ The inference is stated in the plan's Framing and confirmed at the plan approval along with
99
+ everything else. That is the correction point, and it is enough: the user reads one
100
+ sentence and either nods or says "no, this is a blog post". They are never asked to
101
+ categorize their own request up front.
102
+
103
+ Write into `00-request.md`: the verbatim request, the deliverable, what done means,
104
+ and what wrong means. Record in `state.json`: `id`, `mode`, `track`,
105
+ `stage: "plan"`, `awaiting: null`.
106
+
107
+ If the request remains ambiguous enough that a plan would be guesswork, ask now. One
108
+ round of questions here is cheaper than a rejected plan.
109
+
110
+ ---
111
+
112
+ ## Stage files
113
+
114
+ Read core (this file) plus the one file for the stage being run. Nothing else.
115
+
116
+ | Reader | Reads |
117
+ |---|---|
118
+ | Planner | `spec.md` + [`spec-plan.md`](spec-plan.md) |
119
+ | Builder | `spec.md` + [`spec-build.md`](spec-build.md) |
120
+ | Reviewer | `spec.md` + [`spec-review.md`](spec-review.md) |
121
+ | Main thread | `spec.md` + [`spec-main.md`](spec-main.md), plus the stage file for an approval it is presenting |
122
+
123
+ ---
124
+
125
+ ## Resume semantics
126
+
127
+ Any tool picking up a run reads `state.json` and continues from `stage`, honoring
128
+ `awaiting`. A run whose `awaiting` is non-null must not be advanced without a
129
+ recorded decision in `02-approval.md`. This is what makes a run safe to hand between
130
+ Claude Code, Codex, and Antigravity mid-flight.
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: kaizen-help
3
+ description: >
4
+ Quick-reference card for the kaizen workflow: commands, modes, approvals,
5
+ fix loop, config knobs, state layout, backlog/status rules. One-shot
6
+ display, not a persistent mode. Trigger: /kaizen-help, "kaizen help",
7
+ "what kaizen commands", "kaizen cheat sheet".
8
+ ---
9
+
10
+ # Kaizen Help
11
+
12
+ **Print the content of this card into your reply.** The user cannot see this file —
13
+ it loads into your context only, so summarizing it or saying "see above" shows them
14
+ nothing. Output the tables themselves.
15
+
16
+ One-shot: do NOT change kaizen's active mode, write to `state.json`, or persist
17
+ anything.
18
+
19
+ ## Commands
20
+
21
+ | Invocation | Action |
22
+ |---|---|
23
+ | `/kaizen <request>` | Start a new run in the configured mode (default: `approve`) |
24
+ | `/kaizen plan <request>` | Start a run and stop after the plan (`plan-only`) |
25
+ | `/kaizen auto <request>` | Start a run in `auto` mode: every stage back to back, no approval stops |
26
+ | `/kaizen run` | Resume the current run and execute the approved plan |
27
+ | `/kaizen review [target]` | Review-only: audit existing code, no plan, no implementation |
28
+ | `/kaizen status` | List every run grouped waiting-on-you / in flight / done / abandoned, plus open backlog count |
29
+ | `/kaizen backlog` | Print open backlog items across all runs, grouped by source run, rescued items last under `Orphaned` |
30
+ | `/kaizen approve` | Approve whatever the current run is waiting on |
31
+ | `/kaizen reject <reason>` | Reject it; the reason decides revise (back to planner) vs kill (abandon) |
32
+ | `/kaizen abort` | Mark the current run abandoned |
33
+ | `/kaizen init` | Install `.kaizen/` with `spec.md`, config, and the gitignore entry into the current repository |
34
+ | `/kaizen install` | Install the workflow itself globally or per-project |
35
+
36
+ `/kaizen` with no argument: `status` if a run is in progress, else ask what to build.
37
+
38
+ ## Modes
39
+
40
+ Set by `mode` in config, overridable per invocation.
41
+
42
+ | Mode | What it does |
43
+ |---|---|
44
+ | `plan-only` | Produce the plan, write it, stop. No code touched. |
45
+ | `approve` (default) | Stop at every enabled approval, wait for an explicit decision. |
46
+ | `auto` | Run every stage back to back, no approval, report at the end. Fix loop still respects `max_iterations`. |
47
+ | `review-only` | Skip plan and implementation, run the reviewer against existing code or a diff. |
48
+
49
+ Mode never overrides a refusal: destructive/irreversible actions still confirm even in `auto`.
50
+
51
+ ## Approvals
52
+
53
+ - `approvals.plan` — after the plan, before any code is written.
54
+ - `approvals.review` — after the review passes, before the work is called done.
55
+ - `approvals.each_file` — confirm each file edit individually. Off by default; slow.
56
+
57
+ A rejection is written to the run directory, and is one of two things — the reason
58
+ says which. **Revise** ("do it differently") goes back to the planner, which produces
59
+ a new plan and returns to the same approval. **Kill** ("not doing this") means the
60
+ request itself was wrong: set `stage: "abandoned"` and stop, nothing to revise toward.
61
+
62
+ ## Fix loop
63
+
64
+ - `auto_fix.enabled: false` — every finding stops the run, becomes a user decision.
65
+ - `auto_fix.enabled: true` — builder fixes findings at or above `auto_fix.min_severity`,
66
+ reviewer re-checks, up to `auto_fix.max_iterations` rounds. Findings below threshold,
67
+ and anything still open when iterations run out, are reported to the user.
68
+
69
+ Each iteration is written to `runs/<id>/05-iterations/`.
70
+
71
+ ## Config knobs (`config.default.yml` defaults)
72
+
73
+ | Key | Default | Meaning |
74
+ |---|---|---|
75
+ | `mode` | `approve` | Default run mode |
76
+ | `approvals.plan` | `true` | Stop after the plan |
77
+ | `approvals.review` | `true` | Stop after the review |
78
+ | `approvals.each_file` | `false` | Confirm every file edit |
79
+ | `auto_fix.enabled` | `true` | Auto-fix findings vs. escalate everything |
80
+ | `auto_fix.min_severity` | `high` | Threshold for auto-fix (`critical\|high\|medium\|low`) |
81
+ | `auto_fix.max_iterations` | `3` | Fix/recheck rounds before escalating remaining findings |
82
+ | `track.default` | `""` (empty, inferred per run) | Pin a track for a repo that is always one kind of work |
83
+ | `review.write_memory` | `true` | Let the reviewer append lessons to `.kaizen/memory.md` |
84
+ | `backlog.enabled` | `true` | Capture what a run deliberately did not do |
85
+ | `backlog.file` | `06-backlog.md` | Per-run backlog file |
86
+ | `backlog.orphan_file` | `backlog.md` | Where a pruned run's open items are rescued to |
87
+ | `state.dir` | `.kaizen` | State directory |
88
+ | `state.keep_runs` | `20` | Completed runs kept before pruning oldest (rescues open backlog first) |
89
+ | `git.auto_commit` | `false` | Never commit/push/PR unless the user explicitly asks |
90
+ | `git.branch_before_implement` | `true` | Branch before implement stage when on the default branch |
91
+
92
+ `.kaizen/config.yml` overrides only the keys it sets; everything else falls back to
93
+ this skill's `config.default.yml`.
94
+
95
+ ## State layout
96
+
97
+ ```
98
+ .kaizen/{spec.md, config.yml, memory.md, backlog.md (orphanage)}
99
+ .kaizen/runs/<id>/{00-request,01-plan,02-approval,03-impl,04-review}.md,
100
+ 05-iterations/, 06-backlog.md, state.json (id, mode, stage, awaiting, iteration, updated)
101
+ ```
102
+
103
+ ## Backlog and status
104
+
105
+ Backlog items: `- <status>: <item text>`, `<status>` one of `open`, `done`, `rejected`
106
+ (`rejected` carries a reason after `|`). `/kaizen backlog`/`status` are **read-only** —
107
+ never edit `06-backlog.md` or `state.json`, even to fix a spotted inconsistency; report
108
+ it and ask.
109
+
110
+ `/kaizen status` groups every run by `state.json` at read time: **Waiting on you**
111
+ (awaiting non-null, not abandoned), **In flight** (awaiting null, not done/abandoned),
112
+ **Done**, **Abandoned**, plus `Backlog: <n> open` (all runs + orphanage; abandoned
113
+ runs' items excluded).
114
+
115
+ ## More
116
+
117
+ Full walkthrough and rationale: `~/.claude/skills/kaizen/README.md`. Full stage
118
+ contract: `~/.claude/skills/kaizen/spec.md`. Codex/Antigravity porting:
119
+ `~/.claude/skills/kaizen/adapters.md`.