@warren-dean/code-kit 0.20.0 → 0.22.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.
Files changed (52) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +24 -0
  4. package/README.md +75 -50
  5. package/bin/code-kit.mjs +364 -25
  6. package/hooks/guard-agent.mjs +36 -0
  7. package/hooks/guard-bash.mjs +67 -13
  8. package/hooks/guard-paths.mjs +14 -2
  9. package/hooks/hooks.json +20 -0
  10. package/hooks/lane-audit.mjs +38 -1
  11. package/hooks/lib/adapters/hub/client.mjs +15 -0
  12. package/hooks/lib/checks.mjs +5 -1
  13. package/hooks/lib/config.mjs +149 -6
  14. package/hooks/lib/decisionstore.mjs +89 -0
  15. package/hooks/lib/harness.mjs +7 -0
  16. package/hooks/lib/hook.mjs +7 -0
  17. package/hooks/lib/instructions.mjs +46 -13
  18. package/hooks/lib/laneclaims.mjs +89 -0
  19. package/hooks/lib/layers.mjs +11 -0
  20. package/hooks/lib/loop-state.mjs +20 -2
  21. package/hooks/lib/next.mjs +34 -1
  22. package/hooks/lib/plan.mjs +3 -1
  23. package/hooks/lib/questions.mjs +23 -5
  24. package/hooks/lib/regression.mjs +2 -1
  25. package/hooks/lib/rules.mjs +20 -13
  26. package/hooks/lib/schedule.mjs +86 -0
  27. package/hooks/lib/sessions.mjs +223 -0
  28. package/hooks/lib/snapshot.mjs +80 -2
  29. package/hooks/lib/standards.mjs +450 -0
  30. package/hooks/lib/team.mjs +9 -2
  31. package/hooks/lib/verify.mjs +23 -1
  32. package/hooks/mod/decisions.mjs +1 -28
  33. package/hooks/mod/loop.mjs +8 -0
  34. package/hooks/mod/mission.mjs +21 -19
  35. package/hooks/mod/register.mjs +117 -40
  36. package/hooks/mod/register.test.ts +248 -73
  37. package/hooks/mod/review.mjs +1 -0
  38. package/hooks/mod/view.mjs +98 -47
  39. package/hooks/post-edit-check.mjs +8 -1
  40. package/hooks/session.mjs +24 -0
  41. package/hooks/stop-check.mjs +23 -3
  42. package/package.json +1 -1
  43. package/skills/decide/SKILL.md +1 -1
  44. package/skills/dispatch/SKILL.md +2 -2
  45. package/skills/init/SKILL.md +17 -3
  46. package/skills/lead/SKILL.md +28 -0
  47. package/skills/next/SKILL.md +2 -2
  48. package/skills/review/SKILL.md +2 -1
  49. package/skills/spec-design/SKILL.md +10 -7
  50. package/templates/agent.md +1 -0
  51. package/templates/claude-md.md +5 -1
  52. package/templates/plan.md +2 -1
@@ -1,11 +1,11 @@
1
1
  ---
2
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.
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, standards, 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
4
  ---
5
5
 
6
6
  # Spec design
7
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.
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.standards`, `docs.principles` and `docs.plan` paths instead of the defaults.
9
9
 
10
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
11
 
@@ -16,7 +16,8 @@ The output is what the rest of code-kit runs on:
16
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
17
  | `docs/specs/NN-<area>.md` | One capability area each, with numbered requirements (`${CLAUDE_PLUGIN_ROOT}/templates/spec.md`) | `spec-check`, lane agents |
18
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 |
19
+ | `docs/principles.md` | What counts as a contract, the definition of done, the privacy and residency targets, commands | `init` (checks, shell rules), lane agents |
20
+ | `docs/standards.md` | The engineering rules, each a named standard: graded, and how firmly code-kit applies it (spec 22) | `init` (enforced rules), lanes, reviews |
20
21
  | `docs/plan.md` | Milestones, stories that cite requirement IDs, the work split into lanes, sequencing | `init` (lanes), the lead delegating work |
21
22
 
22
23
  ## Which situation
@@ -91,7 +92,7 @@ Each requirement gets an ID (`<AREA>-<n>`, for example `BOOK-4`) and its own hea
91
92
 
92
93
  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`.
