slicekit 0.6.0 → 0.6.2

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/README.md CHANGED
@@ -1,11 +1,117 @@
1
- # Agentic SliceKit
1
+ ![slicekit](docs/assets/slicekit-banner.png)
2
+
3
+ A closed-loop framework for spec-driven development with coding agents.
4
+
5
+ [![npm](https://img.shields.io/npm/v/slicekit)](https://www.npmjs.com/package/slicekit)
6
+ [![CI](https://github.com/adityapandya1/agentic-slicekit/actions/workflows/slicekit.yml/badge.svg)](https://github.com/adityapandya1/agentic-slicekit/actions/workflows/slicekit.yml)
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
8
+
9
+ ## Why
10
+
11
+ Most agent workflows add control through prompts and rule files, and the agent can skip both.
12
+ slicekit checks each step outside the agent: its CLI runs git and refuses a step out of order, its
13
+ hooks refuse an edit to a frozen test and check the spec each time the agent finishes a turn, and
14
+ CI runs the same checks on every pull request.
15
+
16
+ ## See it in action
17
+
18
+ The steps of a Claude Code session, from the requirement document to the release. Under each slash
19
+ command are lines the kit's commands print for it, taken from two sources named below the block, so
20
+ the pull request numbers and hosts differ between steps.
21
+
22
+ ```text
23
+ > /slicekit intake brief/orders.md
24
+ ⎿ docs/intake/2026-10-31-orders.md
25
+ D-02
26
+ open: D-09 Which payment provider do refunds go through?
27
+
28
+ > /slicekit specify
29
+ ⎿ #12 https://github.com/acme/orders/pull/12
30
+
31
+ > /slicekit gaps
32
+ ⎿ G-3 unknown D-09 is open: Which payment provider do refunds go through?
33
+ D-09
34
+ G-3 closed by D-09
35
+ ready: gap-scan
36
+
37
+ > /slicekit plan
38
+ ⎿ ready to plan
39
+ D-14
40
+ BUILD.md updated
41
+
42
+ > /slicekit build P1/S-01
43
+ ⎿ tests-red → building
44
+ #1 https://example.test/pull/1
45
+ next: ci
46
+ rounds: 1 of 2
47
+ ci-green
48
+ ready: waiting for an independent review; run /slicekit review 1 in a new session
49
+
50
+ > /slicekit review 1
51
+ ⎿ round 2
52
+ verdict …/.slicekit/reviews/P1-S-01i-r2.md
53
+ next: ci
54
+ ci-green
55
+ ready
56
+
57
+ > /slicekit release P1
58
+ ⎿ docs/releases/P1.md
59
+ released P1/S-01
60
+ ```
61
+
62
+ Intake, specify, gaps, plan and release lines are from the examples on the guide's command pages:
63
+ intake from `intake`, specify from `pr`, gaps from `gaps` and `decide`, plan from `plan`,
64
+ `decide` and the `--write` option of `status`, release from `release`. Build and review lines are from the
65
+ walkthrough on `examples/backend`, except the review's `verdict` line: it is the verdict file that
66
+ `review start` prints, with the path shortened from the left to `…/`.
67
+
68
+ ## What it covers
69
+
70
+ | Stage | Command | What you get |
71
+ |---|---|---|
72
+ | Any | `/slicekit` | any procedure below by name, for example `/slicekit build` |
73
+ | Brief | `/slicekit brief` | a brief written from the person's own answers, when there is only an idea and no requirement document |
74
+ | Intake | `/slicekit intake` | a frozen snapshot of the requirement document and one decision row per answer |
75
+ | Specify | `/slicekit specify` | spec files in which every requirement cites its source, and the spec pull request |
76
+ | Gaps | `/slicekit gaps` | each place the spec is silent, vague or in conflict with the intake, asked about and closed |
77
+ | Plan | `/slicekit plan` | the stack, the phases and the slice files, and the plan pull request |
78
+ | Build | `/slicekit build` | one slice from failing tests to a pull request with a verdict and green CI |
79
+ | Review | `/slicekit review` | an independent verdict from a session that holds no context of the build |
80
+ | Release | `/slicekit release` | the release record of a phase whose slices are merged, and the release pull request |
81
+ | Operate | `/slicekit ops` | the triage of a symptom: the slices that touched its files and the runbook's first checks |
82
+ | Audit | `/slicekit audit` | the claims of the spec and the runbook compared with the code, the tests and CI |
83
+ | Trace | `slicekit trace`, `slicekit impact`, `slicekit history`, `slicekit uncovered`, `slicekit shipped` | answers from the graph that `slicekit graph` builds from the kit's IDs and git |
84
+
85
+ ## Quick start
86
+
87
+ In your project, with Node 22 or later and git:
2
88
 
3
- Agentic SliceKit is a zero-dependency Node 22 kit for building software with AI coding agents on
4
- Claude Code, one slice at a time, with a traceable line from every requirement to its tests,
5
- commits, pull requests and releases. The spec stays true because a machine checks it each time the
6
- agent finishes a turn and again in CI, not because anyone remembers to update it.
89
+ ```sh
90
+ npm install --save-dev slicekit
91
+ npx slicekit init --shape backend --name <your-project>
92
+ ```
93
+
94
+ Then open Claude Code in the project and type `/slicekit intake <your requirement document>`. To
95
+ see each step run on a sample project first, follow
96
+ [the ten-minute walkthrough](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/walkthrough.md)
97
+ from a clone of this repository.
98
+
99
+ ## How it differs
7
100
 
8
- ## Status: preview
101
+ - Prompt and rule-file workflows tell the agent what to do. slicekit refuses the step when the agent does not do it.
102
+ - Spec-only tools write the spec and stop. slicekit traces each requirement to its tests, commits, pull requests and releases, and checks the spec again on each turn and in CI.
103
+ - With no workflow, the agent's own report is the record. With slicekit the record is the state files and commits that its CLI writes, and the verdict files that the reviewer agent writes and the CLI checks and commits.
104
+
105
+ ## Docs
106
+
107
+ - [The user guide](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/guide/README.md) explains the stages and has a page for every `slicekit` command, every `/slicekit` slash command and every check rule. A command's page gives its usage, what it reads and writes, its exit codes and an example. A check rule's page says what fails and the failure the rule prevents.
108
+ - [The ten-minute walkthrough](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/walkthrough.md) builds one slice of `examples/backend` from `todo` to `merged`.
109
+ - [The runbook](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/runbook.md) covers releasing the kit, rolling back a bad version on npm and debugging a hook on Windows.
110
+ - [docs/adapters.md](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/adapters.md) describes the contracts for anyone adding a git host, a tracker or an agent tool.
111
+ - [CHANGELOG.md](https://github.com/adityapandya1/agentic-slicekit/blob/main/CHANGELOG.md) lists what each version changed.
112
+
113
+ <details>
114
+ <summary>Status: preview</summary>
9
115
 
10
116
  Phases 1 to 5 work. Phases 1 and 2 are intake, specify, the gap scan, plan, the build from red
11
117
  tests to green, the review loop, the independent review and `/slicekit build --parallel`. Phase 3
@@ -17,24 +123,18 @@ cannot judge, commits to the session journal must be signed, the state change af
17
123
  up as a pull request, and declined should-haves can go to Jira. Phase 5 is `release` (the release
18
124
  record of a phase), `ops` (the triage of a symptom), `audit` (the claims of the spec and the
19
125
  runbook against the code), observability steps in CI, and two more examples, `examples/fullstack`
20
- and `examples/data`. [CHANGELOG.md](https://github.com/adityapandya1/agentic-slicekit/blob/main/CHANGELOG.md) lists what each
21
- version changed.
126
+ and `examples/data`.
22
127
 
23
128
  The kit is on npm as a preview from 0.1.1. Versions from 0.3.0 are published from CI, each with a
24
129
  provenance attestation; the versions before it carry none. It needs Node 22 or later and git, and
25
- it has no dependencies of its own. In your project:
26
-
27
- ```sh
28
- npm install --save-dev slicekit
29
- npx slicekit init --shape backend --name <your-project>
30
- ```
130
+ it has no dependencies of its own.
31
131
 
32
132
  Each change to the kit ships as the next 0.x version, and a 0.x version may change how a command
33
133
  works. After an upgrade, `npx slicekit update` shows what would change in each of the kit's files,
34
134
  and `npx slicekit update --yes` writes the changes.
35
135
 
36
- The walkthrough below runs from a clone instead, because it copies files only the repository
37
- holds (`examples/backend` and `examples/walkthrough`):
136
+ The walkthrough runs from a clone instead of an install, because it copies files only the
137
+ repository holds (`examples/backend` and `examples/walkthrough`):
38
138
 
39
139
  ```sh
40
140
  git clone https://github.com/adityapandya1/agentic-slicekit
@@ -42,198 +142,10 @@ cd agentic-slicekit
42
142
  node bin/slicekit.js --version
43
143
  ```
44
144
 
45
- The last line prints the version the clone carries.
46
-
47
- `docs/spec/00-overview.md` says what the kit is and why, `docs/decisions.md` holds every choice
48
- made so far, and `BUILD.md` shows the order the kit is built in. The kit is built with itself.
49
-
50
- ## Walkthrough
51
-
52
- This takes about ten minutes. It builds the one slice of `examples/backend`, P1/S-01 "Greet a name",
53
- from `todo` to `merged`: red tests, green code, a review round, an independent review, green CI and
54
- the merge.
55
-
56
- In your own project you type two commands into Claude Code, `/slicekit build` and
57
- `/slicekit review`, and the kit's agents write the tests, the code and the verdicts. (Each command
58
- also has a file of its own, so `/slicekit-build` and `/slicekit-review` work too.) Here each step
59
- is the command line that those two commands run, and the files the agents would write are copied
60
- in from `examples/walkthrough`. A local bare repository stands in for GitHub's copy of the project,
61
- and two fixture directories stand in for its pull requests and issues. So the walkthrough needs no
62
- account, no agent and no network.
63
-
64
- Run it from the root of your clone, in bash. On Windows, use Git Bash. The kit's own test runs these
65
- blocks as written, in order, in one shell.
66
-
67
- git needs a name and an email set (`git config --global user.name` and `user.email`), since the kit
68
- makes commits. If your git signs commits, it signs these too, and may ask for your key at each of
69
- them. To skip that for this run, run `export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false`
70
- first.
71
-
72
- ### 1. A project to build in
73
-
74
- `KIT` is your clone. On Windows, `pwd -W` gives a path that Node can read; elsewhere it fails and
75
- `pwd` is used. `WORK` is a new temporary directory for everything else.
76
-
77
- ```sh
78
- KIT="$(pwd -W 2>/dev/null || pwd)"
79
- WORK="$(mktemp -d)"
80
- cp -R examples/backend "$WORK/greeting"
81
- git init -q --bare "$WORK/origin.git"
82
- mkdir "$WORK/githost" "$WORK/tracker"
83
- export SLICEKIT_GITHOST_FIXTURE="$WORK/githost"
84
- export SLICEKIT_TRACKER_FIXTURE="$WORK/tracker"
85
- ```
86
-
87
- With `SLICEKIT_GITHOST_FIXTURE` set, the kit keeps pull requests as files in that directory instead
88
- of calling `gh`. `SLICEKIT_TRACKER_FIXTURE` does the same for issues.
89
-
90
- ### 2. Add the kit to the project
91
-
92
- These are the steps in `examples/backend/README.md`. `init` adds the hooks, the Claude Code
93
- commands and the rest of the docs layout. `--cli` tells the hooks how to run the kit from your
94
- clone. The path inside it is quoted, so a clone under a folder with a space in its name still works.
95
-
96
- ```sh
97
- cd "$WORK/greeting"
98
- git init -q -b main
99
- git remote add origin "$WORK/origin.git"
100
- node "$KIT/bin/slicekit.js" init --shape backend --cli "node \"$KIT/bin/slicekit.js\""
101
- node "$KIT/bin/slicekit.js" status --write
102
- ```
103
-
104
- The kit's git hook refuses a commit on `main` unless `ALLOW_PROTECTED_COMMIT=1` is set. This first
105
- commit is the one time it is needed. On Windows, git may print warnings that LF will be replaced by
106
- CRLF; they are harmless.
107
-
108
- ```sh
109
- git add -A
110
- ALLOW_PROTECTED_COMMIT=1 git commit -q -m "chore: slicekit init"
111
- git push -q -u origin main
112
- ```
113
-
114
- ### 3. Pick the slice and start it
115
-
116
- From here to step 6, the steps are what `/slicekit build` runs. `build next` prints the next slice
117
- that is ready to build. `build start` makes its worktree and branch, and pushes the branch.
118
-
119
- ```sh
120
- node "$KIT/bin/slicekit.js" build next
121
- node "$KIT/bin/slicekit.js" build start P1/S-01
122
- WT=.worktrees/P1-S-01
123
- ```
124
-
125
- ### 4. Red tests, then green code
126
-
127
- In `/slicekit build` the developer agent writes the tests first. `build red` runs them, refuses
128
- them unless they fail, and commits them. From then on the tests are frozen: a later commit that
129
- changes them is refused.
130
-
131
- ```sh
132
- mkdir -p "$WT/test"
133
- cp "$KIT/examples/walkthrough/test/greet.test.js" "$KIT/examples/walkthrough/test/greet-empty.test.js" "$WT/test/"
134
- node "$KIT/bin/slicekit.js" build red P1/S-01 --tests test/greet.test.js,test/greet-empty.test.js --worktree "$WT"
135
- ```
136
-
137
- Then the developer agent writes the code. `build commit --require-green` commits it only when every
138
- test passes.
145
+ </details>
139
146
 
140
- ```sh
141
- mkdir -p "$WT/src"
142
- cp "$KIT/examples/walkthrough/src/greet.js" "$WT/src/"
143
- node "$KIT/bin/slicekit.js" build commit P1/S-01 --message "feat(P1/S-01): greet a name" --require-green --worktree "$WT"
144
- ```
145
-
146
- ### 5. The draft pull request and a review round
147
-
148
- `build pr` runs the tests and `slicekit check`, pushes, and opens a draft pull request. It builds
149
- the body from the slice file and from the notes that the developer agent reported. The last line it
150
- prints is `verdict <path>`, the file the reviewer writes its verdict to.
151
-
152
- ```sh
153
- node "$KIT/bin/slicekit.js" build pr P1/S-01 --notes "$KIT/examples/walkthrough/notes.json" --worktree "$WT" | tee "$WORK/pr.txt"
154
- VERDICT="$(sed -n 's/^verdict //p' "$WORK/pr.txt")"
155
- ```
156
-
157
- In `/slicekit build` the reviewer agent writes the verdict now. The copy here is an `APPROVE` with
158
- no findings. Its `Head:` line names the commit it reviewed, here the worktree's head. `build verdict`
159
- checks it, commits it to the branch and prints the next step, `ci`.
160
-
161
- ```sh
162
- sed "s/^Head: .*/Head: $(git -C "$WT" log -1 --format=%H)/" "$KIT/examples/walkthrough/P1-S-01-r1.md" > "$VERDICT"
163
- node "$KIT/bin/slicekit.js" build verdict P1/S-01 "$VERDICT" --worktree "$WT"
164
- ```
165
-
166
- ### 6. Green CI
167
-
168
- On GitHub, CI reports on each push by itself. Here `host.js ci` records a green run on the pull
169
- request's head. `build finish` waits for CI and, on green, records `ci-green` and pushes that
170
- record. It then prints `ready: waiting for an independent review`: a second session must review the
171
- slice before the merge. The push made a new head, so CI reports again.
172
-
173
- ```sh
174
- node "$KIT/examples/walkthrough/host.js" ci 1 success
175
- node "$KIT/bin/slicekit.js" build finish P1/S-01 --worktree "$WT"
176
- node "$KIT/examples/walkthrough/host.js" ci 1 success
177
- ```
178
-
179
- ### 7. The independent review
180
-
181
- This is what `/slicekit review 1` runs, in a new Claude Code session. `review start` checks out the
182
- pull request's head in a fresh worktree, `.worktrees/review-P1-S-01`, and prints the slice, the
183
- worktree, the round and the verdict path.
184
-
185
- ```sh
186
- node "$KIT/bin/slicekit.js" review start 1 | tee "$WORK/review.txt"
187
- VERDICT="$(sed -n 's/^verdict //p' "$WORK/review.txt")"
188
- ```
189
-
190
- The independent reviewer's verdict is round 2, also an `APPROVE`. `build verdict --independent`
191
- commits it in the review worktree and pushes it. CI reports on that new head. It still prints
192
- `rounds: 1 of 2`: round 2 counts all of the slice's verdicts, while `rounds` counts only the two
193
- review rounds inside `/slicekit build`, and the independent review uses neither of them.
194
-
195
- ```sh
196
- sed "s/^Head: .*/Head: $(git -C .worktrees/review-P1-S-01 log -1 --format=%H)/" "$KIT/examples/walkthrough/P1-S-01i-r2.md" > "$VERDICT"
197
- node "$KIT/bin/slicekit.js" build verdict P1/S-01 "$VERDICT" --independent --worktree .worktrees/review-P1-S-01
198
- node "$KIT/examples/walkthrough/host.js" ci 1 success
199
- ```
200
-
201
- `build finish` now prints `ready`: CI is green and the independent verdict is on this head.
202
-
203
- ```sh
204
- node "$KIT/bin/slicekit.js" build finish P1/S-01 --worktree .worktrees/review-P1-S-01
205
- ```
206
-
207
- ### 8. The merge
208
-
209
- A human merges. On GitHub you press Merge; here `host.js merge` makes the same merge in the bare
210
- repository. The merge happened on the remote, and the slice's state is kept in files on `main`, so
211
- pull `main` first. Then `status --sync` reads the merge from the git host and moves the slice to
212
- `merged`.
213
-
214
- ```sh
215
- node "$KIT/examples/walkthrough/host.js" merge 1
216
- git pull -q --ff-only
217
- node "$KIT/bin/slicekit.js" status --sync
218
- node "$KIT/bin/slicekit.js" status
219
- ```
220
-
221
- The last line reads `P1/S-01 merged PR #1 Greet a name`.
222
-
223
- ### 9. Clean up
224
-
225
- Unset the two fixture variables. Otherwise a later slicekit command in this shell writes pull
226
- requests and issues into a deleted folder, instead of calling `gh`. The same line unsets the
227
- `GIT_CONFIG_*` variables, in case you set them above to turn signing off. Then go back to your
228
- clone and remove `$WORK`, which holds the project, the bare repository and the fixture directories.
229
-
230
- ```sh
231
- unset SLICEKIT_GITHOST_FIXTURE SLICEKIT_TRACKER_FIXTURE GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0
232
- cd "$KIT"
233
- rm -rf "$WORK"
234
- ```
235
-
236
- ## Scope
147
+ <details>
148
+ <summary>Scope</summary>
237
149
 
238
150
  The kit does not parse source code. Its graph is built from its own IDs and from git by
239
151
  `slicekit graph`: requirements, decisions, slices, tests, commits, pull requests and releases. It is
@@ -247,16 +159,10 @@ pip install graphifyy && graphify install
247
159
 
248
160
  Then one Claude Code session runs both: `/graphify .` for the code graph, then `/slicekit build`.
249
161
 
250
- ## User guide
162
+ </details>
251
163
 
252
- The [user guide](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/guide/README.md)
253
- explains the stages and has a page for every `slicekit` command, every `/slicekit` slash command
254
- and every check rule. A command's page gives its usage, what it reads and writes, its exit codes
255
- and an example. A check rule's page says what fails and the failure the rule prevents.
256
- [docs/adapters.md](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/adapters.md)
257
- describes the contracts for anyone adding a git host, a tracker or an agent tool.
258
-
259
- ## How the hooks find slicekit
164
+ <details>
165
+ <summary>How the hooks find slicekit</summary>
260
166
 
261
167
  `slicekit init` writes the hook command as `node node_modules/slicekit/bin/slicekit.js` when the
262
168
  repository has a local install, and `slicekit` otherwise, which needs slicekit on PATH. When neither
@@ -269,4 +175,15 @@ instead, pass `--cli` to init, as the walkthrough does:
269
175
  hooks run from the session's working directory, so a worktree outside the repository tree needs an
270
176
  absolute path in `cli` or a global install.
271
177
 
178
+ </details>
179
+
180
+ <details>
181
+ <summary>Built with itself</summary>
182
+
183
+ The kit is built with itself: each change to its code goes through a slice, with tests written first,
184
+ a review and green CI; its plans and version changes go through pull requests of their own. `docs/spec/00-overview.md` says what the kit is and why, `docs/decisions.md` holds every
185
+ choice made so far, and `BUILD.md` shows the order the kit is built in.
186
+
187
+ </details>
188
+
272
189
  License: MIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicekit",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Spec-driven agentic workflow kit",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/brief.js ADDED
@@ -0,0 +1,221 @@
1
+ // `slicekit brief` (REQ-2.15, D-99): the interview that writes `<docsRoot>/brief/<slug>.md` from a
2
+ // person's answers alone, one topic per question in the order of REQ-2.15. An answer the person
3
+ // cannot give is listed under `## Open questions` by its topic's name and nowhere else. The brief
4
+ // holds only the seven headings, the answers and those topic names; `brief done` commits it.
5
+ //
6
+ // The session lives in this worktree's own git directory, `<git-dir>/slicekit/brief.json`, as
7
+ // {slug, startedAt, specFiles, pending, asked}: never in the work tree, so `git add -A` cannot stage
8
+ // it, and one per worktree. pre-edit denies the file, so an agent cannot rewrite it by hand.
9
+ import crypto from 'node:crypto';
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import { listFiles } from './fs.js';
13
+ import { commitPaths, currentBranch, git } from './git.js';
14
+ import { kitPaths } from './paths.js';
15
+
16
+ // `code` 1: refused. `code` 2: bad input.
17
+ export class BriefError extends Error {
18
+ constructor(code, message) {
19
+ super(message);
20
+ this.name = 'BriefError';
21
+ this.code = code;
22
+ }
23
+ }
24
+
25
+ // The topics of REQ-2.15 in their order, each with the heading its answers go under. An answer to
26
+ // `unknowns` is an open question the person named; it goes under `## Open questions`.
27
+ export const SECTIONS = [
28
+ { topic: 'problem', heading: 'Problem and who has it' },
29
+ { topic: 'today', heading: 'What they do today' },
30
+ { topic: 'use-cases', heading: 'Use cases' },
31
+ { topic: 'out-of-scope', heading: 'Out of scope' },
32
+ { topic: 'success-measures', heading: 'Success measures' },
33
+ { topic: 'constraints', heading: 'Constraints' },
34
+ { topic: 'unknowns', heading: 'Open questions' },
35
+ ];
36
+ export const BRIEF_HEADINGS = SECTIONS.map((s) => s.heading);
37
+ const TOPICS = SECTIONS.map((s) => s.topic);
38
+ const OPEN = 'Open questions';
39
+ const SLUG = /^[a-z0-9][a-z0-9-]{0,59}$/;
40
+
41
+ const posix = (p) => p.split(path.sep).join('/');
42
+ const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
43
+
44
+ // The `## ` headings of a brief that are missing from `text`, in the order of REQ-2.15.
45
+ export function missingHeadings(text) {
46
+ const present = new Set(text.split(/\r?\n/).map((l) => l.trim()));
47
+ return BRIEF_HEADINGS.filter((h) => !present.has(`## ${h}`));
48
+ }
49
+
50
+ // The topic headings of a brief whose section holds no line and whose name is not listed under
51
+ // `## Open questions`, in the order of REQ-2.15: each such topic was neither answered nor left open.
52
+ export function unlistedEmptySections(text) {
53
+ const under = {};
54
+ let at = null;
55
+ for (const raw of text.split(/\r?\n/)) {
56
+ const line = raw.trim();
57
+ if (line.startsWith('## ')) {
58
+ at = line.slice(3).trim();
59
+ under[at] ??= [];
60
+ } else if (at !== null && line !== '') under[at].push(line);
61
+ }
62
+ const open = new Set((under[OPEN] ?? []).map((l) => l.toLowerCase()));
63
+ return BRIEF_HEADINGS.filter((h) => h !== OPEN && Object.hasOwn(under, h) && under[h].length === 0 && !open.has(h.toLowerCase()));
64
+ }
65
+
66
+ function onWorkBranch(root, cfg, what) {
67
+ const branch = currentBranch(root);
68
+ if (branch === null || branch === cfg.defaultBranch || cfg.protectedBranches.includes(branch)) {
69
+ throw new BriefError(1, `${what} on a work branch; run slicekit branch spec <slug>`);
70
+ }
71
+ }
72
+
73
+ function sessionPath(root) {
74
+ return path.join(git(root, ['rev-parse', '--path-format=absolute', '--git-dir']), 'slicekit', 'brief.json');
75
+ }
76
+
77
+ function readSession(root) {
78
+ const file = sessionPath(root);
79
+ if (!fs.existsSync(file)) return null;
80
+ try {
81
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
82
+ } catch {
83
+ throw new BriefError(1, `${posix(file)} is not valid JSON; delete it to start the brief again`);
84
+ }
85
+ }
86
+
87
+ function writeSession(root, session) {
88
+ const file = sessionPath(root);
89
+ fs.mkdirSync(path.dirname(file), { recursive: true });
90
+ fs.writeFileSync(file, `${JSON.stringify(session, null, 2)}\n`);
91
+ }
92
+
93
+ const needSession = (root) => {
94
+ const session = readSession(root);
95
+ if (!session) throw new BriefError(1, 'no brief is under way; run slicekit brief start <slug> first');
96
+ return session;
97
+ };
98
+
99
+ // Each file under the spec directory, root-relative and POSIX, with the SHA-256 of its bytes.
100
+ function specFilesNow(root, cfg) {
101
+ const dir = kitPaths(root, cfg).spec;
102
+ if (!fs.existsSync(dir)) return {};
103
+ const base = posix(path.relative(root, dir));
104
+ return Object.fromEntries(listFiles(dir).map((f) => [`${base}/${f}`, sha256(fs.readFileSync(path.join(dir, f)))]));
105
+ }
106
+
107
+ const briefFile = (root, cfg, slug) => path.join(kitPaths(root, cfg).brief, `${slug}.md`);
108
+ const briefRel = (root, cfg, slug) => posix(path.relative(root, briefFile(root, cfg, slug)));
109
+
110
+ // The brief as the session holds it, rebuilt from every recorded answer: each heading, then the
111
+ // answers under it in the order given. A topic with only unknown answers is its heading name under
112
+ // Open questions, once; a topic with a real answer is answered and not listed as open.
113
+ export function renderBrief(asked) {
114
+ const under = Object.fromEntries(BRIEF_HEADINGS.map((h) => [h, []]));
115
+ const answered = new Set(asked.filter((a) => a.answer !== null).map((a) => a.topic));
116
+ const open = new Set();
117
+ for (const a of asked) {
118
+ const { heading } = SECTIONS.find((s) => s.topic === a.topic);
119
+ if (a.answer !== null) under[heading].push(a.answer);
120
+ else if (a.topic !== 'unknowns' && !answered.has(a.topic)) open.add(heading);
121
+ }
122
+ under[OPEN].unshift(...open);
123
+ return `${BRIEF_HEADINGS.map((h) => [`## ${h}`, ...under[h]].join('\n\n')).join('\n\n')}\n`;
124
+ }
125
+
126
+ // Opens the session for `slug` and writes the brief with its seven empty headings.
127
+ export function start(root, cfg, { slug, now = new Date() } = {}) {
128
+ if (typeof slug !== 'string' || !SLUG.test(slug)) {
129
+ throw new BriefError(2, `slug '${slug}' must be lowercase letters, digits and dashes, at most 60, not starting with a dash`);
130
+ }
131
+ onWorkBranch(root, cfg, 'the brief');
132
+ const existing = readSession(root);
133
+ if (existing) {
134
+ throw new BriefError(1, `the brief ${existing.slug} is under way; run slicekit brief done, or delete ${posix(sessionPath(root))} to drop it`);
135
+ }
136
+ const file = briefFile(root, cfg, slug);
137
+ const rel = briefRel(root, cfg, slug);
138
+ if (fs.existsSync(file)) throw new BriefError(1, `${rel} exists; choose another slug`);
139
+ fs.mkdirSync(path.dirname(file), { recursive: true });
140
+ fs.writeFileSync(file, renderBrief([]));
141
+ writeSession(root, { slug, startedAt: now.toISOString(), specFiles: specFilesNow(root, cfg), pending: null, asked: [] });
142
+ return { file: rel };
143
+ }
144
+
145
+ function oneLine(field, value) {
146
+ if (typeof value !== 'string' || value.trim() === '') throw new BriefError(2, `${field} is required`);
147
+ if (/[\r\n]/.test(value)) throw new BriefError(2, `${field} must be one line`);
148
+ return value.trim();
149
+ }
150
+
151
+ // Holds `question` on `topic` as the one waiting for an answer; returns its number. The topic is the
152
+ // one last asked (a follow-up) or the next in the order of REQ-2.15.
153
+ export function ask(root, cfg, { topic, question } = {}) {
154
+ if (!TOPICS.includes(topic)) throw new BriefError(2, `topic must be one of ${TOPICS.join(', ')}, not '${topic}'`);
155
+ const q = oneLine('question', question);
156
+ const session = needSession(root);
157
+ if (session.pending) throw new BriefError(1, `answer the last question first: "${session.pending.question}" has no answer`);
158
+ const last = session.asked.length === 0 ? -1 : TOPICS.indexOf(session.asked.at(-1).topic);
159
+ const at = TOPICS.indexOf(topic);
160
+ if (at !== last && at !== last + 1) {
161
+ throw new BriefError(1, `topic ${topic} is out of order; ask ${last === -1 ? TOPICS[0] : `${TOPICS[last]} or ${TOPICS[last + 1] ?? 'nothing more'}`}`);
162
+ }
163
+ session.pending = { topic, question: q };
164
+ writeSession(root, session);
165
+ return { n: session.asked.length + 1 };
166
+ }
167
+
168
+ // Writes the waiting question's answer into the brief, then clears it: the brief first, so the
169
+ // answer is recorded before the next question can be asked. `unknown` lists the topic under Open
170
+ // questions instead, and is refused on a topic the person already answered.
171
+ export function answer(root, cfg, { answer: text, unknown = false } = {}) {
172
+ const session = needSession(root);
173
+ if (!session.pending) throw new BriefError(1, 'no question is waiting for an answer');
174
+ let value = null;
175
+ if (unknown) {
176
+ const { topic } = session.pending;
177
+ if (topic !== 'unknowns' && session.asked.some((a) => a.topic === topic && a.answer !== null)) {
178
+ throw new BriefError(1, `topic ${topic} is already answered, so it cannot be open; record what the person says to this question with slicekit brief answer --answer <a>`);
179
+ }
180
+ } else {
181
+ if (typeof text !== 'string' || text.trim() === '') throw new BriefError(2, 'answer is required');
182
+ value = text.trim().replace(/\r\n/g, '\n');
183
+ if (value.split('\n').some((l) => /^#{1,6}\s/.test(l.trim()))) throw new BriefError(2, 'an answer holds no heading line');
184
+ }
185
+ const asked = [...session.asked, { ...session.pending, answer: value }];
186
+ fs.mkdirSync(kitPaths(root, cfg).brief, { recursive: true });
187
+ fs.writeFileSync(briefFile(root, cfg, session.slug), renderBrief(asked));
188
+ writeSession(root, { ...session, pending: null, asked });
189
+ return { file: briefRel(root, cfg, session.slug) };
190
+ }
191
+
192
+ // Ends the brief: refuses while a question waits, on the default or a protected branch, while a
193
+ // topic was never asked and answered (an unknown answer counts), while a heading is missing from the brief, or when a file under the spec directory appeared, changed or
194
+ // went since `brief start`; otherwise commits the brief alone.
195
+ export function done(root, cfg) {
196
+ const session = needSession(root);
197
+ if (session.pending) throw new BriefError(1, `answer the last question first: "${session.pending.question}" has no answer`);
198
+ onWorkBranch(root, cfg, 'the brief');
199
+ const answered = new Set(session.asked.map((a) => a.topic));
200
+ const unasked = TOPICS.find((t) => !answered.has(t));
201
+ if (unasked) {
202
+ throw new BriefError(1, `topic ${unasked} was never asked and answered; run slicekit brief ask --topic ${unasked} --question <q>, then slicekit brief answer`);
203
+ }
204
+ const file = briefFile(root, cfg, session.slug);
205
+ const rel = briefRel(root, cfg, session.slug);
206
+ if (!fs.existsSync(file)) throw new BriefError(1, `${rel} is missing; run slicekit brief start ${session.slug} again`);
207
+ const missing = missingHeadings(fs.readFileSync(file, 'utf8'));
208
+ if (missing.length > 0) throw new BriefError(1, `${rel} has no section ## ${missing[0]}`);
209
+ const known = session.specFiles ?? {};
210
+ const now = specFilesNow(root, cfg);
211
+ for (const [f, digest] of Object.entries(now)) {
212
+ if (!Object.hasOwn(known, f)) throw new BriefError(1, `the brief writes no spec text; remove ${f}`);
213
+ if (known[f] !== digest) throw new BriefError(1, `the brief writes no spec text; ${f} changed during the interview`);
214
+ }
215
+ for (const f of Object.keys(known)) {
216
+ if (!Object.hasOwn(now, f)) throw new BriefError(1, `the brief writes no spec text; ${f} was removed during the interview`);
217
+ }
218
+ const commit = commitPaths(root, [rel], `docs(brief): ${session.slug}`);
219
+ fs.rmSync(sessionPath(root), { force: true });
220
+ return { file: rel, commit };
221
+ }
@@ -13,7 +13,7 @@ export const ratchet = false;
13
13
 
14
14
  const CONFIG = '.slicekit/config.json';
15
15
  const FILES = ['decisions', 'gaps', 'stack', 'platform', 'observability', 'runbook', 'build', 'workflow'];
16
- const DIRS = ['kit', 'state', 'baselines', 'docs', 'intake', 'spec', 'contracts', 'phases', 'releases', 'githooks', 'claude'];
16
+ const DIRS = ['kit', 'state', 'baselines', 'docs', 'brief', 'intake', 'spec', 'contracts', 'phases', 'releases', 'githooks', 'claude'];
17
17
 
18
18
  const toPosix = (p) => p.split(path.sep).join('/');
19
19
 
@@ -0,0 +1,90 @@
1
+ // `slicekit brief start | ask | answer | done` (REQ-2.15, D-99): the brief interview. `start` prints
2
+ // the brief's path, `ask` prints `question <n>`, `answer` the brief's path, and `done` the path it
3
+ // committed and then, as its last line, the intake command that takes the brief as its source.
4
+ import { parseArgs } from 'node:util';
5
+ import { ConfigError, loadConfig } from '../config.js';
6
+ import { BriefError, answer, ask, done, start } from '../brief.js';
7
+ import { GitError } from '../git.js';
8
+
9
+ const SUBCOMMANDS = ['start', 'ask', 'answer', 'done'];
10
+ const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
11
+ const USAGE =
12
+ 'brief start <slug>\n' +
13
+ ' brief ask --topic <problem|today|use-cases|out-of-scope|success-measures|constraints|unknowns> --question <q>\n' +
14
+ ' brief answer (--answer <a> | --unknown)\n' +
15
+ ' brief done';
16
+
17
+ const SPEC = {
18
+ start: { options: [], positionals: 1 },
19
+ ask: { options: ['topic', 'question'], positionals: 0 },
20
+ answer: { options: ['answer', 'unknown'], positionals: 0 },
21
+ done: { options: [], positionals: 0 },
22
+ };
23
+ const OPTIONS = { topic: { type: 'string' }, question: { type: 'string' }, answer: { type: 'string' }, unknown: { type: 'boolean' } };
24
+
25
+ const usage = (io, why) => {
26
+ io.stderr(`${why ? `slicekit: ${why}\n` : ''}usage: slicekit ${USAGE}\n`);
27
+ return 2;
28
+ };
29
+
30
+ // SLICEKIT_NOW is for tests only: it fixes the instant the session records as its start.
31
+ function clock(io) {
32
+ const fixed = (io.env ?? process.env).SLICEKIT_NOW;
33
+ if (fixed === undefined || fixed === '') return new Date();
34
+ const now = new Date(fixed);
35
+ return ISO.test(fixed) && !Number.isNaN(now.getTime()) ? now : null;
36
+ }
37
+
38
+ function perform(sub, root, cfg, values, rest, now, io) {
39
+ if (sub === 'start') {
40
+ io.stdout(`${start(root, cfg, { slug: rest[0], now }).file}\n`);
41
+ } else if (sub === 'ask') {
42
+ io.stdout(`question ${ask(root, cfg, { topic: values.topic, question: values.question }).n}\n`);
43
+ } else if (sub === 'answer') {
44
+ io.stdout(`${answer(root, cfg, { answer: values.answer, unknown: Boolean(values.unknown) }).file}\n`);
45
+ } else {
46
+ const { file } = done(root, cfg);
47
+ io.stdout(`${file}\n/slicekit intake ${file}\n`);
48
+ }
49
+ }
50
+
51
+ async function run(args, io) {
52
+ let values;
53
+ let positionals;
54
+ try {
55
+ ({ values, positionals } = parseArgs({ args, options: OPTIONS, allowPositionals: true }));
56
+ } catch (e) {
57
+ return usage(io, e.message);
58
+ }
59
+ const [sub, ...rest] = positionals;
60
+ const spec = Object.hasOwn(SPEC, sub ?? '') ? SPEC[sub] : undefined;
61
+ if (!spec || rest.length !== spec.positionals) return usage(io);
62
+ const extra = Object.keys(values).filter((k) => !spec.options.includes(k));
63
+ if (extra.length > 0) return usage(io, `${sub} does not take --${extra[0]}`);
64
+ if (sub === 'ask' && (values.topic === undefined || values.question === undefined)) return usage(io);
65
+ if (sub === 'answer' && (values.answer === undefined) === !values.unknown) return usage(io, 'answer takes one of --answer and --unknown');
66
+ const now = clock(io);
67
+ if (now === null) return usage(io, `SLICEKIT_NOW '${(io.env ?? process.env).SLICEKIT_NOW}' is not an ISO time`);
68
+ const root = io.cwd;
69
+ try {
70
+ const cfg = loadConfig(root);
71
+ perform(sub, root, cfg, values, rest, now, io);
72
+ return 0;
73
+ } catch (e) {
74
+ if (e instanceof BriefError) {
75
+ io.stderr(`slicekit: ${e.message}\n`);
76
+ return e.code;
77
+ }
78
+ if (e instanceof ConfigError) {
79
+ io.stderr(`slicekit: ${e.message}\n`);
80
+ return 2;
81
+ }
82
+ if (e instanceof GitError) {
83
+ io.stderr(`slicekit: ${e.message}\n`);
84
+ return 1;
85
+ }
86
+ throw e;
87
+ }
88
+ }
89
+
90
+ export const briefCommand = { run, usage: USAGE, subcommands: SUBCOMMANDS };
package/src/cli/index.js CHANGED
@@ -7,6 +7,7 @@ import { findSliceFiles, parseSliceFile } from '../slicefile.js';
7
7
  import { auditCommand } from './audit.js';
8
8
  import { baselineCommand } from './baseline.js';
9
9
  import { branchCommand } from './branch.js';
10
+ import { briefCommand } from './brief.js';
10
11
  import { buildCommand } from './build.js';
11
12
  import { checkCommand } from './check.js';
12
13
  import { ciCommand } from './ci.js';
@@ -43,6 +44,7 @@ export const COMMANDS = {
43
44
  audit: auditCommand,
44
45
  baseline: baselineCommand,
45
46
  branch: branchCommand,
47
+ brief: briefCommand,
46
48
  build: buildCommand,
47
49
  check: checkCommand,
48
50
  ci: ciCommand,
package/src/cli/stage.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // `slicekit stage require <stage>` (REQ-1.7): a command's gate. Exit 0 with `ready: <stage>` when
2
2
  // the stage and every one before it are complete; exit 1 with the first blocker and the command
3
- // that clears it. Pending rows that do not block follow, one per line.
3
+ // that clears it. Pending rows that do not block follow, one per line. `brief` (D-99) is the optional
4
+ // stage before intake: judged alone, and no stage of STAGES reads it.
4
5
  import { ConfigError, loadConfig } from '../config.js';
5
- import { STAGES, StageError, programStage } from '../stage.js';
6
+ import { STAGES, StageError, briefStage, programStage } from '../stage.js';
6
7
 
7
- const USAGE = 'stage require <stage>';
8
+ const USAGE = 'stage require <stage|brief>';
8
9
 
9
10
  async function run(args, io) {
10
11
  const [sub, stage, ...rest] = args;
@@ -12,8 +13,8 @@ async function run(args, io) {
12
13
  io.stderr(`usage: slicekit ${USAGE}\n`);
13
14
  return 2;
14
15
  }
15
- if (!STAGES.includes(stage)) {
16
- io.stderr(`slicekit: unknown stage '${stage}'; one of ${STAGES.join(', ')}\n`);
16
+ if (stage !== 'brief' && !STAGES.includes(stage)) {
17
+ io.stderr(`slicekit: unknown stage '${stage}'; one of ${STAGES.join(', ')}, or brief\n`);
17
18
  return 2;
18
19
  }
19
20
  let cfg;
@@ -24,7 +25,7 @@ async function run(args, io) {
24
25
  io.stderr(`slicekit: ${e.message}\n`);
25
26
  return 2;
26
27
  }
27
- const now = programStage(io.cwd, cfg, { upTo: stage });
28
+ const now = stage === 'brief' ? briefStage(io.cwd, cfg) : programStage(io.cwd, cfg, { upTo: stage });
28
29
  const pending = (now.pending ?? []).map((line) => `${line}\n`).join('');
29
30
  if (!now.complete) {
30
31
  io.stderr(`${new StageError(now.stage, now.blockers[0]).message}\n${pending}`);
@@ -6,7 +6,7 @@
6
6
  // `.slicekit/baselines/`, `.slicekit/.subagent-*`, `.slicekit/.retry-*` or `.slicekit/.agents-*` segment
7
7
  // under any root, or a `slicekit/subagent-*` marker, `slicekit/retry-*` retry state or `slicekit/agents-*`
8
8
  // started-agents record in a git directory (`.git` or `*.git`), or the `slicekit/interview.json` intake
9
- // session in one (a linked worktree's included)
9
+ // session or the `slicekit/brief.json` brief session in one (a linked worktree's included)
10
10
  // — always; (4) a path that matches a pattern of the root's `agents.denyPaths` (REQ-3.13) — always;
11
11
  // then, only while
12
12
  // the file's own root has an active slice (a `slice/*` branch with a state file) in `tests-red` or
@@ -86,9 +86,9 @@ function kitOwned(abs) {
86
86
  }) || segs.some((s, i) => i > 0 && (segs[i - 1] === '.git' || segs[i - 1].endsWith('.git'))
87
87
  && s === 'slicekit' && (segs[i + 1] === 'clone-id'
88
88
  || ['subagent-', 'retry-', 'agents-'].some((p) => segs[i + 1]?.startsWith(p))))
89
- // The intake interview session, also in a linked worktree's own git directory
90
- // (`<.git>/worktrees/<name>/slicekit/interview.json`).
91
- || segs.some((s, i) => s === 'slicekit' && segs[i + 1] === 'interview.json'
89
+ // The intake interview and brief sessions, also in a linked worktree's own git directory
90
+ // (`<.git>/worktrees/<name>/slicekit/interview.json`, `.../slicekit/brief.json`).
91
+ || segs.some((s, i) => s === 'slicekit' && (segs[i + 1] === 'interview.json' || segs[i + 1] === 'brief.json')
92
92
  && segs.slice(0, i).some((p) => p === '.git' || p.endsWith('.git')));
93
93
  }
94
94
 
package/src/init.js CHANGED
@@ -137,6 +137,7 @@ const TEMPLATE_DEST = {
137
137
  'spec/00-overview.md': (p) => path.join(p.spec, '00-overview.md'),
138
138
  'spec/gaps.md': (p) => p.gaps,
139
139
  'spec/stack.md': (p) => p.stack,
140
+ 'brief/.keep': (p) => path.join(p.brief, '.keep'),
140
141
  'intake/.keep': (p) => path.join(p.intake, '.keep'),
141
142
  'spec/contracts/.keep': (p) => path.join(p.contracts, '.keep'),
142
143
  'phases/.keep': (p) => path.join(p.phases, '.keep'),
@@ -16,7 +16,7 @@ import { kitPaths } from './paths.js';
16
16
  import { findSliceFiles } from './slicefile.js';
17
17
  import { reqBlocks } from './stage.js';
18
18
 
19
- export const PROCEDURES = ['intake', 'specify', 'gaps', 'plan', 'build', 'review', 'release', 'ops', 'audit'];
19
+ export const PROCEDURES = ['brief', 'intake','specify', 'gaps', 'plan', 'build', 'review', 'release', 'ops', 'audit'];
20
20
  export const TEMPLATES = fileURLToPath(new URL('../templates/instructions', import.meta.url));
21
21
 
22
22
  const KIT_SKILL = fileURLToPath(new URL('../templates/claude-code/skills/slicekit-writing/SKILL.md', import.meta.url));
package/src/paths.js CHANGED
@@ -14,6 +14,7 @@ export function kitPaths(root, cfg) {
14
14
  reports: path.join(kit, 'reports'),
15
15
  workspace: path.join(kit, 'workspace.json'),
16
16
  docs,
17
+ brief: path.join(docs, 'brief'),
17
18
  intake: path.join(docs, 'intake'),
18
19
  decisions: path.join(docs, 'decisions.md'),
19
20
  spec,
package/src/stage.js CHANGED
@@ -6,6 +6,7 @@ import { GitError, assertRef, git, hasCommits, isRepo } from './git.js';
6
6
  import { readDecisions } from './decisions.js';
7
7
  import { blankCodeSpans, headings, lines, prose, refs, tables } from './markdown.js';
8
8
  import { re } from './ids.js';
9
+ import { missingHeadings, unlistedEmptySections } from './brief.js';
9
10
  import { kitPaths } from './paths.js';
10
11
  import { findSliceFiles, parseSliceFile } from './slicefile.js';
11
12
  import { listSlices } from './state/index.js';
@@ -14,6 +15,7 @@ export const STAGES = ['intake', 'clarify', 'specify', 'spec-review', 'gap-scan'
14
15
 
15
16
  // The slash command that does each stage, named in the refusal.
16
17
  const COMMANDS = {
18
+ brief: 'brief',
17
19
  intake: 'intake',
18
20
  clarify: 'intake (clarify)',
19
21
  specify: 'specify',
@@ -27,6 +29,7 @@ const COMMANDS = {
27
29
 
28
30
  // The display name of each stage, used in messages; the ids stay in code.
29
31
  const LABELS = {
32
+ brief: 'brief',
30
33
  intake: 'intake',
31
34
  clarify: 'clarify',
32
35
  specify: 'specify',
@@ -298,6 +301,30 @@ function release(root, cfg) {
298
301
  .map((id) => `${id} has no releases/${id}.md`);
299
302
  }
300
303
 
304
+ // The optional brief stage (REQ-1.7, D-99), outside STAGES: no stage after it reads the brief folder.
305
+ // Complete when there is a brief and every file under `<docsRoot>/brief/` other than `.keep` has
306
+ // every section of REQ-2.15, each topic section filled or listed under Open questions; the blockers
307
+ // name each file and its first missing section, or else its first empty section not listed there.
308
+ export function briefStage(root, cfg) {
309
+ const dir = kitPaths(root, cfg).brief;
310
+ const files = exists(dir) ? listFiles(dir).filter((f) => path.posix.basename(f) !== '.keep') : [];
311
+ if (files.length === 0) return { stage: 'brief', complete: false, blockers: [`no brief under ${rel(root, dir)}/`] };
312
+ const blockers = [];
313
+ for (const f of files.sort()) {
314
+ const text = readText(path.join(dir, f));
315
+ const missing = missingHeadings(text);
316
+ if (missing.length > 0) {
317
+ blockers.push(`${rel(root, path.join(dir, f))} has no section ## ${missing[0]}`);
318
+ continue;
319
+ }
320
+ const empty = unlistedEmptySections(text);
321
+ if (empty.length > 0) {
322
+ blockers.push(`${rel(root, path.join(dir, f))} has an empty section ## ${empty[0]} that is not listed under ## Open questions`);
323
+ }
324
+ }
325
+ return { stage: 'brief', complete: blockers.length === 0, blockers };
326
+ }
327
+
301
328
  const CHECKS = { intake, clarify, specify, 'spec-review': specReview, 'gap-scan': gapScan, stack, plan, build, release };
302
329
 
303
330
  // Evaluates the stages in order and stops after `upTo` (default: all), so later stages cost nothing.
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Interview a person about an idea, one topic per question, and write the brief /slicekit intake takes as its source.
3
+ argument-hint: "[<slug>]"
4
+ ---
5
+ Run `{{cli}} instructions --command brief $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
6
+
7
+ Writing rules: `.claude/skills/slicekit-writing/SKILL.md`.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Run a slicekit command: intake, specify, gaps, plan, build, review, release, ops or audit. /slicekit <command> [args]"
2
+ description: "Run a slicekit command: brief, intake, specify, gaps, plan, build, review, release, ops or audit. /slicekit <command> [args]"
3
3
  argument-hint: "<command> [args]"
4
4
  ---
5
5
  Run `{{cli}} instructions --command $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
@@ -8,6 +8,15 @@
8
8
  "data"
9
9
  ]
10
10
  },
11
+ {
12
+ "src": "commands/slicekit-brief.md",
13
+ "dest": ".claude/commands/slicekit-brief.md",
14
+ "shapes": [
15
+ "backend",
16
+ "fullstack",
17
+ "data"
18
+ ]
19
+ },
11
20
  {
12
21
  "src": "commands/slicekit-intake.md",
13
22
  "dest": ".claude/commands/slicekit-intake.md",
File without changes
@@ -0,0 +1,60 @@
1
+ # /slicekit brief
2
+
3
+ You interview a person who has an idea but no requirement document, and write their brief from their answers alone. You end with `<docsRoot>/brief/<slug>.md` committed on the spec branch, and the intake command that takes it as its source. The slug is: {{args}}
4
+
5
+ `<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`.
6
+
7
+ This command writes no spec text and no file under `<docsRoot>/spec/`. Writing the spec is `/slicekit specify`, after `/slicekit intake`. Every git step is in the CLI: the branch and the brief commit are `{{cli}}` subcommands. You run no git command yourself.
8
+
9
+ When a `{{cli}}` step exits with a code other than 0, stop and show the person its message. Do not work around it.
10
+
11
+ ## 1. The slug and the work branch
12
+
13
+ When the slug above is `(none)`, ask the person for a short name for the idea, and make the slug from it: lower-cased, each run of characters other than `a-z0-9` turned into one `-`, dashes trimmed from both ends, at most 60 characters. Then run:
14
+
15
+ `{{cli}} branch spec <slug>`
16
+
17
+ ## 2. Start the brief
18
+
19
+ `{{cli}} brief start <slug>`
20
+
21
+ It prints the brief's path, for example `docs/brief/payments-retry.md`. Call it `<brief>` below. It holds the seven headings and nothing else yet.
22
+
23
+ ## 3. The interview
24
+
25
+ Ask one question at a time, one topic per question, in this order:
26
+
27
+ 1. `problem`: the problem and who has it
28
+ 2. `today`: what they do today
29
+ 3. `use-cases`: the use cases
30
+ 4. `out-of-scope`: what is out of scope
31
+ 5. `success-measures`: the success measures
32
+ 6. `constraints`: the constraints
33
+ 7. `unknowns`: what they know they do not know
34
+
35
+ A topic may take more than one question; do not mix two topics in one question, and do not go back to an earlier topic. Ask in the person's terms. Offer no answer of your own: the brief holds only what the person says.
36
+
37
+ For each question:
38
+
39
+ 1. Before you ask it, run `{{cli}} brief ask --topic=<topic> --question=<the question>`. It prints `question <n>`.
40
+ 2. Ask the person, and wait for the answer.
41
+ 3. Record the answer in the person's own words with `{{cli}} brief answer --answer=<the answer>`. It writes the answer under the topic's heading in `<brief>`.
42
+ - When the person says they do not know, or cannot answer, run `{{cli}} brief answer --unknown`. It lists the topic under `## Open questions` and writes nothing under the topic's heading. Never write a guess in its place. A later answer on the same topic takes the topic off `## Open questions`. Once a topic has an answer, `--unknown` on it is refused: record what the person says with `--answer=<the answer>`.
43
+ 4. Ask the next question only after the answer step exits 0. The CLI refuses a new question while the last one has no answer, and a topic out of the order above.
44
+
45
+ Always write a value as `--option=<text>`, with the `=`, so a value that starts with `-` is read as text and not as an option.
46
+
47
+ ## 4. Finish
48
+
49
+ `{{cli}} brief done`
50
+
51
+ It commits `<brief>` alone on the spec branch. Its last line is the next command, for example `/slicekit intake docs/brief/payments-retry.md`. Show the person that line as it is: `/slicekit intake` takes the brief as its source like any other document.
52
+
53
+ `{{cli}} brief done` refuses when no brief is under way, while a question has no answer, on the default branch or a protected branch, while a topic was never asked and answered (an answer given with `--unknown` counts as answered), naming the first such topic, when `<brief>` is missing, while a heading is missing from `<brief>`, or when a file under `<docsRoot>/spec/` appeared, changed or was removed during the interview. Show the person the message. Never delete or edit a spec file to get past it.
54
+
55
+ ## You never
56
+
57
+ - Write or edit a file under `<docsRoot>/spec/`.
58
+ - Edit `<brief>` by hand, or add text the person did not give. Answers are written only by `{{cli}} brief answer`.
59
+ - Edit the brief session file.
60
+ - Run a git or gh command. The CLI does every git step.
@@ -4,6 +4,8 @@ You bring a requirement document into the project and interview the human about
4
4
 
5
5
  `<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`.
6
6
 
7
+ A brief at `<docsRoot>/brief/<slug>.md`, written by `/slicekit brief`, is a valid source: snapshot it in step 2 as you would any other document.
8
+
7
9
  This command writes no file under `<docsRoot>/spec/`. Writing the spec is `/slicekit specify`, later. Every git step is in the CLI: the branch, the snapshot commit and the answers commit are all `{{cli}}` subcommands. You run no git command yourself.
8
10
 
9
11
  When a `{{cli}}` step exits with a code other than 0, stop and show the human its message. Do not work around it.