@warren-dean/code-kit 0.3.4

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.
Files changed (42) hide show
  1. package/.claude-plugin/marketplace.json +18 -0
  2. package/.claude-plugin/plugin.json +23 -0
  3. package/LICENSE +21 -0
  4. package/README.md +369 -0
  5. package/SECURITY.md +7 -0
  6. package/bin/code-kit.mjs +398 -0
  7. package/hooks/guard-bash.mjs +223 -0
  8. package/hooks/guard-paths.mjs +70 -0
  9. package/hooks/hooks.json +71 -0
  10. package/hooks/lane-audit.mjs +58 -0
  11. package/hooks/lib/adapters/context-graph.mjs +34 -0
  12. package/hooks/lib/adapters/index.mjs +34 -0
  13. package/hooks/lib/baseline.mjs +23 -0
  14. package/hooks/lib/checks.mjs +67 -0
  15. package/hooks/lib/config.mjs +211 -0
  16. package/hooks/lib/dependencies.mjs +129 -0
  17. package/hooks/lib/diff.mjs +122 -0
  18. package/hooks/lib/glob.mjs +42 -0
  19. package/hooks/lib/hook.mjs +19 -0
  20. package/hooks/lib/layers.mjs +57 -0
  21. package/hooks/lib/next.mjs +197 -0
  22. package/hooks/lib/plan.mjs +206 -0
  23. package/hooks/lib/rules.mjs +313 -0
  24. package/hooks/lib/trace.mjs +69 -0
  25. package/hooks/lib/verify.mjs +146 -0
  26. package/hooks/post-edit-check.mjs +40 -0
  27. package/hooks/stop-check.mjs +84 -0
  28. package/package.json +41 -0
  29. package/skills/check/SKILL.md +19 -0
  30. package/skills/dispatch/SKILL.md +83 -0
  31. package/skills/init/SKILL.md +151 -0
  32. package/skills/next/SKILL.md +52 -0
  33. package/skills/review/SKILL.md +57 -0
  34. package/skills/spec-check/SKILL.md +27 -0
  35. package/skills/spec-design/SKILL.md +137 -0
  36. package/skills/status/SKILL.md +42 -0
  37. package/templates/agent.md +29 -0
  38. package/templates/brief.md +45 -0
  39. package/templates/claude-md.md +23 -0
  40. package/templates/github-workflow.yml +23 -0
  41. package/templates/plan.md +30 -0
  42. package/templates/spec.md +52 -0
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@warren-dean/code-kit",
3
+ "version": "0.3.4",
4
+ "description": "Keeps AI coding agents inside your project's rules: lanes, layer rules, protected paths and proof before finish, enforced by Claude Code hooks and in CI",
5
+ "license": "MIT",
6
+ "author": "Warren Langeveldt",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/warrendeanlangeveldt/code-kit.git"
11
+ },
12
+ "homepage": "https://github.com/warrendeanlangeveldt/code-kit#readme",
13
+ "bugs": "https://github.com/warrendeanlangeveldt/code-kit/issues",
14
+ "keywords": [
15
+ "claude-code",
16
+ "claude-code-plugin",
17
+ "ai-agents",
18
+ "guardrails",
19
+ "architecture",
20
+ "ci"
21
+ ],
22
+ "bin": {
23
+ "code-kit": "bin/code-kit.mjs"
24
+ },
25
+ "files": [
26
+ "bin",
27
+ "hooks",
28
+ "skills",
29
+ "templates",
30
+ ".claude-plugin",
31
+ "README.md",
32
+ "LICENSE",
33
+ "SECURITY.md"
34
+ ],
35
+ "engines": {
36
+ "node": ">=22"
37
+ },
38
+ "scripts": {
39
+ "test": "node --test test/units.test.mjs && node test/hooks.test.mjs"
40
+ }
41
+ }
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: check
3
+ description: Validate the project's .claude/code-kit.json and show who owns what. Use after changing the config, when a path's owner or layer is unclear, or when the person asks what the kit enforces here.
4
+ ---
5
+
6
+ # Check the code-kit config
7
+
8
+ From the project root:
9
+
10
+ ```bash
11
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" check
12
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" unowned
13
+ ```
14
+
15
+ - If `check` reports problems, fix `.claude/code-kit.json` (the lead only). Until it's valid, every write except the config itself is blocked.
16
+ - Files listed by `unowned` can't be written by anyone. Give each one an owner, or confirm with the person that it should stay frozen.
17
+ - For a particular path, run `node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" who <path>...`. It shows the path's owner and layer.
18
+
19
+ Report the summary, and any problem or unowned file, in a few lines.
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: dispatch
3
+ description: Hand stories from the plan to their lane agents, as many at once as can safely run in parallel. Picks the ready stories, checks each is buildable, briefs each lane agent with its story, requirements and acceptance criteria, and starts it on its own branch and worktree. Use when the lead is ready to start building, asks what to work on next, or runs /code-kit:dispatch [story IDs, a milestone, or "next"].
4
+ ---
5
+
6
+ # Dispatch stories to lanes
7
+
8
+ Only the lead dispatches. Lane agents build; the lead writes contracts, reviews and merges.
9
+
10
+ The argument names what to dispatch: story IDs (`ST-4 ST-7`), a milestone, or `next` (everything that's ready). With no argument, show what's ready and ask.
11
+
12
+ The CLI is `node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs"`, run from the project root.
13
+
14
+ ## 1. See what's ready
15
+
16
+ ```bash
17
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" status
18
+ ```
19
+
20
+ A story is **ready** when its dependencies are done and nobody has started it. `status` also lists gaps between the specs and the plan; a story with a gap (an unknown lane, a requirement no spec defines) isn't dispatched until the lead fixes the plan.
21
+
22
+ If the project has no `docs.plan`, or the plan has no stories in the `### ST-n` form (`${CLAUDE_PLUGIN_ROOT}/templates/plan.md`), stop and suggest the spec-design skill.
23
+
24
+ ## 2. Check each story before it goes
25
+
26
+ For every story you're about to dispatch, read in full:
27
+
28
+ - the story in the plan;
29
+ - every requirement it cites, in its spec, with the spec's open questions;
30
+ - the lane's agent file in `.claude/agents/`.
31
+
32
+ Then check:
33
+
34
+ - **No open question blocks it.** If a spec's open questions touch a cited requirement, don't dispatch the story; list the question for the person.
35
+ - **The contracts exist.** If the story needs an API schema, event or database contract that isn't written yet, that's the lead's work first. Write it (the lead owns contracts), commit it on the lead's branch, then dispatch. A lane never invents a contract.
36
+ - **The lane is right.** Run `who` on the paths the story will touch. If they belong to two lanes, split the story or sequence it; don't hand one lane another's files.
37
+ - **Nothing overlaps.** At most one story per lane at a time, unless two stories touch disjoint folders. Two lanes may run in parallel; that's the point of lanes.
38
+
39
+ Commit everything the lanes need first. Each lane branches from the lead's branch as committed, so uncommitted work isn't there.
40
+
41
+ ## 3. Brief and start each lane
42
+
43
+ Start each story with the Agent tool: `subagent_type` is the lane's agent, `isolation: "worktree"`, and run them in the background. Start every story in the batch in the same message so they run in parallel.
44
+
45
+ The brief is the agent's whole context. Write it so the agent needs nothing else:
46
+
47
+ ```text
48
+ Story ST-<n>: <title> (lane <lane>)
49
+ Branch: <lane>/st-<n>. Create it first, from the lead's branch: git switch -c <lane>/st-<n> <lead's branch>
50
+
51
+ Requirements (read each one in full, with its acceptance criteria):
52
+ - <spec path>#<ID> <name>
53
+ - …
54
+
55
+ What to build: <the story's description, and anything the lead decided that the spec doesn't say>
56
+ Contracts to use: <paths of the schemas, events or tables this story relies on>
57
+ Out of scope: <what neighbouring stories or other lanes will do>
58
+
59
+ Steps:
60
+ 1. Run the spec-check skill against these requirements and save the report (the path guard requires it).
61
+ If it recommends "blocked on questions", stop and report the questions.
62
+ 2. Build it end to end in your lane's paths. No mocks, stubs, placeholder screens or "coming soon".
63
+ 3. Write tests that prove each acceptance criterion. Name the requirement ID in each test's title,
64
+ e.g. test('BOOK-4 a customer can cancel up to 24 hours before'), so `code-kit status` can trace it.
65
+ 4. Run <the lane's proving command> until it passes.
66
+ 5. Commit on your branch. The message names ST-<n>, what changed and the proof.
67
+ 6. Finish with: what you built, per requirement; the commands you ran and their output; open questions.
68
+ ```
69
+
70
+ **A person running a lane** instead of an agent gets its own worktree, marked with the lane:
71
+
72
+ ```bash
73
+ git worktree add ../<repo>-<lane>-st-<n> -b <lane>/st-<n> <lead's branch>
74
+ echo <lane> > ../<repo>-<lane>-st-<n>/.lane
75
+ ```
76
+
77
+ Give them the same brief. Claude Code opened in that worktree then acts as the lane.
78
+
79
+ ## 4. Keep track
80
+
81
+ - Set each dispatched story's `**Status:**` in the plan to `in progress`, and commit it on the lead's branch.
82
+ - Tell the person, in a few lines: what was dispatched, to which lane and branch, what's still blocked and on what, and what's ready next.
83
+ - As each agent finishes, read its report. If it came back blocked on questions, bring the questions to the person. If it came back done, run the review skill on its branch.
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: init
3
+ description: Set up code-kit in a project, or bring an existing setup up to date. Works from the project's docs (new builds) or from its code (brownfield), drafts .claude/code-kit.json, the lane agents and the CLAUDE.md section, and shows the person exactly what changes before anything is enforced. Use when the person says to apply the kit to a project, to re-run or refresh it, or runs /code-kit:init [docs path].
4
+ ---
5
+
6
+ # Set up or update code-kit
7
+
8
+ The argument, if given, is the path to the project's docs (a folder or one file).
9
+
10
+ Always the same shape: **read, draft, show, and switch on only once the person approves.** The hooks read only `.claude/code-kit.json`. Every draft goes to `.claude/code-kit.draft.json`, which enforces nothing.
11
+
12
+ The CLI is `node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs"`, run from the project root. Its commands are `check`, `unowned`, `who`, `diff`, `baseline` and `graph`, each taking `--config <file>` to read the draft.
13
+
14
+ ## Which situation
15
+
16
+ - **`.claude/code-kit.json` exists** → **Update** (section 4). The lanes stay in step with the build.
17
+ - **No config, and the docs describe the architecture** → **New from docs** (sections 1–3).
18
+ - **No config, and the docs are thin or missing** → **Brownfield** (sections 1–3, with the brownfield steps). The code is the main source, and the docs fill in what they can.
19
+
20
+ - **No config, no code and no docs** (just an idea) → stop and suggest `/code-kit:spec-design` first. It writes the brief, specs, architecture, principles and plan this skill works from.
21
+
22
+ Say which one applies and why before you start.
23
+
24
+ ## 1. Read everything first
25
+
26
+ 1. **The docs, in full.** Every file under the docs path, not excerpts. Note where each of these is described:
27
+ - **Layers:** names, which folders each covers, which way dependencies point, what each may not use.
28
+ - **Work split:** lanes, teams, packages, apps or services, and who owns which paths. An implementation plan or a sub-agent table is the best source.
29
+ - **Principles:** engineering rules, definitions of done, what counts as a contract.
30
+ - **Protected things:** registers, contracts and schemas that need a person's sign-off.
31
+ - **Design-first rules:** screens designed before they are built, and where approvals are listed.
32
+ - **Commands:** test, lint, typecheck, database and deploy commands, and which must never run locally.
33
+ 2. **The repository.** Map the real layout: `git ls-files | cut -d/ -f1-3 | sort | uniq -c`, package manifests (`package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`), workspace files, existing lint, format and test scripts, CI workflows and CODEOWNERS.
34
+ 3. **Existing kit.** If the project has `.claude/hooks`, agents or skills, read them. The kit replaces local hooks; agents and skills are kept and adapted, not rewritten.
35
+ 4. **Other tools.** Run `adapters --config .claude/code-kit.draft.json` once the draft exists. It lists the tools code-kit has an adapter for (such as Context Graph, found by its `.ctx/` folder), what each adds to the rules, and the setup each needs. Don't copy an adapter's paths into the config; they're added automatically while the tool is present.
36
+
37
+ **Brownfield, in addition:**
38
+
39
+ 5. **Find the layers in the code.** Run `graph` (default depth 2, and `--depth 3` for deeper packages). It lists which folders import which, most-used first. Look for:
40
+ - folders nothing depends on (the edges: apps, UI, entry points);
41
+ - folders everything depends on (the core: domain, schemas, shared types);
42
+ - edges in both directions between two folders. These are existing tangles; record them, don't design around them.
43
+ 6. **Find the work split in the history.** Use `git log --format='%an' -- <folder> | sort | uniq -c | sort -rn | head` per top-level folder, plus CODEOWNERS. Folders that change together and are worked on by the same people make a lane.
44
+ 7. **Check the checks.** Run each candidate check command once on the current code, before proposing it. If a command already fails, that's a finding, not a check to switch on silently. Offer three options: fix first, leave it out for now, or scope `files` narrower so it guards only new work.
45
+
46
+ ## 2. Draft the config
47
+
48
+ Write `.claude/code-kit.draft.json`. Follow `${CLAUDE_PLUGIN_ROOT}/README.md` › Config for every field.
49
+
50
+ - **`docs`:**
51
+ - `specs`, `principles` and `plan` as found. `plan` is the plan file itself; with stories in the `### ST-n` form, the dispatch, review and status skills work from it. Leave `specs` out if the project has no specs: without it, lanes aren't held to a spec-check report.
52
+ - Brownfield: if there are no specs, say so, and offer the spec-check gate for later, once specs exist.
53
+ - **`layers`:** one entry per layer, documented or found in the graph. Each needs:
54
+ - `paths`: globs matching where that layer's code really lives;
55
+ - `mayImport`: the direction the docs set. For brownfield code, the direction most of the code already follows;
56
+ - `denyPackages`: packages forbidden for that layer, for example `node:*` or a vendor SDK outside its adapter.
57
+ - Also add `importAliases` for path aliases in `tsconfig` `paths` that the graph can't see. Workspace package names are found automatically.
58
+ - The import check reads JavaScript and TypeScript. For another language, record the layers anyway (agents and spec-check use them), and say the import check doesn't cover that language yet.
59
+ - **`lanes`:** one per documented or discovered ownership area. Each needs:
60
+ - `agent`: a kebab-case agent name, for example `api-engineer`;
61
+ - `paths` and `exclude`: every path must have exactly one owner.
62
+ - **`lead.paths`:** contracts, specs, design, root config, and anything the docs reserve for the lead.
63
+ - **`anyActor`:** lockfiles, if lanes may update them.
64
+ - **`protected`:** registers and contracts that need a person's sign-off, each with an `approval` name and a `why`.
65
+ - **`designGate`:** only if the docs require designs before screens.
66
+ - **`shell.block`:** deploy, release and production commands reserved for CI or a person.
67
+ - **`shell.restricted`:** commands that affect a shared local service, limited to the lanes that own it.
68
+ - **`postEdit`:** the project's existing per-file linters and formatters, with `{file}`.
69
+ - **`checks`:** the typecheck, test, architecture and database commands, each scoped by `files`. Only include commands that pass on the current code, or ones the person chose to keep.
70
+
71
+ Prove the draft:
72
+
73
+ ```bash
74
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" check --config .claude/code-kit.draft.json
75
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" unowned --config .claude/code-kit.draft.json
76
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" baseline --config .claude/code-kit.draft.json
77
+ ```
78
+
79
+ - **`check`:** fix every problem it reports.
80
+ - **`unowned`:** a file it lists can't be written by anyone. Give each one an owner, or confirm with the person that it should stay frozen.
81
+ - **`baseline`:** lists the layer violations already in the code.
82
+ - New from docs: expect none. Any it finds are drift from the documented design; list them.
83
+ - Brownfield: expect some. They'll be recorded as the baseline, so only new violations block.
84
+
85
+ ## 3. Agents, CLAUDE.md, and switching on
86
+
87
+ Draft, alongside the config:
88
+
89
+ - **One agent per lane:** write `.claude/agents/<agent>.md` from `${CLAUDE_PLUGIN_ROOT}/templates/agent.md`, filled in from the docs (or the code, for brownfield):
90
+ - owned paths;
91
+ - its layers and what they may depend on;
92
+ - the specs it reads;
93
+ - the command that proves its work;
94
+ - its lane rules.
95
+ - If an agent already exists, keep its content and add only what's missing.
96
+ - Drop the spec-check lines if the config has no `docs.specs`.
97
+ - **CLAUDE.md:** add the section from `${CLAUDE_PLUGIN_ROOT}/templates/claude-md.md`.
98
+ - **Project skills** (recipes like "new migration" or "new endpoint"): list the recipes the docs describe step by step, and offer to write them. Don't write them unasked, and never write an empty one.
99
+
100
+ Show the person:
101
+
102
+ 1. the layers and what each may depend on, and for brownfield the existing violations the baseline will record;
103
+ 2. the lanes, their agents and their paths;
104
+ 3. protected paths, blocked and restricted commands, and checks (including any left out because they fail today);
105
+ 4. the active adapters and what each adds, from `adapters`;
106
+ 5. every **question**: where the docs or the code are silent, ambiguous or contradictory. Don't guess; a wrong owner or layer blocks real work.
107
+
108
+ Once they approve (with any changes):
109
+
110
+ 1. Rename the draft to `.claude/code-kit.json`. From then on, every hook enforces it.
111
+ 2. If there are existing violations, run `baseline --write`. This writes `.claude/code-kit.baseline.json`.
112
+ 3. If the project had local hooks in `.claude/settings.json` that the kit replaces, remove those hook entries and the local hook files. Keep the `permissions` block.
113
+ 4. Add `.claude/approvals/`, `.claude/state/` and `.claude/code-kit.draft.json` to `.gitignore`. Add `.claude/approval-log.jsonl merge=union` to `.gitattributes`: when lanes and the lead both log changes, merging keeps every entry instead of conflicting.
114
+ 5. Apply each active adapter's `setup` lines (ignore files, merge drivers, the CLAUDE.md note), and say which you applied.
115
+ 6. Offer CI enforcement, since the hooks only see Claude Code sessions. On yes:
116
+ - write `.github/workflows/code-kit.yml` from `${CLAUDE_PLUGIN_ROOT}/templates/github-workflow.yml`;
117
+ - set the version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json`;
118
+ - fill in the install steps the project's checks need, from its existing CI or package manager;
119
+ - make sure the lead owns the workflow file, and add it to `protected` (approval `ci`, why "the CI that enforces the rules"), so a lane can't switch it off;
120
+ - tell the person to make the `code-kit` check required on the protected branches.
121
+ 7. Run `check` and `unowned` again, without `--config`.
122
+ 8. Commit on a branch. The kit records the protected files in `.claude/approval-log.jsonl`.
123
+
124
+ Report what was set up, what's enforced from now on, how many existing violations the baseline holds, and the open questions.
125
+
126
+ ## 4. Update an existing setup
127
+
128
+ Re-run whenever the build has moved on: new apps or packages, folders that moved, a changed plan, or files `unowned` keeps listing.
129
+
130
+ 1. **Re-read** the docs and the repository as in section 1, including the brownfield steps if the code has grown past the docs.
131
+ 2. **Draft** the whole config again into `.claude/code-kit.draft.json`, starting from the live one. Keep everything that's still right, so the diff shows only real changes.
132
+ 3. **Show the difference:**
133
+
134
+ ```bash
135
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" diff --config .claude/code-kit.draft.json
136
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" unowned --config .claude/code-kit.draft.json
137
+ ```
138
+
139
+ `diff` lists lanes, layers, checks and rules that were added (`+`), removed (`-`) or changed (`~`), and how many files change owner, route by route. Explain each change in a sentence, with where it came from: the doc section, or the folder in the repository.
140
+
141
+ 4. **Also propose:**
142
+ - agent files for new lanes, and updates to agents whose paths changed;
143
+ - a smaller baseline when `baseline` shows violations were fixed. It only ever shrinks.
144
+ 5. **On approval:**
145
+ 1. Replace `.claude/code-kit.json` with the draft and delete the draft.
146
+ 2. Write or update the agents.
147
+ 3. Run `baseline --write` if it shrank.
148
+ 4. Run `check` and `unowned`.
149
+ 5. Commit on a branch.
150
+
151
+ Nothing changes until then.
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: next
3
+ description: The one command for code-kit. Reads where the project stands (a blank folder, a spec being shaped, a ready spec, existing code, a draft config, stories ready, finished or being built) and runs the right skill in the right order, carrying on until something needs the person. Use when the person runs /code-kit:next, asks "what now?" or "what's next?", wants to start a project with code-kit without knowing which skill to use, or comes back to a project mid-build.
4
+ ---
5
+
6
+ # Next step
7
+
8
+ The argument, if given, is passed to the first skill that runs. From a blank folder, that's the idea itself: `/code-kit:next a booking app for mobile dog groomers`.
9
+
10
+ ## 1. Read the state
11
+
12
+ ```bash
13
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" next --json
14
+ ```
15
+
16
+ It returns `step`, `why`, `args`, `then` (steps that can follow straight after) and `attention` (things the person should know). The order it applies:
17
+
18
+ | State | Step |
19
+ | ---------------------------------------------------------- | --------------------------------------------------------- |
20
+ | Invalid config | `check`, then fix the config |
21
+ | No config, a draft waiting | `init`, to show it for approval |
22
+ | No config, a spec still being shaped (brief not `ready`) | `spec-design`, resuming |
23
+ | No config, a ready spec | `init <docs folder>` |
24
+ | No config, existing code or docs | `init` |
25
+ | Nothing at all | `spec-design` |
26
+ | Config, but no specs, plan or stories | `spec-design` |
27
+ | Stories finished on their branches | `review`, then `dispatch` what's ready |
28
+ | Stories ready | `dispatch` |
29
+ | Stories being built, nothing else can start | wait |
30
+ | Ready stories with gaps in the plan, or a dependency cycle | `spec-design`, to fix the plan |
31
+ | Every story done | done: `status`, then `spec-design` for the next milestone |
32
+
33
+ Tell the person in one or two lines what you found and what you're about to run, with anything under `attention`. If `attention` says the folder isn't a git repository, run `git init` before init (spec-design doesn't need one).
34
+
35
+ ## 2. Run it
36
+
37
+ Run the named skill with the Skill tool: `code-kit:<step>`, with `args` (and the person's argument, if they gave one). Follow that skill in full. This skill only chooses; it never does a step's work itself.
38
+
39
+ - **`wait`:** say which stories are being built and on which branches, then stop. When a lane agent finishes, its notification arrives in this session; run this skill again then. If a story has been in progress with no agent running (the session ended, or the agent stopped without committing), dispatch it again.
40
+ - **`done`:** give the `status` summary in a few lines, then offer to run spec-design for the next milestone or feature.
41
+
42
+ ## 3. Keep going until the person is needed
43
+
44
+ After a step finishes, run `next --json` again and carry on with the new step, without asking, as long as nothing needs the person. Stop and hand over when:
45
+
46
+ - a skill asks the person questions (spec-design's rounds, spec-check's blocking questions, review's scope questions);
47
+ - something needs the person's approval (init's draft, an approval for a protected path);
48
+ - a person has to act: merge a pull request to a protected branch, add a CI secret;
49
+ - the step is `wait` or `done`;
50
+ - the same step comes back twice in a row with nothing changed. Report what's stuck instead of looping.
51
+
52
+ When you stop, end with one line saying what happens next and who does it, e.g. "Next: you approve the draft config, then I dispatch ST-1 to ST-4."
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: review
3
+ description: The lead's review of a lane's finished branch before it merges. Runs code-kit verify on the branch, checks the work against its story's requirements and acceptance criteria, the spec-check report, the approval log and the tests, and ends with merge or send back. Use when a lane agent or person finishes a story, when the person asks to review a branch or pull request, or runs /code-kit:review [branch, story ID or PR number].
4
+ ---
5
+
6
+ # Review a lane's branch
7
+
8
+ Only the lead reviews. The argument names the branch (`web/st-4`), the story (`ST-4`, whose branch is `<lane>/st-4`) or a pull request number. With none, review every story `code-kit status` shows in review.
9
+
10
+ The CLI is `node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs"`. `<base>` is the branch the lanes started from: the lead's branch, or the first protected branch.
11
+
12
+ ## 1. Find the work
13
+
14
+ - **The branch and its story.** `status --json` lists each story with its branch, its commits ahead of the base, and its worktree, if one is checked out. For a pull request, `gh pr view <n> --json headRefName,baseRefName` gives both.
15
+ - **Where to run things.** Use the branch's worktree if it has one. Otherwise check it out in a throwaway worktree: `git worktree add .claude/worktrees/review-st-<n> <branch>`, and remove it when you're done.
16
+ - **The spec-check report** is in that worktree, in `.claude/state/spec-check/<branch with / as _>.md`. The state folder isn't committed, so a branch pushed from elsewhere may not have one. Say so, and review against the specs directly.
17
+
18
+ ## 2. Run the rules
19
+
20
+ From the branch's worktree:
21
+
22
+ ```bash
23
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" verify --base <base>
24
+ ```
25
+
26
+ `verify` holds a `<lane>/…` branch to that lane's paths, and checks:
27
+
28
+ - that every protected change is in the approval log, which is append-only;
29
+ - new layer violations, and a baseline that grew;
30
+ - screens without an approved design;
31
+ - committed secrets;
32
+ - the project's checks for the changed files.
33
+
34
+ Any problem it reports means the branch goes back. Don't fix a lane's code yourself; the lead doesn't write lane paths.
35
+
36
+ ## 3. Check the work against the story
37
+
38
+ Read the story, every requirement it cites, and the full diff (`git diff <base>...<branch>`). Read each changed file in full where the diff alone doesn't show the behaviour. Then, for each requirement:
39
+
40
+ | Requirement | Acceptance criterion | Built (where) | Test (which) | Verdict |
41
+ | ----------- | -------------------- | ------------- | ------------ | ------- |
42
+
43
+ - **Built end to end:** the behaviour works from the entry point to storage and back, including the errors, permissions and states the spec lists. A mock, stub, hard-coded response, placeholder screen, `TODO` or "coming soon" in shipped code fails the requirement.
44
+ - **Tested:** a test proves each acceptance criterion and names the requirement ID. The test would fail if the behaviour were broken; one that asserts nothing, or only asserts a mock, doesn't count.
45
+ - **The spec-check report matches:** its table has no row still `missing` or `conflicts` without an answer, and its questions were answered, not guessed.
46
+ - **Only the story:** changes beyond the story (refactors elsewhere, other stories' requirements, new dependencies) are called out. They may be fine, but they're the person's call.
47
+ - **Contracts respected:** the code uses the contracts as written. A lane that needed a contract change should have asked, not worked around it.
48
+
49
+ ## 4. Verdict
50
+
51
+ Report the table, `verify`'s result and one of:
52
+
53
+ - **Merge.** Everything passes. The lead merges the branch into its own branch (`git merge --no-ff <branch>`), sets the story's `**Status:**` to `done` in the plan, and commits. `main` and the other protected branches are merged by a person, through a pull request, after `verify` passes in CI. When the branch is merged, remove its worktree.
54
+ - **Send back.** List each problem, where it is, and what "fixed" looks like. Send the list to the same lane agent if it's still running (SendMessage), or dispatch the story again with the list added to the brief. Set the story's status to `in progress`.
55
+ - **Ask the person.** When the right answer is a product or scope decision (the spec is silent, or the lane found a real conflict), put the question to the person with your recommendation. Don't merge around it.
56
+
57
+ Keep the report short: the verdict first, then the table, then the problems.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: spec-check
3
+ description: Check a task against the project's specs before implementing it, and again before declaring it done. Produces the requirement table that the code-kit path guard requires before a lane writes code on a branch. Use at the start of any non-trivial task, or when checking code against the spec.
4
+ ---
5
+
6
+ # Spec check
7
+
8
+ The project's specs are in the folder named by `docs.specs` in `.claude/code-kit.json`. The engineering principles are in `docs.principles`, and the plan in `docs.plan`.
9
+
10
+ ## Steps
11
+
12
+ 1. **Find the section.** The task should name its requirement IDs (`BOOK-4`, headings in the specs) or a spec section. If it doesn't, search the specs folder for the domain nouns. Read the whole section, not just the matching lines, plus every section it references.
13
+ 2. **Read the principles.** Re-read the parts of `docs.principles` that apply: layers, ports and providers, events, testing and the rules for agents. Note this lane's layer rules from `layers` in the config.
14
+ 3. **Make a checklist.** One line per requirement: behaviour, fields, error cases, permissions, states, tests.
15
+ 4. **Compare with the code.** For each line, search for where it's implemented, then read those files in full.
16
+ 5. **Report** as a table:
17
+
18
+ | Requirement | Status (done / partial / missing / conflicts) | Where | Note |
19
+ | ----------- | --------------------------------------------- | ----- | ---- |
20
+
21
+ 6. **List questions** for the lead wherever the spec is missing, ambiguous, or contradicts the code or another spec. Don't resolve them by guessing.
22
+
23
+ ## Output
24
+
25
+ The table, the questions, and a one-line recommendation: ready to implement, or blocked on questions.
26
+
27
+ **Save it** to `.claude/state/spec-check/<branch>.md`, with `/` in the branch name replaced by `_` (for example `lane_data-e2-s1.md`). The table must keep its `| Requirement |` header. A lane can't write code on a branch until this report exists, and the lead reads it when reviewing the pull request. If the recommendation is "blocked on questions", stop and ask the lead instead of writing code.
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: spec-design
3
+ description: Turn an idea into a buildable specification by working it through with the person. Frames the problem, explores options, asks the questions that decide scope and behaviour, and writes the brief, specs, architecture, principles and plan that code-kit init and spec-check work from. Use when someone starts a new product or feature with an idea rather than a spec, wants to ideate or shape requirements, or runs /code-kit:spec-design [idea or docs path]. Also use to resume or extend specs it wrote earlier.
4
+ ---
5
+
6
+ # Spec design
7
+
8
+ The argument is either the idea itself, in a sentence or a paragraph, or the path to the docs folder to write to (default `docs/`). If `.claude/code-kit.json` exists, use its `docs.specs`, `docs.principles` and `docs.plan` paths instead of the defaults.
9
+
10
+ The job is to think the idea through **with** the person, not for them. You propose, question and push back; they decide. Every decision ends up in a document, so the build never depends on a conversation nobody can read later.
11
+
12
+ The output is what the rest of code-kit runs on:
13
+
14
+ | File | Holds | Used by |
15
+ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
16
+ | `docs/brief.md` | Problem, users, outcomes, scope, non-goals, the decision log and the open questions (`${CLAUDE_PLUGIN_ROOT}/templates/brief.md`) | Everyone; where a resumed session starts |
17
+ | `docs/specs/NN-<area>.md` | One capability area each, with numbered requirements (`${CLAUDE_PLUGIN_ROOT}/templates/spec.md`) | `spec-check`, lane agents |
18
+ | `docs/architecture.md` | Components, layers and which way they depend, contracts, integrations, quality targets | `init` (layers, lanes, protected paths) |
19
+ | `docs/principles.md` | Engineering rules, what counts as a contract, the definition of done, commands | `init` (checks, shell rules), lane agents |
20
+ | `docs/plan.md` | Milestones, stories that cite requirement IDs, the work split into lanes, sequencing | `init` (lanes), the lead delegating work |
21
+
22
+ ## Which situation
23
+
24
+ - **A new idea, no docs** → all phases, from 1.
25
+ - **Docs this skill wrote earlier** (`docs/brief.md` exists) → **Resume**: read every file in full, then start from the brief's open questions and the phase its `Status` line names. Say where you're picking up.
26
+ - **An existing codebase, a new feature** → phases 1–4 and 6 for the feature, and phase 5 only where the feature changes the architecture. Read the code first (entry points, the modules the feature touches, existing docs and the code-kit config). Existing layers, contracts and conventions are constraints, not suggestions. Write the feature's spec next to the others and add its stories to the existing plan.
27
+
28
+ Say which one applies before you start.
29
+
30
+ ## How to ask
31
+
32
+ The questions are the skill. Ask well:
33
+
34
+ - **Only what the person can answer.** Look up anything the repository, the docs or a quick search can tell you, and state what you found instead of asking.
35
+ - **Few at a time.** Up to four questions per round, most decisive first: a question whose answer changes the shape of everything else comes before any detail. Use the AskUserQuestion tool for choices, with 2–4 concrete options, your recommendation first and marked, and a line on what each option costs. Ask open questions in plain text.
36
+ - **Say why it matters.** One clause per question on what the answer changes: scope, a data model, a permission, a dependency, the cost.
37
+ - **Offer a default.** When you have a sensible default, state it, so "yes" is a complete answer.
38
+ - **Push back.** Name contradictions, scope creep, risky assumptions, and requirements that can't be tested. Suggest the smaller version that still delivers the outcome.
39
+ - **Never fill a gap by guessing.** An unanswered question goes into the brief's open questions with its owner and what it blocks. It doesn't quietly become a requirement.
40
+
41
+ After each round, summarise what was decided in a few lines, append it to the decision log, and move on.
42
+
43
+ ## 1. Frame
44
+
45
+ Get the problem straight before any solution:
46
+
47
+ - **Problem:** what's wrong or missing today, for whom, and how they cope now.
48
+ - **Users:** each kind of user or actor, including admins, other systems and scheduled jobs, and what each is trying to get done.
49
+ - **Outcome:** what's different when this works, and how anyone will know. Prefer something observable ("a new customer books without calling us") over a feature list.
50
+ - **Why now, and constraints:** deadline, budget, team, required platforms and technology, regulation and data residency, existing systems it must fit.
51
+ - **Non-goals:** what this deliberately won't do. Ask for them; they are as useful as the goals.
52
+
53
+ Write `docs/brief.md` as soon as the frame is agreed, with `Status: framed`, and keep it current from then on.
54
+
55
+ ## 2. Explore
56
+
57
+ Before narrowing, widen:
58
+
59
+ - Sketch **two or three different shapes** of solution: different scopes, workflows or build-versus-buy choices, not the same idea three times. For each: how it works in a paragraph, what it's good at, what it costs, the biggest risk.
60
+ - Walk through the **main journey** of each kind of user, step by step, for the shape you recommend. Journeys expose missing capabilities faster than feature lists.
61
+ - List the **riskiest assumptions**: things that, if wrong, sink the idea. Say how each could be checked cheaply.
62
+ - **Recommend** one shape and say why. The person chooses.
63
+
64
+ Record the choice and the rejected options, with why, in the decision log. `Status: explored`.
65
+
66
+ ## 3. Shape the scope
67
+
68
+ - Break the chosen shape into **capability areas**, for example accounts, booking, payments, notifications, admin. Each becomes one spec file.
69
+ - For each area, agree what's in the **first release** and what's later. The first release must be a complete, working slice end to end, with nothing mocked or stubbed and no placeholder screens. If it's too big, cut capability, not quality.
70
+ - Agree **quality targets** that change the build: expected scale, response times, availability, security and privacy, accessibility, supported devices and languages.
71
+
72
+ Write the scope into the brief. `Status: scoped`.
73
+
74
+ ## 4. Specify
75
+
76
+ Write one spec per capability area from `${CLAUDE_PLUGIN_ROOT}/templates/spec.md`. Work through the areas one at a time, with a round of questions per area.
77
+
78
+ Each requirement gets an ID (`<AREA>-<n>`, for example `BOOK-4`) and its own heading, `### BOOK-4 Short name`, which is how `code-kit status` finds it. `ST` is reserved for stories. Every requirement must be testable: someone reading it can say whether the code does it. For every area, work through:
79
+
80
+ - **Behaviour:** what each actor can do, step by step, including what the system does in response.
81
+ - **Data:** the entities, their fields, types, which are required, uniqueness, and who owns the data.
82
+ - **States:** the lifecycle of anything that changes state, with the allowed transitions and what triggers each.
83
+ - **Rules:** validation, calculations, limits and business rules, with real values rather than "reasonable".
84
+ - **Permissions:** who can see and do what, including other users' data.
85
+ - **Errors and edge cases:** invalid input, duplicates, concurrency, partial failure, timeouts, an external service being down, empty and very large data.
86
+ - **Events and integrations:** what other parts of the system or external services are told, and what they send back.
87
+ - **Acceptance criteria:** Given / When / Then for the main path and for each important error.
88
+
89
+ A spec answers what and why, not how: no framework, file or function names unless the person requires them. Anything still undecided goes in the spec's open questions and the brief's, never into a requirement. `Status: specified`.
90
+
91
+ ## 5. Architecture, principles and plan
92
+
93
+ These are what `/code-kit:init` turns into enforced rules, so be concrete.
94
+
95
+ - **`docs/architecture.md`:**
96
+ - the components (apps, services, packages, jobs) and what each is for;
97
+ - the **layers**, the folders each will live in, and which layers each may depend on (for example `ui → application → domain`, with adapters implementing the domain's ports);
98
+ - what each layer must not use, for example no database client in the domain;
99
+ - the **contracts** (API schemas, events, database schema) and who may change them;
100
+ - external services and how each is isolated;
101
+ - how the quality targets from phase 3 are met.
102
+ Propose the architecture from the specs and constraints, explain the choices, and ask about the ones that matter. Record each in the decision log.
103
+ - **`docs/principles.md`:** the engineering rules; what counts as a contract; the definition of done (tests, checks, reviews, end-to-end working features); the test, lint, typecheck and database commands once they're known; and which commands only CI or a person may run, such as deploys.
104
+ - **`docs/plan.md`**, from `${CLAUDE_PLUGIN_ROOT}/templates/plan.md`:
105
+ - the **work split**: lanes (for example web, api, data), the paths each will own, the agent name for it and the command that proves its work, so work can run in parallel without overlap;
106
+ - milestones, each a usable increment;
107
+ - stories, each small enough for one lane to finish on one branch. Each story is a `### ST-<n> Title` heading with `**Lane:**`, `**Requirements:**` (the IDs it delivers), `**Depends on:**` and `**Status:** todo` lines. `code-kit status` and the dispatch skill read them. A story that needs two lanes is two stories, with a dependency between them;
108
+ - sequencing: contracts and shared foundations first (the lead's own stories), then work that can run in parallel.
109
+
110
+ `Status: planned`.
111
+
112
+ ## 6. Check it's buildable
113
+
114
+ Before handing over, review everything once, as a sceptical engineer about to build it:
115
+
116
+ - every journey step maps to a requirement, and every requirement to a story;
117
+ - every requirement is testable and has acceptance criteria where it matters;
118
+ - data, states, permissions and errors are covered for every area;
119
+ - no requirement contradicts another, the constraints or a non-goal;
120
+ - nothing is left as "TBD" outside the open-questions lists.
121
+
122
+ Fix what you can. Put the rest to the person as a last round of questions. Then give them:
123
+
124
+ 1. what was written, file by file, in one line each;
125
+ 2. the open questions that still block building, with who owns each;
126
+ 3. the next steps:
127
+ - `/code-kit:init docs/` turns the architecture, principles and plan into enforced lanes and layers. If the project already runs code-kit, `/code-kit:init` updates it.
128
+ - `/code-kit:dispatch next` starts the ready stories on their lanes. Each lane spec-checks its story against these specs before writing code.
129
+ - `/code-kit:review` checks each finished branch against its requirements before it merges.
130
+ - `/code-kit:status` shows where the build stands against the spec.
131
+ - Or just `/code-kit:next`, which picks each of these in turn.
132
+
133
+ `Status: ready` once no open question blocks the first milestone.
134
+
135
+ ## Keep it current
136
+
137
+ A spec is the source of truth while it's being built. When a decision changes, re-run this skill: update the spec, the brief's decision log and the plan together, and keep requirement IDs stable (mark a dropped requirement `Removed` rather than reusing its number). If the project enforces code-kit and the specs are protected paths, the change goes through the approval log like any other.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: status
3
+ description: Where the build stands against the spec. Traces every requirement to its story, branch and tests, shows what's done, in review, ready or blocked, lists gaps between the specs, the plan and the tests, and brings the plan's status fields up to date. Use when the person asks how the build is going, what's left, what's untested or what to do next, or runs /code-kit:status.
4
+ ---
5
+
6
+ # Build status
7
+
8
+ From the project root:
9
+
10
+ ```bash
11
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" status # the report
12
+ node "${CLAUDE_PLUGIN_ROOT}/bin/code-kit.mjs" status --json # the same, to work from
13
+ ```
14
+
15
+ Add `--base <ref>` when the lanes branch from something other than the first protected branch, for example the lead's integration branch.
16
+
17
+ It reads the specs (`### BOOK-4 …` headings), the plan (`### ST-n` stories with `**Lane:**`, `**Requirements:**`, `**Depends on:**` and `**Status:**`), git (each story's `<lane>/st-n` branch) and the tracked tests (which requirement IDs each names). If the config has no `docs.specs` or `docs.plan`, suggest the spec-design skill instead.
18
+
19
+ ## Report
20
+
21
+ Lead with the answer, in a few lines:
22
+
23
+ 1. **Progress:** requirements done, of how many; stories done, in review, in progress, ready and blocked. Name the milestone that's closest to done and what it still needs.
24
+ 2. **Needs the lead now:**
25
+ - stories in review (run the review skill);
26
+ - stories that are ready (run the dispatch skill);
27
+ - blocked stories, and what they wait on.
28
+ 3. **Risks:**
29
+ - requirements marked done that no test names;
30
+ - requirements in no story;
31
+ - stories citing requirements no spec defines;
32
+ - stories whose branch has been in review a long time.
33
+
34
+ Then the detail only if the person asks: the story table and the requirement table from the CLI.
35
+
36
+ "No test names it" means no tracked test mentions the ID, so it may be tested under another name. Treat it as a question for the review, not proof of a gap.
37
+
38
+ ## Keep the plan current
39
+
40
+ `status` shows where the plan's `**Status:**` lines disagree with git ("the plan is out of date"). Offer to fix them. The lead edits the plan, updates the lines, and commits on the lead's branch. Git is right about branches; the plan is right about `done` for stories whose branch was merged and deleted.
41
+
42
+ Gaps between the specs and the plan (a requirement in no story, an unknown lane, a duplicate ID) are the lead's to fix in the plan or the spec. If fixing one needs a product decision, ask the person rather than guessing.