@evolvehq/docflow 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: agent-wave
3
+ description: Orchestrate a wave of parallel agents over the plan/todo queue in a documentation-led repo — asks how many agents, the budget (items/waves, with hours as a soft cap), and whether to checkpoint after each wave or run continuously. Spawns isolated worktree subagents, assigns one queue item each, collects results. Use when the user says "spawn a wave of agents", "run the queue in parallel", "fan out the work", "agent wave", or invokes /agent-wave.
4
+ ---
5
+
6
+ # agent-wave
7
+
8
+ Drive the implementation queue with parallel subagents, in waves.
9
+
10
+ ## Honest scope (read first)
11
+
12
+ In-session subagents are bounded by **this session**, not by wall-clock
13
+ hours. So this skill measures budget reliably in **items and waves**,
14
+ with hours as a *soft cap* (stop starting new waves once elapsed time
15
+ passes it). For a true multi-hour unsupervised fleet that outlives a
16
+ session, use remote agents or a scheduled run of
17
+ `_agent/prompts/autonomous.md` (`/schedule`) instead — this skill points
18
+ you there rather than pretending to be it.
19
+
20
+ ## Step 0 — Preconditions and context
21
+
22
+ 1. Confirm the repo is bootstrapped with a `plan/` queue and that
23
+ `_agent/prompts/autonomous.md` exists (a real verify gate is
24
+ required — see the **bootstrap** skill, Q8).
25
+ 2. Read `CONVENTIONS.md` for the **multi-agent mode** and **integration
26
+ model**.
27
+ - **Mode 1 (single agent):** refuse. Parallel agents in one checkout
28
+ clobber each other. Tell the user to re-bootstrap as mode 2/3, or
29
+ run the autonomous prompt sequentially instead.
30
+ - **Mode 2 (shared checkout):** allowed but warn — file contention is
31
+ real; LOCKS must be respected and wave width kept low.
32
+ - **Mode 3 (worktrees):** the intended mode. Each subagent works in
33
+ its own isolated worktree.
34
+
35
+ ## Step 1 — Ask the wave parameters (one at a time, recommend)
36
+
37
+ 1. **Wave width N** — how many agents per wave.
38
+ *Recommended: min(queue depth, 3)* — modest, keeps review tractable.
39
+ 2. **Budget** — total items (or waves) to attempt this run.
40
+ *Recommended: one wave, then reassess.* Optionally a soft hours cap.
41
+ 3. **Supervision** — **checkpoint** (review after each wave, then
42
+ continue) or **continuous** (run wave after wave until budget/queue
43
+ exhausted).
44
+ *Recommended: checkpoint* for the first run on a repo.
45
+
46
+ Cross-check: **continuous + direct-to-main** is risky — nothing gates
47
+ each merge. If the repo is direct-to-main, recommend either switching
48
+ this run to checkpoint, or that the repo move to PR-based so CI gates
49
+ every merge.
50
+
51
+ ## Step 2 — Plan the wave
52
+
53
+ - Read `plan/todo/`; take the lowest-numbered N items with no unmet
54
+ dependencies. Two agents must never get the same item or items that
55
+ edit the same files — partition by item and, in mode 2, by LOCKS.
56
+ - Record the assignment in `_agent/IN_FLIGHT.md` (mode 3) so the wave is
57
+ visible.
58
+
59
+ ## Step 3 — Spawn the wave
60
+
61
+ Spawn N subagents in parallel, each in an isolated worktree
62
+ (`isolation: worktree`). Brief each with: its assigned queue item, the
63
+ instruction to follow `_agent/prompts/autonomous.md` end-to-end for that
64
+ one item (orient → implement → verify → integrate per the repo's model →
65
+ ship), and to report back a structured result (item, pass/fail, HEAD or
66
+ PR link, any blocker).
67
+
68
+ ## Step 4 — Collect and checkpoint
69
+
70
+ When the wave returns, summarise: shipped, failed, blocked, with links.
71
+ Update `_agent/IN_FLIGHT.md` (remove finished rows). Then:
72
+ - **Checkpoint mode:** present the summary and ask whether to launch the
73
+ next wave.
74
+ - **Continuous mode:** launch the next wave with the next N items,
75
+ unless a stop condition fired.
76
+
77
+ ## Stop conditions
78
+
79
+ Stop the run (do not start another wave) when any holds:
80
+ - Queue empty, or budget (items/waves) reached, or soft hours cap passed.
81
+ - Failure rate exceeds a sane threshold (e.g. >½ the wave failed) —
82
+ something systemic is wrong; surface it.
83
+ - Repeated merge conflicts on the same files — the queue partition is
84
+ wrong; re-plan.
85
+ - An item's ADR is not `Accepted`, or its acceptance criteria are
86
+ ambiguous.
87
+
88
+ On stop, leave every worktree in a committed or cleanly-abandoned state,
89
+ record the outcome in the WORKLOG, and report.
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: audit
3
+ description: Audit a documentation-led repo against its own conventions — contiguous ADR numbering, INDEX sync, plan/ coverage, required sections, status validity, cross-reference resolution, language mandate, and ADR-privacy leaks into user-visible code. Reports a punch list and offers to fix the mechanical issues. Use when the user says "audit the ADRs", "lint the conventions", "check repo consistency", "are the ADRs in sync", or invokes /audit.
4
+ ---
5
+
6
+ # audit
7
+
8
+ Check a documentation-led repo against the conventions it declares.
9
+ This is the enforcement `AGENTS.md` cannot guarantee on its own.
10
+
11
+ ## Step 0 — Preconditions and context
12
+
13
+ 1. Confirm the repo is bootstrapped.
14
+ 2. Read `CONVENTIONS.md` to learn what to enforce: ADR shape and
15
+ cutoff, status lifecycle, integration model, multi-agent mode,
16
+ language mandate, optional artefacts present (GLOSSARY, domains/),
17
+ and any Q10 domain hard rules.
18
+
19
+ ## Step 1 — Run the checks (read-only)
20
+
21
+ Report each as PASS / FAIL / N/A with specifics (file + line where
22
+ relevant):
23
+
24
+ 1. **Numbering.** ADR filenames contiguous, zero-padded, no gaps, no
25
+ duplicates. Split repos: capability below cutoff, technology at/above.
26
+ 2. **INDEX sync.** Every ADR appears in `INDEX.md`; every INDEX row has
27
+ a matching file; metadata fields (status, title, date) agree.
28
+ 3. **Plan coverage.** Every `Accepted` ADR has a `plan/todo/` item;
29
+ every `Implemented` ADR has a `plan/done/` entry. Flag orphans both
30
+ ways.
31
+ 4. **Section completeness.** Each ADR has the required sections in the
32
+ order its shape mandates. Acceptance criteria are numbered.
33
+ 5. **Status validity.** Every `status:` is in the declared lifecycle.
34
+ `Superseded` ADRs name a successor in `superseded-by:`; the successor
35
+ names them in `supersedes:` (symmetry).
36
+ 6. **Revision/Approvals.** Revision History present; Approvals populated
37
+ for ADRs at `Accepted` or beyond.
38
+ 7. **Cross-references.** Relative `adr/NNNN-*.md` links resolve to real
39
+ files. Glossary anchors (if used) resolve.
40
+ 8. **Language mandate.** If set, spot-check user-facing docs for the
41
+ required spellings.
42
+ 9. **ADR-privacy leaks.** Grep source / product directories for ADR
43
+ identifiers in user-visible strings — patterns like `ADR 0042`,
44
+ `adr-0042`, `see ADR`, ADR titles — in UI copy, API responses,
45
+ error messages, customer-facing logs, public docs, release notes.
46
+ Report each suspect; this rule is easy to violate by reflex.
47
+ 10. **Coordination hygiene.** `_agent/LOCKS.md` has no stale claims
48
+ (mode 2); `_agent/IN_FLIGHT.md` rows match live worktrees (mode 3).
49
+
50
+ ## Step 2 — Report
51
+
52
+ Lead with a one-line verdict (clean / N issues). Then the punch list,
53
+ grouped by severity: **blocking** (privacy leaks, status/lifecycle
54
+ violations, broken cross-refs), **drift** (INDEX out of sync, missing
55
+ plan files), **hygiene** (stale locks, formatting).
56
+
57
+ ## Step 3 — Offer fixes
58
+
59
+ Offer to fix the **mechanical** issues automatically: regenerate
60
+ `INDEX.md`, create missing `plan/todo` stubs, clear stale locks, fix
61
+ broken relative links. **Do not** auto-edit ADR content, rewrite
62
+ acceptance criteria, or remove suspected privacy leaks without the
63
+ user confirming each — those need judgement. Commit fixes as
64
+ `fix(adr): ...` / `docs: ...` with a `Rationale:` footer where an ADR
65
+ is touched.
@@ -0,0 +1,347 @@
1
+ ---
2
+ name: bootstrap
3
+ description: Scaffold or retrofit documentation-led conventions (AGENTS.md, CLAUDE.md, CONVENTIONS.md, ADR catalogue, plan/ queue, _agent/ coordination) into a repo. Use when the user asks to "set up conventions", "bootstrap ADRs", "scaffold the documentation-led layout", "add AGENTS.md and a plan queue", or invokes /bootstrap. Works on fresh repos and existing ones — preserves existing content and merges rather than overwrites.
4
+ ---
5
+
6
+ # bootstrap
7
+
8
+ You are installing (or retrofitting) a documentation-led convention set
9
+ in the current repo. The end state is a repo that can be driven by
10
+ both humans and coding agents off a small set of canonical files. Carry
11
+ over the *mechanism* described here — nothing about any other project.
12
+
13
+ ## Step 1 — Detect the situation
14
+
15
+ Inspect the repo before asking anything.
16
+
17
+ - **Fresh repo** (no source, no docs): you are scaffolding from zero.
18
+ - **Existing repo**: you are retrofitting.
19
+ - Read any current `README.md`, `CONTRIBUTING.md`, `AGENTS.md`,
20
+ `CLAUDE.md`, `docs/`, `adr/`, `.github/` before proposing changes.
21
+ - Preserve existing content. Merge, don't overwrite. If existing
22
+ conventions conflict with the ones below, surface the conflict in
23
+ your assessment summary.
24
+ - If ADRs already exist in another format, propose a migration plan
25
+ (renumber, keep, translate) rather than creating a parallel tree.
26
+
27
+ State which situation applies in one line before asking the assessment
28
+ questions.
29
+
30
+ ## Step 2 — Target layout
31
+
32
+ ```
33
+ <repo>/
34
+ AGENTS.md # hard rules for coding agents — entry point
35
+ CLAUDE.md # one-liner: @AGENTS.md
36
+ README.md # human-facing project summary (preserve if exists)
37
+ CONVENTIONS.md # authoring rules: ADRs, naming, status, audit, git
38
+ INDEX.md # generated table of all ADRs
39
+ GLOSSARY.md # shared terms (optional — see Q7)
40
+ adr/
41
+ 0000-template.md # capability-ADR template (always)
42
+ NNNN-template.md # technology-ADR template (only if split — see Q2)
43
+ NNNN-<kebab-slug>.md # one ADR per decision, contiguous numbering
44
+ domains/<slug>/README.md # optional (see Q7)
45
+ plan/
46
+ README.md
47
+ todo/NNNN-<slug>.md
48
+ done/<YYYY-MM-DD>-<slug>.md
49
+ _agent/
50
+ ROLES.md # named agents and what each owns
51
+ LOCKS.md # file-claim ledger
52
+ WORKLOG.md # append-only ship log
53
+ CURRENT_FOCUS.md # slim live snapshot
54
+ HANDOFF.md # fresh-agent entry point
55
+ prompts/autonomous.md # only if a verify gate exists (see Q8)
56
+ ```
57
+
58
+ ## Step 3 — Conventions to install
59
+
60
+ 1. **ADRs are the source of truth.** One decision per ADR. Splits become
61
+ new ADRs that supersede; never expand scope inside an existing one.
62
+ 2. **Up to two ADR shapes:**
63
+ - **Capability ADR** (what the system must do). Section order:
64
+ metadata → Context → Capability statement → User stories / scenarios
65
+ → Acceptance criteria → Out of scope → Open questions → References →
66
+ Revision History → Approvals.
67
+ - **Technology ADR** (how it's built). Section order:
68
+ metadata → Context → Decision → Rationale → Consequences →
69
+ Acceptance criteria → Out of scope → Open questions → References →
70
+ Revision History → Approvals. Rationale must name alternatives
71
+ considered and give specific rejection reasons (not "simpler" /
72
+ "more idiomatic").
73
+ 3. **Status lifecycle:** `Proposed → Accepted → Implemented →
74
+ (Superseded | Deprecated)`. Terminal states reachable from any prior
75
+ state. Status drives plan-folder placement: `Accepted` →
76
+ `plan/todo/`, `Implemented` → `plan/done/`.
77
+ 4. **Filenames:** `adr/NNNN-kebab-slug.md`, zero-padded 4 digits,
78
+ contiguous, no reserved gaps. Cross-references use relative paths.
79
+ 5. **Acceptance criteria are testable and numbered.** Tests map back to
80
+ them where practical.
81
+ 6. **Audit discipline.** Substantive ADR changes append a Revision
82
+ History row. Editorial changes (typos, formatting, link fixes) are
83
+ excluded but flagged `editorial` in the commit message. Approvals
84
+ table populates when an ADR is Accepted and updates on each later
85
+ substantive revision.
86
+ 7. **INDEX.md is regenerated** from ADR metadata after any ADR change.
87
+ Treat as derived, not hand-edited.
88
+ 8. **`plan/` is the work queue.** `git mv plan/todo/X plan/done/<date>-X`
89
+ is the completion event; the moved file gets a footer naming the HEAD
90
+ SHA (and deploy artefact id if applicable). Owning ADR(s) advance
91
+ `Accepted → Implemented` on the same commit.
92
+ 9. **Multi-agent coordination.** Before editing, an agent appends a row
93
+ to `_agent/LOCKS.md` (`<agent-id> | <path> | <ISO-8601 timestamp>`)
94
+ and removes it on commit. On commit, append one line to
95
+ `_agent/WORKLOG.md`. `CURRENT_FOCUS.md` is the live snapshot; if it
96
+ disagrees with git, git wins and `CURRENT_FOCUS.md` is corrected.
97
+ 10. **Git contract.** Conventional Commits. Mandatory `Rationale:`
98
+ footer on commits touching an ADR. Signed commits unless the user
99
+ opts out. No `Co-Authored-By` trailer for agent work unless the user
100
+ asks for one.
101
+ 11. **AGENTS.md is the hard-rules entry point;** **CLAUDE.md** is the
102
+ one-liner `@AGENTS.md` so the Claude Code CLI picks it up.
103
+ 12. **ADRs are internal artefacts — never user-visible.** ADR numbers,
104
+ ADR titles, and the existence of the ADR catalogue must NEVER
105
+ appear in product code paths that reach a user: UI strings, API
106
+ response bodies, error messages, log lines emitted to customers,
107
+ public documentation, release notes, marketing copy, or support
108
+ communications. ADRs are for builders, not users. References ARE
109
+ allowed in: code comments (`// see adr/0042-foo.md`), commit
110
+ messages, PR descriptions, internal docs, `AGENTS.md`,
111
+ `CONVENTIONS.md`, `INDEX.md`, and the `plan/` queue. When in
112
+ doubt, ask whether a non-builder would ever see this string — if
113
+ yes, the ADR reference comes out.
114
+
115
+ ## Step 4 — Assessment (10 questions)
116
+
117
+ **Ask the questions one at a time, not in a batch.** For each question,
118
+ state a **recommended** option (label it "Recommended") with one short
119
+ sentence on why; the user picks it, picks an alternative, or types a
120
+ custom answer. Wait for the answer before moving to the next question.
121
+
122
+ If the host CLI exposes a structured single-select question tool (e.g.
123
+ Claude Code's `AskUserQuestion`), use it and mark the recommended
124
+ option with the literal "(Recommended)" suffix in its label. Otherwise
125
+ ask in plain text, listing options as A/B/C and naming the recommended
126
+ one.
127
+
128
+ After all 10 answers are in, summarise the resulting plan in 5–10
129
+ lines and ask for sign-off before writing any files.
130
+
131
+ 1. **Project identity.** Name, one-line description, doc language
132
+ (en-GB / en-US / other), and — if existing repo — what current files
133
+ (README, CONTRIBUTING, docs/, adr/, etc.) must be preserved or
134
+ merged. *No recommendation — project-specific.*
135
+ 2. **ADR shape.** Single shape, or capability-vs-technology split?
136
+ **Recommended: single shape** — start simple, split later if
137
+ long-lived product requirements clearly outlive their
138
+ implementations.
139
+ 3. **Status lifecycle.** Full `Proposed → Accepted → Implemented →
140
+ (Superseded | Deprecated)`, or shorter (drop `Implemented`)?
141
+ **Recommended: full lifecycle** — the `Implemented` rung is cheap
142
+ and gives a clear "what's shipped" signal.
143
+ 4. **Plan folder + integration model.** Two sub-answers. **Ask Q5
144
+ before Q4b — the integration recommendation depends on the
145
+ multi-agent mode chosen in Q5.** When asking sequentially, the
146
+ order is: Q1 → Q2 → Q3 → Q4a → Q5 → Q4b → Q6 → Q7 → Q8 → Q9 → Q10.
147
+
148
+ **Q4a — Plan folder.** Use `plan/todo/` + `plan/done/`, or skip it
149
+ because work is tracked elsewhere?
150
+ **Recommended: use it** — the queue is what makes the convention
151
+ set actionable for agents.
152
+
153
+ **Q4b — Integration model.** *Skip if Q4a = skip.* Two options:
154
+ - **Direct-to-main, fast-forward only.**
155
+ *Recommended if Q5 = mode 1 (single agent).* Local verify gate
156
+ runs before push. Completion event: "fast-forwarded to main +
157
+ remote push succeeded". Autonomous prompt uses
158
+ `git merge --ff-only`. Trunk-based development; no PRs.
159
+ - **PR-based, required CI green.**
160
+ *Recommended if Q5 = mode 2 or 3 (multi-agent).* Verify gate
161
+ runs in CI on the PR. Completion event: "PR merged to main + CI
162
+ green". Autonomous prompt opens a draft PR, waits for green,
163
+ marks ready, merges. Ask the user for merge strategy
164
+ (squash / merge / rebase — default: squash for clean history,
165
+ rebase if per-commit identity matters).
166
+ 5. **Multi-agent setup.** Pick one — the three options have different
167
+ coordination-file shapes, and switching later is not free:
168
+ - **(Recommended) Single agent.** `default-agent` in ROLES.
169
+ LOCKS skipped. WORKLOG / CURRENT_FOCUS as standard single-file
170
+ snapshots. Right for small projects and the "one human + one
171
+ agent" case.
172
+ - **Multi-agent, shared checkout.** Named agents in ROLES. LOCKS
173
+ ON as a filesystem mutex (prevents simultaneous writes to the
174
+ same file). WORKLOG append-on-commit, single file.
175
+ CURRENT_FOCUS as the single in-flight snapshot. Right when
176
+ several agents serialise through one working tree.
177
+ - **Multi-agent, separate worktrees / PR branches.** Named agents
178
+ in ROLES. LOCKS *advisory only* — GitHub draft PRs / branch
179
+ assignment are the real lock; pick one signal, not two.
180
+ `_agent/WORKLOG.md` gets `merge=union` via `.gitattributes` so
181
+ concurrent appends concatenate instead of conflicting (or split
182
+ to `_agent/worklog/<agent-id>.md` if agent set is fixed).
183
+ `_agent/CURRENT_FOCUS.md` becomes local-only (added to
184
+ `.gitignore`); a committed `_agent/IN_FLIGHT.md` dashboard
185
+ aggregates per-worktree state.
186
+
187
+ Note: option 2 → option 3 is not a free upgrade later; it means
188
+ splitting WORKLOG (or adding the merge driver) and rethinking
189
+ CURRENT_FOCUS. Choose deliberately.
190
+ 6. **Git contract.** Confirm or override each — Conventional Commits;
191
+ mandatory `Rationale:` footer on ADR-touching commits; signed
192
+ commits; ADR-revision tags `adr-NNNN-rN`; whether agent commits
193
+ carry a `Co-Authored-By` trailer. **Recommended: Conventional
194
+ Commits ON, `Rationale:` footer ON, signed commits ON, ADR-revision
195
+ tags OFF, `Co-Authored-By` trailer OFF.**
196
+ 7. **Optional artefacts.** Which now vs. defer: `GLOSSARY.md`,
197
+ `domains/<slug>/README.md` groupings, technology-ADR template?
198
+ **Recommended: defer all three** — add when scale demands
199
+ (terminology drift, >20 ADRs, or technology decisions splitting
200
+ from product decisions).
201
+ 8. **Verify gate.** What command(s) decide a change is shippable
202
+ (`npm test`, CI workflow, deploy + smoke, manual)? *No
203
+ recommendation — project-specific.* If the user has no real gate,
204
+ the skill will refuse to write `_agent/prompts/autonomous.md`.
205
+ 9. **Existing-content conflicts** (existing repos only). Any
206
+ conventions already in place (commit format, branch policy, ADR
207
+ style, status names) the new layout must defer to or merge with?
208
+ *No recommendation — project-specific.* Skip this question on a
209
+ fresh repo.
210
+ 10. **Domain-specific hard rules to bake in.** Any project-specific
211
+ constraints to enforce in `AGENTS.md` / `CONVENTIONS.md` from day
212
+ one — e.g. vendor-naming restriction, regulated-evidence posture
213
+ (attribution, retention, e-signatures), language mandate,
214
+ mandatory user-story personas, separated audit streams?
215
+ **Recommended: none from day one** — add later when a concrete
216
+ requirement appears; pre-emptive hard rules accumulate as cruft.
217
+
218
+ ## Step 4.5 — Cross-check before sign-off
219
+
220
+ After all answers are in, scan for contradictions before writing the
221
+ plan summary. Surface each, take the correction, then proceed:
222
+
223
+ - **Q5 mode 3 (worktrees) + Q4b direct-to-main.** Unusual: each
224
+ worktree would have to rebase onto main before fast-forwarding.
225
+ Ask the user to confirm or switch to PR-based — PR-based is the
226
+ near-universal fit for worktree work.
227
+ - **Q4a plan-folder skipped + Q8 autonomous prompt expected.** The
228
+ autonomous prompt walks `plan/todo/`; with no plan folder it has
229
+ nothing to drive. Do not write the autonomous prompt.
230
+ - **Q8 has no real verify gate + Q4b PR-based with required CI.**
231
+ "Required CI green" needs a CI gate. Confirm what the CI actually
232
+ runs, or downgrade the completion event.
233
+ - **Q2 single ADR shape + Q7 technology-ADR template requested.**
234
+ Contradiction — pick one.
235
+
236
+ ## Step 5 — Output sequence (after sign-off)
237
+
238
+ Templates live in this skill's `templates/` directory. Read each
239
+ template, fill its placeholders from the assessment answers, then
240
+ write it into the repo.
241
+
242
+ 1. `CONVENTIONS.md` — from `templates/CONVENTIONS.md`. Spec other files
243
+ reference.
244
+ 2. `AGENTS.md` — from `templates/AGENTS.md`.
245
+ 3. `CLAUDE.md` — from `templates/CLAUDE.md` (single line `@AGENTS.md`).
246
+ 4. `adr/0000-template.md` — from `templates/adr-capability.md`.
247
+ 5. `adr/NNNN-template.md` — from `templates/adr-technology.md`, only if
248
+ Q2 said split. `NNNN` is the number where capability ADRs end
249
+ (project-defined, e.g. 0091; default 0100 if unspecified).
250
+ 6. `plan/README.md` — from `templates/plan-README.md`. Create empty
251
+ `plan/todo/.gitkeep` and `plan/done/.gitkeep`.
252
+ 7. `_agent/ROLES.md` — from `templates/_agent-ROLES.md`. Mode 1
253
+ keeps the `default-agent` block; modes 2 and 3 expand to named
254
+ agents per Q5.
255
+ 8. `_agent/LOCKS.md` — from `templates/_agent-LOCKS.md`. **Skip in
256
+ mode 1.** **Mode 3** writes it with an advisory header noting
257
+ PRs are the authoritative lock.
258
+ 9. `_agent/WORKLOG.md` — from `templates/_agent-WORKLOG.md`. In
259
+ **mode 3**, also write a `.gitattributes` entry:
260
+ `_agent/WORKLOG.md merge=union`.
261
+ 10. `_agent/CURRENT_FOCUS.md` — from
262
+ `templates/_agent-CURRENT_FOCUS.md`. In **mode 3**, add
263
+ `_agent/CURRENT_FOCUS.md` to `.gitignore` (the file stays
264
+ local-only per worktree) and write
265
+ `_agent/IN_FLIGHT.md` from `templates/_agent-IN_FLIGHT.md` as
266
+ the committed cross-worktree dashboard.
267
+ 11. `_agent/HANDOFF.md` — from `templates/_agent-HANDOFF.md`.
268
+ 12. Stub `INDEX.md` — header + empty table.
269
+ 13. `_agent/prompts/autonomous.md` — from
270
+ `templates/_agent-prompts-autonomous.md`, **only** if Q8 confirmed a
271
+ verify gate. Keep the integration block matching Q4b: the
272
+ **direct-to-main** variant (`git merge --ff-only` then push) or
273
+ the **PR-based** variant (`gh pr create --draft` → wait for CI →
274
+ mark ready → `gh pr merge`). Drop the unused variant.
275
+
276
+ Commit each file (or logical group) with a Conventional Commit message;
277
+ no `Co-Authored-By` trailer unless Q6 asked for one.
278
+
279
+ For an existing repo, prefer Edit over Write where files exist, and
280
+ call out every merge decision in the commit message.
281
+
282
+ ## Step 6 — Offer backfill (existing repos only)
283
+
284
+ Once the scaffolding commit has landed, **offer to backfill** the ADR
285
+ catalogue, the plan folder, and `CONVENTIONS.md` from the existing
286
+ code and git history. Skip this step entirely on a fresh repo.
287
+
288
+ Phrase the offer like this:
289
+
290
+ > The scaffolding is in. Want me to backfill ADRs, plan/done entries,
291
+ > and CONVENTIONS additions from the existing code and commit history?
292
+ > I'll propose drafts; you approve in batches before anything lands.
293
+
294
+ If the user accepts, run the backfill in four passes. Each pass
295
+ produces drafts the user reviews before they are committed.
296
+
297
+ 1. **Scan inputs (read-only).**
298
+ - `git log --oneline --reverse main` (or the default branch) — the
299
+ decision and shipped-work trail.
300
+ - Major modules / packages / top-level source directories — the
301
+ surface of what exists.
302
+ - Any existing docs (`README`, `docs/`, design notes, RFCs) — prior
303
+ decision records, even informal ones.
304
+ - `package.json` / `pyproject.toml` / `go.mod` etc. — declared
305
+ dependencies often map to technology decisions.
306
+
307
+ 2. **Propose ADRs.** For each distinguishable decision or capability
308
+ evident from the scan, draft an ADR using the appropriate template.
309
+ - Capabilities (what the system does) → capability ADR, status
310
+ `Implemented` (the code already exists), Revision History row
311
+ citing the commit(s) that introduced the behaviour.
312
+ - Technology choices (framework, persistence, deployment target) →
313
+ technology ADR, status `Accepted` or `Implemented` as appropriate,
314
+ Rationale section reconstructed from commit messages and code
315
+ comments — flag any speculative rationale clearly so the human
316
+ can correct it.
317
+ - Number contiguously from `0001`. Show the user the proposed list
318
+ (number + title + status + one-line scope) before writing files.
319
+
320
+ 3. **Propose plan/done entries.** For each ADR drafted as
321
+ `Implemented`, generate a corresponding `plan/done/<date>-<slug>.md`
322
+ file using the commit date of the implementing commit (or the
323
+ merge commit) as the date prefix. Body: short summary, owning ADR,
324
+ "Shipped at HEAD `<sha>`" footer. Group these into a single
325
+ approval prompt — they are mechanical once the ADRs are agreed.
326
+
327
+ 4. **Propose CONVENTIONS additions.** Identify patterns in the existing
328
+ repo that should be promoted to written conventions: commit-message
329
+ style, branch naming, test layout, file-naming rules, language /
330
+ tooling choices that are de-facto standards. Draft additions to
331
+ `CONVENTIONS.md` (and corresponding bullets in `AGENTS.md` §Hard
332
+ rules if they should be enforced). Show the diff before applying.
333
+
334
+ After each pass, commit the approved drafts with a Conventional Commit
335
+ (`docs(adr): backfill ADRs 0001-00NN from code and history`,
336
+ `docs(plan): backfill plan/done from shipped commits`,
337
+ `docs: backfill conventions from de-facto patterns`). Regenerate
338
+ `INDEX.md` after the ADR pass.
339
+
340
+ **Important guardrails.**
341
+ - The backfill produces *drafts*. Every commit is reviewable; the user
342
+ is the authority on whether an inferred decision is real.
343
+ - If commit history is sparse or unclear, say so and stop — do not
344
+ invent rationale to fill gaps.
345
+ - If the user declines the backfill, the scaffolding is still
346
+ complete; the queue is just empty until the first hand-authored ADR
347
+ lands.
@@ -0,0 +1,157 @@
1
+ # AGENTS.md
2
+
3
+ This file provides guidance to coding agents working in this repository.
4
+
5
+ ## What this repository is
6
+
7
+ <One paragraph. Project purpose, current baseline, what the artefacts in
8
+ this repo represent.>
9
+
10
+ ## Repository structure
11
+
12
+ - `adr/0000-template.md` — canonical ADR template.
13
+ <!-- If technology-ADR split (Q2): also include `adr/NNNN-template.md` for technology ADRs. -->
14
+ - `adr/NNNN-<kebab-slug>.md` — one ADR per decision, contiguous
15
+ numbering, no gaps.
16
+ - `INDEX.md` — table regenerated from every ADR's metadata block.
17
+ - `CONVENTIONS.md` — authoring rules (read before editing anything).
18
+ - `plan/todo/NNNN-<slug>.md` — pending work, lower numbers run first.
19
+ - `plan/done/<YYYY-MM-DD>-<slug>.md` — shipped work, chronological.
20
+ - `_agent/` — multi-agent coordination: `ROLES.md`, `LOCKS.md`,
21
+ `WORKLOG.md`, `CURRENT_FOCUS.md`, `HANDOFF.md`, `prompts/`.
22
+ <!-- If GLOSSARY.md (Q7): also include `GLOSSARY.md` — shared terms. -->
23
+ <!-- If domains/ (Q7): also include `domains/<slug>/README.md`. -->
24
+
25
+ ## Hard rules when editing ADRs
26
+
27
+ These come from `CONVENTIONS.md` and override default behaviour:
28
+
29
+ - **One decision per ADR.** Splits become new ADRs that supersede;
30
+ never expand scope inside an existing one.
31
+ - **Status lifecycle:** `<from Q3>`.
32
+ - **Capability ADR section order:** metadata → Context → Capability
33
+ statement → User stories / scenarios → Acceptance criteria → Out of
34
+ scope → Open questions → References → Revision History → Approvals.
35
+ <!-- If technology-ADR split (Q2): -->
36
+ - **Technology ADR section order:** metadata → Context → Decision →
37
+ Rationale → Consequences → Acceptance criteria → Out of scope → Open
38
+ questions → References → Revision History → Approvals. Rationale must
39
+ name alternatives considered with specific rejection reasons.
40
+ - **Acceptance criteria are testable and numbered.**
41
+ - **ADRs are internal artefacts — never user-visible.** ADR numbers,
42
+ ADR titles, and the existence of the ADR catalogue must NEVER appear
43
+ in any string the product emits to users: UI copy, API response
44
+ bodies, error messages, customer-visible log lines, public
45
+ documentation, release notes, marketing copy, or support
46
+ communications. The catalogue is a builder's tool, not a user-facing
47
+ surface. References ARE allowed in: code comments
48
+ (`// see adr/0042-foo.md`), commit messages, PR descriptions,
49
+ internal docs, `AGENTS.md`, `CONVENTIONS.md`, `INDEX.md`, and the
50
+ `plan/` queue. Rule of thumb: if a non-builder could ever see the
51
+ string, the ADR reference comes out.
52
+ <!-- Insert any Q10 domain-specific hard rules here as additional bullets. -->
53
+
54
+ ## Implementation work
55
+
56
+ - Start from the ADRs. Identify which ADRs a code change implements or
57
+ affects before changing behaviour.
58
+ - If implementation reveals a capability gap or changed decision, update
59
+ the relevant ADR rather than silently diverging.
60
+ - Add or update tests for implemented behaviour. Map tests back to ADR
61
+ acceptance criteria where practical.
62
+ - **Do not leak ADR identifiers into user-visible surfaces.** When
63
+ writing error messages, UI copy, API responses, log lines that ship
64
+ to customers, public docs, or release notes, refer to the behaviour
65
+ by its product-level name — never by ADR number, ADR title, or
66
+ phrases like "per the ADR catalogue". The ADR link belongs in the
67
+ commit message and (optionally) an inline code comment, not in the
68
+ string the user reads.
69
+
70
+ ## Audit trail and revision discipline
71
+
72
+ - Substantive ADR changes append a row to the Revision History table.
73
+ Editorial changes (typos, formatting, link fixes) are excluded but
74
+ flagged `editorial` in the commit message.
75
+ - Approvals table populates when an ADR is Accepted and updates on each
76
+ later substantive revision.
77
+ - Regenerate `INDEX.md` from ADR metadata after any ADR status change
78
+ or new ADR.
79
+
80
+ ## Multi-agent workflow
81
+
82
+ <!-- Mode 1 — single agent (Q5 default). Keep this block. -->
83
+ A single agent owns this repo. The `_agent/` directory tracks live
84
+ state and history; LOCKS discipline is not in use.
85
+
86
+ <!-- Mode 2 — multi-agent, shared checkout. Replace the block above with: -->
87
+ <!--
88
+ Work is partitioned across named agents (see `_agent/ROLES.md`).
89
+ Coordination rules:
90
+ - Before editing a file, claim it in `_agent/LOCKS.md` by appending
91
+ `<agent-id> | <path> | <ISO-8601 timestamp>`. Remove the line on
92
+ commit. LOCKS is a filesystem mutex — it prevents simultaneous
93
+ writes to the same file.
94
+ - Append a one-line entry to `_agent/WORKLOG.md` on every commit.
95
+ - `_agent/CURRENT_FOCUS.md` is the single in-flight snapshot
96
+ (branch, active queue item, blockers, uncommitted work). Update it
97
+ when state changes.
98
+ -->
99
+
100
+ <!-- Mode 3 — multi-agent, separate worktrees / PR branches. Replace
101
+ the block above with: -->
102
+ <!--
103
+ Work is partitioned across named agents (see `_agent/ROLES.md`).
104
+ Each agent works in its own git worktree or PR branch.
105
+ Coordination rules:
106
+ - **GitHub draft PRs / branch assignment are the authoritative lock.**
107
+ `_agent/LOCKS.md` is advisory only — append an intent declaration
108
+ if it helps coordinate before a PR exists; do not rely on it as a
109
+ mutex. The filesystem can't conflict across worktrees, but
110
+ duplicated work and contradictory merges still can.
111
+ - Append a one-line entry to `_agent/WORKLOG.md` on every commit.
112
+ The repo's `.gitattributes` sets `_agent/WORKLOG.md merge=union`
113
+ so concurrent appends concatenate instead of conflicting.
114
+ - `_agent/CURRENT_FOCUS.md` is local-only per worktree (gitignored).
115
+ Update it freely; it never merges.
116
+ - The committed cross-worktree dashboard is `_agent/IN_FLIGHT.md` —
117
+ one row per active worktree (agent, branch, queue item, started).
118
+ Add your row when you start, remove it when the worktree closes.
119
+ -->
120
+
121
+ ## Plan folder
122
+
123
+ - A pending item gets a `plan/todo/NNNN-<slug>.md` file BEFORE work
124
+ starts, naming the owning ADR(s), scope, and exit criteria.
125
+ - The completion event is: `<from Q4 — e.g. merge to main, deploy +
126
+ smoke passes, release tag>`. On completion, `git mv` the file to
127
+ `plan/done/<YYYY-MM-DD>-<slug>.md` with a footer naming the HEAD SHA
128
+ and any artefact id.
129
+ - The owning ADR(s) advance `Accepted → Implemented` on the same
130
+ commit. Regenerate `INDEX.md`.
131
+
132
+ ## Git contract
133
+
134
+ - Commit messages follow **Conventional Commits**.
135
+ - Mandatory `Rationale:` footer on any commit touching an ADR.
136
+ - <Signed commits: yes/no per Q6.>
137
+ - <ADR-revision tags `adr-NNNN-rN`: yes/no per Q6.>
138
+ - <Co-Authored-By trailer: yes/no per Q6 — default no.>
139
+ - Cross-references between ADRs use relative paths (`adr/NNNN-*.md`).
140
+
141
+ <!-- Integration model per Q4b — keep one block. -->
142
+
143
+ <!-- Direct-to-main:
144
+ - **Integration:** direct-to-main, **fast-forward only**. No merge
145
+ commits on `main`. The verify gate (`<command from Q8>`) runs
146
+ locally and must pass before push. Completion event:
147
+ fast-forwarded to `main` + remote push succeeded.
148
+ -->
149
+
150
+ <!-- PR-based:
151
+ - **Integration:** every change ships via a pull request. CI must be
152
+ green before merge — the verify gate (`<command from Q8>`) runs in
153
+ CI on the PR, not (only) locally. Merge strategy:
154
+ <squash | merge | rebase>. Completion event: PR merged to `main`
155
+ with CI green.
156
+ -->
157
+
@@ -0,0 +1 @@
1
+ @AGENTS.md