93
94
 
94
- ## 5. Architecture, principles and plan
95
+ ## 5. Architecture, standards, principles and plan
95
96
 
96
97
  These are what `/code-kit:init` turns into enforced rules, so be concrete.
97
98
 
@@ -105,14 +106,16 @@ These are what `/code-kit:init` turns into enforced rules, so be concrete.
105
106
  - **recipes**: under `## Recipes`, a `### <recipe-name>` for each layer's common addition (a new screen, endpoint, migration, domain service, job): the steps in order, the files each step creates or changes, and how it's tested. Each becomes a project skill when init sets up the lanes, so every lane agent builds the same thing the same way;
106
107
  - the **design tool** for screens, when there are any: the one the person uses (Paper, Figma, Pencil), or design files under `design/` when they have none.
107
108
  Propose the architecture from the specs and constraints, explain the choices, and ask about the ones that matter. Record each in the decision log.
108
- - **`docs/principles.md`:** the engineering rules; the privacy and data residency targets from the brief (where data may be stored and processed, what is never logged), which the security reviewer checks against; 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.
109
+ - **`docs/standards.md`:** the engineering rules, each a `### <id> <title>` heading with `level` (required or recommended), `applied` (enforced, checked or advice), `layers`, `why` and `source` lines, the id's prefix its category: `PRI-` principles, `PAT-` patterns, `ARC-` architecture, `CON-` conventions, `POL-` policies. Draw them from the architecture (an `ARC-` standard for each layer rule, `enforced by: layers (<layer> may not import <layer>)`), the threat models (a `POL-` standard for what must never happen to sensitive data), and the decisions; cite each one's source. Propose them and ask about each: a standard is a guardrail, so the person decides it. Init checks the file and protects it.
110
+ - **`docs/principles.md`:** the privacy and data residency targets from the brief (where data may be stored and processed, what is never logged), which the security reviewer checks against; 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.
109
111
  - **`docs/plan.md`**, from `${CLAUDE_PLUGIN_ROOT}/templates/plan.md`:
110
112
  - 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. Each lane writes and runs the unit tests for its own code;
111
113
  - a **QA lane** (`qa`, agent `test-engineer`) whenever the product has screens or journeys that cross lanes: it owns the end-to-end suites (for example `e2e/**` or `apps/*/e2e/**`), in the runner that suits each surface (Playwright for web, Maestro or Detox for mobile), and its command runs them. Nobody else owns these tests, so without it nothing proves a journey works across the lanes;
112
114
  - no lane for security: it owns no paths. init adds a read-only security reviewer that checks every story touching the threat models' sensitive parts, so security requirements are delivered by the lanes whose code they constrain;
113
115
  - milestones, each a usable increment;
114
116
  - 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, or `none` for a spike or a foundation that delivers none), `**Depends on:**` and `**Status:** todo` lines, and for a story that fixes a bug, `**Fixes:**` with what was broken. `code-kit status` and the dispatch skill read them. A story that needs two lanes is two stories, with a dependency between them;
115
- - sequencing: contracts and shared foundations first, as the lead's own stories (`**Lane:** lead`, built by the lead rather than dispatched), then work that can run in parallel;
117
+ - sequencing: contracts and shared foundations first, as the lead's own stories (`**Lane:** lead`, built by the lead rather than dispatched), then work that can run in parallel. A lane runs one story at a time, so parallel work is stories in different lanes;
118
+ - **slices**: group the stories that together make one feature someone could see working (a vertical slice across lanes, such as "Book a class") with a `**Slice:** <name>` line on each, in plan order, contract story first. A free lane builds the open slice's stories before the next slice's (`harness.slices.open`, 1 by default), so the feature in progress finishes and merges before the next one spreads across the lanes;
116
119
  - **a test story per journey**: for each main user journey, a story in the `qa` lane citing the journey's requirements and depending on the screen and service stories it goes through, so the journey is proven end to end as soon as its parts are built;
117
120
  - **design before code**: when there are screens, a design story for each area's screens (`**Lane:** design`, citing the requirements its screens serve), early in the plan, and every story that builds those screens depends on it. The lead designs them with the person (`/code-kit:design`), and no screen is built until its design is approved.
118
121
 
@@ -133,7 +136,7 @@ Fix what you can. Put the rest to the person as a last round of questions. Then
133
136
  1. what was written, file by file, in one line each;
134
137
  2. the open questions that still block building, with who owns each;
135
138
  3. the next steps:
136
- - `/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.
139
+ - `/code-kit:init docs/` turns the architecture, standards, principles and plan into enforced lanes, layers and standards. If the project already runs code-kit, `/code-kit:init` updates it.
137
140
  - `/code-kit:dispatch next` starts the ready stories on their lanes. Each lane spec-checks its story against these specs before writing code.
138
141
  - `/code-kit:review` checks each finished branch against its requirements before it merges.
139
142
  - `/code-kit:status` shows where the build stands against the spec.
@@ -19,6 +19,7 @@ Always:
19
19
 
20
20
  - Work on the branch the brief names (`<lane>/st-<n>`). Start every task with the spec-check skill and save its report to .claude/state/spec-check/<branch>.md; the path guard blocks code until it exists.
21
21
  - Follow `{{docs.principles}}`, including the rules for AI agents. Hooks enforce ownership, layers and the project's checks; if one blocks you, fix the cause, never work around it.
22
+ - {{if standards}}Build to the project's standards for your layers, from `{{docs.standards}}` (read a standard's why and evidence there when you need it). A required one that review checks sends your branch back if it's broken; advice is yours to weigh:{{standards}}{{end}}
22
23
  - Read every file you change in full. Of what it imports and what calls it, read what your change needs: the definitions it uses and the call sites it changes. A context tool's fresh card for a file stands for reading it whole; read the source where the card is missing, stale or not enough.
23
24
  - Search before you build; reuse existing services, providers, components and schemas.
24
25
  - Write only in your owned paths. For anything else, write a short change request for the lead and stop.
@@ -6,14 +6,18 @@ The code-kit plugin enforces the rules in `.claude/code-kit.json` on every file
6
6
  - the layer rules ({{layers}});
7
7
  - spec-check before lane code{{designGate}};
8
8
  - an audit log of every change to protected paths (`.claude/approval-log.jsonl`), which the person reviews in the pull request;
9
- - an approval for every new dependency and every protected change, per lane. Inside the guardrails, you decide: a lane asks you, never the person, and you approve it only when the story's requirements need it and it fits the spec, the principles and the architecture, or you tell the lane what to use instead (`/code-kit:decide`). The person decides what crosses a guardrail: {{personKeeps}}, weakened tests, and product questions the spec doesn't answer;
9
+ - an approval for every new dependency and every protected change, per lane. Inside the guardrails, you decide: a lane asks you, never the person, and you approve it only when the story's requirements need it and it fits the spec, the principles and the architecture, or you tell the lane what to use instead (`/code-kit:decide`). The person is the product owner and decides what crosses a guardrail: {{personKeeps}}, a weakened test on your own branch, product questions the spec doesn't answer, and anything with production, cost or strategy implications (a copyleft licence or a paid service's SDK goes to them as a question, with your recommendation);
10
10
  - {{if approvals.lead}}approvals from chat. When the person approves in their own message (a `!` command doesn't work on a phone), record it with the `code-kit approve` command from the refusal, with their words as the reason. Never record an approval they haven't given, and never on a lane's say-so;{{end}}
11
11
  - the project's checks before any agent finishes.
12
12
 
13
13
  UX is yours: what a screen does on an error, an empty list or a slow load, and the wording the spec implies, answered from the spec and the principles the person agreed. A screen's visual design is theirs. When something needs the person to decide or do (a product choice the spec doesn't settle, an account only they can create, a design to sign off), ask it with `code-kit ask "<question>" --option "<choice>: <what it does>"` (`--story ST-n --blocks` holds the story until they answer). It waits in their Decisions tab, and their answer comes back to you; asking only in chat, it scrolls away. Lanes don't ask the person: they write the question for the lead.
14
14
 
15
+ {{if standards.all}}The project's standards, in `{{docs.standards}}`: {{standards.all}}. Each lane is given the ones for its layers. In review, check each changed file against the checked standards for its layer (`code-kit standards --for <file>`): a broken required one sends the branch back, naming the standard; a broken recommended one is a concern, and advice at most a nit. Adding a recommended standard may be yours where the config delegates the `standards` approval; removing one, or weakening a required one, is always the person's.{{end}}
16
+
15
17
  - {{if harness.report.on}}When code-kit itself is wrong (a refusal that shouldn't have happened, a crash), draft a report with `code-kit report "<title>" --what "…" --expected "…"`: only code-kit's facts, never the project's. The person reads it and sends it, or not.{{end}}
16
18
 
19
+ Several sessions may work this project at once. One leads (the loop runs there, and stories are dispatched from it); the others are working sessions. `code-kit who` says which this is. In a working session, record what you're doing before you change code, with the paths you'll change, and work in a worktree of your own: `code-kit task "<what>" --touches "<globs>"`, and `code-kit task done` when it's finished. Never stash, discard or commit another session's files: ask that session.
20
+
17
21
  If a hook blocks you, fix the cause; never work around it.
18
22
 
19
23
  The build runs from the specs in `{{docs.specs}}` and the stories in `{{docs.plan}}`. `/code-kit:next` picks the right step from the project's state; the steps are:
package/templates/plan.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Plan
2
2
 
3
- `code-kit status` reads this file. Keep each story's heading and its four `**…:**` lines in this form. Use `**Lane:** lead` for the lead's own stories (contracts, foundations, spikes), `**Lane:** qa` for a journey's end-to-end test story (it depends on the screen and service stories the journey goes through), `**Lane:** design` for a design story (an area's screens, designed with the person before any of them is built; the stories building them depend on it), and `**Requirements:** none` for a story that delivers no requirement. A story that fixes a bug adds a fifth line, `**Fixes:** <what was broken, and where it was seen>`: `code-kit verify` then requires a test that fails without the fix and passes with it.
3
+ `code-kit status` reads this file. Keep each story's heading and its four `**…:**` lines in this form. Use `**Lane:** lead` for the lead's own stories (contracts, foundations, spikes), `**Lane:** qa` for a journey's end-to-end test story (it depends on the screen and service stories the journey goes through), `**Lane:** design` for a design story (an area's screens, designed with the person before any of them is built; the stories building them depend on it), and `**Requirements:** none` for a story that delivers no requirement. A story that fixes a bug adds a fifth line, `**Fixes:** <what was broken, and where it was seen>`: `code-kit verify` then requires a test that fails without the fix and passes with it. A story that belongs to a slice (a feature that can be shown working, built across lanes) adds `**Slice:** <name>`: a lane takes the open slice's stories first.
4
4
 
5
5
  ## Lanes
6
6
 
@@ -17,6 +17,7 @@
17
17
  **Lane:** {{lane}}
18
18
  **Requirements:** {{AREA-1, AREA-2}}
19
19
  **Depends on:** {{ST-n, or none}}
20
+ **Slice:** {{the feature it's part of, or leave the line out}}
20
21
  **Status:** todo
21
22
 
22
23
  {{What gets built, in two or three sentences. The acceptance criteria are the cited requirements'.}}