archgen-skill 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +29 -3
  2. package/bin/archgen.mjs +146 -12
  3. package/lib/block.js +197 -8
  4. package/lib/config.js +96 -0
  5. package/lib/doctor.js +283 -0
  6. package/lib/init.js +130 -27
  7. package/lib/install.js +105 -14
  8. package/lib/migrate.js +88 -0
  9. package/lib/migrations/001-stamp-provenance.mjs +77 -0
  10. package/lib/migrations/index.mjs +170 -0
  11. package/lib/restore.js +239 -0
  12. package/lib/store.js +161 -0
  13. package/lib/uninstall-project.js +95 -0
  14. package/lib/version-stamp.js +47 -0
  15. package/lib/version.js +23 -0
  16. package/package.json +37 -9
  17. package/vendor/skills/archgen/SKILL.md +252 -73
  18. package/vendor/skills/archgen/archgen.config.json +16 -0
  19. package/vendor/skills/archgen/assets/skill-registry.json +4 -3
  20. package/vendor/skills/archgen/references/artifact-templates.md +251 -7
  21. package/vendor/skills/archgen/references/interview.md +180 -16
  22. package/vendor/skills/archgen/references/mcp-and-skills.md +88 -17
  23. package/vendor/skills/archgen/references/orchestration.md +102 -39
  24. package/vendor/skills/archgen/references/platforms.md +18 -14
  25. package/vendor/skills/archgen/scripts/doc-index.mjs +457 -0
  26. package/vendor/skills/archgen/scripts/impact.mjs +14 -1
  27. package/vendor/skills/archgen/scripts/lib/graph.mjs +82 -3
  28. package/vendor/skills/archgen/scripts/lib/scope.mjs +65 -0
  29. package/vendor/skills/archgen/scripts/lib/yaml.mjs +19 -3
  30. package/vendor/skills/archgen/scripts/plan-graph.mjs +329 -0
  31. package/vendor/skills/archgen/scripts/set-status.mjs +26 -6
  32. package/vendor/skills/archgen/scripts/update-agents.mjs +204 -0
  33. package/vendor/skills/archgen/scripts/validate.mjs +18 -1
  34. package/vendor/skills/archgen/scripts/verify-plan.mjs +8 -3
@@ -1,7 +1,109 @@
1
1
  # Artifact templates — copy, fill, never invent structure
2
2
 
3
+ ## Provenance header (SHOULD on every NEW tasks.yaml / architecture.yaml)
4
+
5
+ Begin both files with three YAML comment lines. Comments are ignored by every
6
+ consumer (skill scripts, VS Code extension, any YAML toolchain), so this is
7
+ purely additive metadata — it can never break a parser:
8
+
9
+ ```yaml
10
+ # schema_version: 1
11
+ # generator: archgen v0.0.4
12
+ # generated_at: 2026-08-26T09:00:00.000Z
13
+ ```
14
+
15
+ Version token rules — code-defensive, NEVER guess:
16
+
17
+ 1. If a `.archgen-version` stamp sits next to `SKILL.md` (the installed skill
18
+ root) and reads as exact `MAJOR.MINOR.PATCH`, write `generator: archgen vX.Y.Z`.
19
+ 2. Else if an adjacent `archgen.config.json` carries a semver-shaped
20
+ `"version"` field, use that value the same way.
21
+ 3. Else omit the version token entirely: plain `# generator: archgen`.
22
+
23
+ `generated_at` is one ISO-8601 timestamp per generation run (all files written
24
+ by the same run share it). Keep the header at the very top of the file; never
25
+ place content above it and never encode meaning anywhere except these three
26
+ lines.
27
+
28
+ Older artifacts without the header are backfilled by
29
+ `npx archgen-skill migrate --apply` (dry-run `--check` is the default), which
30
+ snapshots each file into `.archgen/.backup/<ts>/migrate/` before touching it
31
+ and skips already-stamped files, so re-running is always safe.
32
+
33
+ ## Self-containment rules (anti-hallucination)
34
+
35
+ Artifacts are executed by sessions and sub-agents that were NEVER part of the
36
+ conversation that produced them. Hard rules, no exceptions:
37
+
38
+ 1. **Full paths, always.** Every task step, `file_ownership` glob, artifact,
39
+ and verification command uses complete repo-root-relative paths
40
+ (`src/features/catalog/api/routes.ts`), never bare filenames (`routes.ts`)
41
+ and never invented directories. Paths come from `structure:` /
42
+ `owns[]` in architecture.yaml or from surveyed code — nowhere else.
43
+ 2. **Names derive from naming_conventions.** Every file, symbol, table, and
44
+ env-var name you introduce cites WHICH convention key produced it, e.g.
45
+ `camelCase symbols per naming_conventions.symbol_casing`. If no key covers
46
+ it, add the key first, then use it.
47
+ 3. **Plans survive context summarization alone.** Any session reading ONLY
48
+ `.archgen/<slug>/` must execute correctly with zero chat history. If a fact
49
+ matters, it is written in an artifact; if it is not written, it does not
50
+ exist.
51
+ 4. **Forbidden phrases** (in any artifact): "as discussed", "the usual
52
+ pattern", "same as before", "see chat". Replace each with the concrete
53
+ artifact reference it was standing in for.
54
+ 5. **Cross-references are artifact-relative**, e.g.
55
+ `see ../architecture.yaml data_contracts.orders` or
56
+ `payload per ../architecture.yaml api_contracts.payments.request_payload`.
57
+ Never restate a contract from memory — point at it.
58
+ 6. **Verifier-compatible ids in plans.** `verify-plan.mjs` rejects any
59
+ UPPERCASE-numbered token in `plans/*.md` that is not a real tasks.yaml id
60
+ (`TASK-999` fails; your actual ids pass). So: requirement ids
61
+ (`FR-<MODULE>-nn`) are cited from `tasks.yaml` acceptance lines and
62
+ `docs/prd.md` itself; inside plan prose link the anchor instead —
63
+ `../docs/prd.md#fr-catalog-01`. Every tasks.yaml id MUST appear in some
64
+ plan file (coverage check runs both directions).
65
+
66
+ ## Plan depth by scope class
67
+
68
+ Pick ONE class before writing any artifact; depth scales with risk, not
69
+ enthusiasm. Misclassifying is a defect: inflating SMALL wastes tokens,
70
+ shrinking LARGE hallucinates.
71
+
72
+ - **SMALL** (add/touch few things): lean plan-note shape stays —
73
+
74
+ ```markdown
75
+ # <feature> — plan note (SMALL)
76
+ Intent: <one paragraph>
77
+ Tasks: see tasks.yaml entries <ids>
78
+ Risks: <bullets or none>
79
+ ```
80
+
81
+ Every task entry STILL carries absolute-from-repo-root paths verbatim —
82
+ in `file_ownership`, in each step, in verification commands. No Context
83
+ section, no diagrams, no PRD.
84
+
85
+ - **MEDIUM**: `plans/<feature>.md` gains, in order:
86
+ - **Context** — 2–4 paragraphs max: why now, what exists, what changes.
87
+ - **Per-task sections** (one `<id> — <title>` heading per task):
88
+ Approach (short bullets) + **Edge cases** (min 3 bullets each, feeding
89
+ the edge-case matrix below) + **Out-of-scope** (explicit non-goals).
90
+ - **Verification steps** — ordered, runnable, repo-root-relative.
91
+ No PRD, no diagrams unless structure changed.
92
+
93
+ - **LARGE / greenfield-from-scratch**: FULL professional stack — PRD
94
+ (`docs/prd.md`, ~1 page per major module) + expanded `architecture.yaml`
95
+ (naming_conventions, data_contracts, api_contracts, environment_matrix) +
96
+ per-task edge-case matrices + per-module diagrams + MEDIUM-grade plan
97
+ sections. Every diagram ≤15 nodes.
98
+
3
99
  ## architecture.yaml (LARGE scope)
4
100
 
101
+ The four contract blocks below (`naming_conventions`, `data_contracts`,
102
+ `api_contracts`, `environment_matrix`) are THE anti-hallucination source of
103
+ truth: tasks cite them by key instead of re-describing shapes from memory.
104
+ Module entries extend `schemas/architecture-conventions.md` (its
105
+ `name`/`responsibility`/`owns[]` trio is unchanged and still normative).
106
+
5
107
  ```yaml
6
108
  name: Acme Shop
7
109
  slug: acme-shop # becomes .archgen/acme-shop/
@@ -17,13 +119,44 @@ structure: # planned folder tree — planned BEFORE code exists
17
119
  purpose: cross-feature utilities, no feature imports
18
120
  - path: src/config/
19
121
  purpose: env parsing + constants
122
+ naming_conventions: # filled during generation; referenced by EVERY task
123
+ file_naming: kebab-case files, feature folder mirrors module name
124
+ dir_layout: "<module>/{api,internal,tests}; shared code only in src/shared/"
125
+ symbol_casing: PascalCase types, camelCase functions, SCREAMING_SNAKE env
126
+ test_placement: colocated <name>.test.ts next to unit under test
20
127
  modules:
21
128
  - name: catalog
22
129
  responsibility: product browsing + search
23
130
  owns: ["src/features/catalog/**"]
131
+ depends_on_modules: [] # acyclic; drives task depends_on edges
132
+ key_interfaces: # what OTHER modules may import — nothing else
133
+ - CatalogApi (src/features/catalog/api/index.ts)
24
134
  - name: checkout
25
135
  responsibility: cart → payment orchestration
26
136
  owns: ["src/features/checkout/**"]
137
+ depends_on_modules: [catalog]
138
+ key_interfaces:
139
+ - CheckoutApi (src/features/checkout/api/index.ts)
140
+ data_contracts: # schemas/entities; field tables, not prose
141
+ orders:
142
+ storage: postgres table orders (migration migrations/NNNN_orders.sql)
143
+ fields:
144
+ - {field: id, type: uuid, required: true, notes: pk}
145
+ - {field: session_id, type: uuid, required: true, notes: fk sessions}
146
+ - {field: total_cents, type: integer, required: true, notes: >= 0}
147
+ - {field: status, type: enum(pending,paid,failed), required: true}
148
+ - {field: created_at, type: timestamptz, required: true, notes: db default now()}
149
+ api_contracts: # endpoint/method/auth/payload/error-shape tables
150
+ payments:
151
+ - endpoint: /api/checkout/pay
152
+ method: POST
153
+ auth: session cookie; 401 when absent
154
+ request_payload: {order_id: uuid}
155
+ success: 200 {payment_id: uuid, status: paid}
156
+ error_shape: {code: string, message: string, retryable: boolean}
157
+ environment_matrix: # vars per env; unparsed vars fail fast in src/config/
158
+ - {var: DATABASE_URL, dev: local docker postgres, ci: ephemeral service, prod: secret ref, required: true}
159
+ - {var: PAYMENT_API_KEY, dev: stub key, ci: stub key, prod: secret ref, required: true}
27
160
  decisions: # ADR-lite; full ADRs live in decisions/
28
161
  - id: D1
29
162
  title: Postgres over MongoDB
@@ -32,6 +165,49 @@ decisions: # ADR-lite; full ADRs live in decisions/
32
165
  consequences: schema migrations required per release
33
166
  ```
34
167
 
168
+ Token balance: one contract block per module/domain (~10–20 lines each);
169
+ split further rather than letting any single block exceed ~40 lines.
170
+
171
+ ## Product requirements document (PRD) — LARGE/greenfield
172
+
173
+ Written to `docs/prd.md` BEFORE tasks.yaml. Bullet-dense prose, zero filler
174
+ paragraphs; target ~1 page per major module. Requirement ids here are the
175
+ stable handles every task acceptance cites.
176
+
177
+ ```markdown
178
+ # PRD — <project name>
179
+
180
+ ## Problem statement & goals
181
+ - <pain, quantified where possible>
182
+ - Goals: <3–5 outcome bullets, each measurable>
183
+
184
+ ## Non-goals
185
+ - <explicitly out; prevents scope creep mid-execution>
186
+
187
+ ## Personas / stakeholders
188
+ - <persona>: <need>, <success looks like>
189
+
190
+ ## Functional requirements — <module-name> (repeat per module)
191
+ - FR-<MODULE>-01: <single verifiable behavior statement>
192
+ - FR-<MODULE>-02: ...
193
+ <!-- ids are immutable once tasks reference them -->
194
+
195
+ ## Non-functional requirements (measurable targets, no adjectives)
196
+ - Perf: p95 API latency < 300 ms at 50 rps; LCP < 2.5 s
197
+ - Security: authz check on every endpoint; no secrets in repo; OWASP top-10 reviewed
198
+ - i18n: all user-facing strings externalized; ICU plurals; RTL-safe layouts
199
+ - A11y: WCAG 2.1 AA; full keyboard nav; contrast ≥ 4.5:1
200
+
201
+ ## Success metrics
202
+ - <metric>: <baseline> → <target> within <window>
203
+
204
+ ## Risks & mitigations
205
+ - <risk> → <mitigation>, <owner task id or ADR ref>
206
+
207
+ ## Open questions
208
+ - <question> — owner <name/role>, blocks <task id | none>
209
+ ```
210
+
35
211
  ## tasks.yaml (canonical shape)
36
212
 
37
213
  ```yaml
@@ -41,7 +217,7 @@ tasks:
41
217
  - id: C
42
218
  title: Scaffold project skeleton + config loading
43
219
  depends_on: []
44
- file_ownership: ["src/config/**", "package.json"]
220
+ file_ownership: ["src/config/**", "package.json"] # FULL repo-root-relative paths, never bare filenames
45
221
  acceptance:
46
222
  - "npm run build exits 0"
47
223
  - "config loads from env with typed schema"
@@ -62,17 +238,55 @@ tasks:
62
238
  ```
63
239
 
64
240
  Rules encoded above: depends_on = prerequisites; ownership globs disjoint
65
- within a wave; acceptance = objectively checkable statements.
241
+ within a wave; acceptance = objectively checkable statements. Acceptance
242
+ bullets SHOULD reference edge-matrix rows (`E1`–`En` of that task's matrix)
243
+ and, on LARGE, the FR ids they implement. Schema stays stable
244
+ (`schemas/tasks.schema.json`, schema_version 1) — no new required fields;
245
+ guidance lives in comments and plan files.
246
+
247
+ LARGE-grade example task (same schema, richer acceptance — sits beside the
248
+ minimal ones above, never replaces them):
249
+
250
+ ```yaml
251
+ - id: PAY-2
252
+ title: Order payment capture with retry
253
+ depends_on: [A]
254
+ parallel_group: wave-payments
255
+ file_ownership:
256
+ - src/features/checkout/internal/capture.ts # full path per naming_conventions.dir_layout
257
+ - src/features/checkout/internal/capture.test.ts # colocated per naming_conventions.test_placement
258
+ artifacts: ["docs/payment-retry.md"]
259
+ acceptance:
260
+ - "capture() sends idempotency key; double submit charges once (E3)"
261
+ - "gateway 5xx retries 3x exponential backoff, then raises PaymentFailed (E5)"
262
+ - "denied card → 402 with error_shape from ../architecture.yaml api_contracts.payments (FR-PAYMENTS-02)"
263
+ - "amounts render via session locale, cents-safe integer math (E6)"
264
+ ```
265
+
266
+ ## Edge-case matrix (per task, MEDIUM+)
66
267
 
67
- ## SMALL-scope plan note (plans/<feature>.md)
268
+ Each MEDIUM/LARGE task carries a matrix in its plan section. Every row MUST
269
+ map to an acceptance bullet — no orphan rows; every acceptance bullet SHOULD
270
+ trace to ≥1 row. Minimum coverage classes per task: empty/null, boundary
271
+ values, authz denied, concurrent/conflicting write, failure/retry path,
272
+ i18n/formatting edge. Tasks touching infra (migrations, deploys, queues)
273
+ ADD: partial-failure recovery, rollback story.
68
274
 
69
275
  ```markdown
70
- # <feature> — plan note (SMALL)
71
- Intent: <one paragraph>
72
- Tasks: see tasks.yaml entries <ids>
73
- Risks: <bullets or none>
276
+ | Case | Input/state | Expected behavior | Covered by |
277
+ | ---- | ------------------------------- | ------------------------------------ | ---------- |
278
+ | E1 | empty/null: cart with 0 items | 200, total 0, no gateway call | PAY-2#1 |
279
+ | E2 | boundary: qty = max allowed 999 | accepted; 1000 rejected with 422 | PAY-2#1 |
280
+ | E3 | concurrent: same order paid 2x | idempotency key → single charge | PAY-2#1 |
281
+ | E4 | authz denied: expired session | 401 error_shape, no state change | PAY-2#2 |
282
+ | E5 | failure/retry: gateway 5xx x3 | backoff retry then PaymentFailed | PAY-2#2 |
283
+ | E6 | i18n: locale de-DE, ¥-less cur | EUR formatting, correct decimal comma| PAY-2#3 |
74
284
  ```
75
285
 
286
+ `Covered by` = `<task-id>#<acceptance index>` (1-based, matching the
287
+ tasks.yaml `acceptance` array). Rows are additive across waves; keep each
288
+ matrix ≤10 rows — split into per-concern tables beyond that.
289
+
76
290
  ## ADR template (decisions/NNNN-title.md)
77
291
 
78
292
  ```markdown
@@ -103,3 +317,33 @@ graph LR
103
317
  api --> db[(Postgres)]
104
318
  api --> cache[(Redis)]
105
319
  ```
320
+
321
+ ## Per-module diagram (LARGE)
322
+
323
+ For EACH `modules:` entry in architecture.yaml, one small flowchart of its
324
+ internal components plus its `depends_on_modules` edges (arrow points from
325
+ consumer to provider). Plus ONE integration diagram wiring all modules —
326
+ edges between modules only, no internals. HARD LIMIT: ≤15 nodes per diagram;
327
+ split into two diagrams rather than cramming. Internals stay ≤6 nodes per
328
+ module.
329
+
330
+ Catalog module (internal + inbound depends_on edge):
331
+
332
+ ```mermaid
333
+ graph LR
334
+ subgraph catalog
335
+ routes[api routes] --> svc[search service]
336
+ svc --> repo[(product repository)]
337
+ end
338
+ checkout -.->|depends_on CatalogApi| routes
339
+ ```
340
+
341
+ Integration (modules as atoms, mirrors depends_on_modules):
342
+
343
+ ```mermaid
344
+ graph LR
345
+ accounts --> catalog
346
+ cart --> catalog
347
+ checkout --> cart
348
+ checkout --> accounts
349
+ ```
@@ -3,24 +3,147 @@
3
3
  Goal: complete, conflict-free requirements in the FEWEST round-trips.
4
4
  Batch 3–5 questions per message. Never ask what you can infer.
5
5
 
6
- ## Round 1 — business frame (ask the user)
6
+ ## Round 0 — calibration exchange (skippable)
7
7
 
8
- 1. What problem does this solve, and for whom? (one sentence is enough)
9
- 2. What does success look like — measurable if possible?
10
- 3. Hard constraints: deadline, budget, must-keep systems?
8
+ Two or three rapid questions, asked once at the very start:
11
9
 
12
- ## Round 2 — technical frame (infer first, confirm second)
10
+ 1. Rough scale: prototype, MVP, or production-bound?
11
+ 2. Team size + convention constraints? (solo? existing lint/CI/style guides?)
12
+ 3. Deadline pressure: none, moderate, crunch?
13
+
14
+ Purpose is ONLY to pick question-set depth and right-size later verification
15
+ rigor — never to collect requirements. SKIP the whole exchange when the user's
16
+ opening message already answers these items (e.g. "quick prototype by Friday").
17
+ Record whatever was captured under `calibration:` in answers.yaml.
18
+
19
+ ## Step 1 — classify intent (decide during round 1)
20
+
21
+ From the opening message + calibration, decide ONE intent class, state it to
22
+ the user in one sentence, and record it as `intent_class` in answers.yaml:
23
+
24
+ | intent_class | Signal | Question depth | Round cap |
25
+ |---|---|---|---|
26
+ | GREENFIELD-SYSTEM | net-new product/system from scratch; no host repo | full PRD-grade discovery | ≤6 |
27
+ | GREENFIELD-MODULE | net-new capability inside an existing system/repo | targeted; infer from host repo first | ≤3 |
28
+ | BROWNFIELD-FEATURE | existing repo, additive behavior | survey-first; ask only survey gaps (max ~5 questions) | ≤3 |
29
+ | BROWNFIELD-CHANGE | modify existing behavior in place | survey-first; diff current vs desired | ≤3 |
30
+
31
+ Never interrogate a BROWNFIELD-FEATURE with PRD-grade questions — token waste,
32
+ user annoyance. Round caps INCLUDE round 0 when it runs.
33
+
34
+ ## GREENFIELD-SYSTEM — professional discovery (≤6 rounds)
35
+
36
+ Creating a system from scratch demands PRD-grade inputs. Each round below
37
+ lists its questions and where the answers land (`feeds:` tags — see
38
+ Traceability).
39
+
40
+ ### R1 — problem, users, success → PRD
41
+
42
+ 1. What problem does this solve, for whom — and what is explicitly NOT a goal?
43
+ 2. Who uses it? Sketch 1–3 personas: role, key job-to-be-done, environment.
44
+ 3. What does success look like — measurable (activation, conversion,
45
+ time-saved, error rate)? Adjectives are not metrics.
46
+
47
+ ### R2 — shape & module decomposition → architecture.yaml `modules`
48
+
49
+ Infer stack/hosting from stated preferences, then confirm:
13
50
 
14
- Draft answers from context (existing repo, stated stack), then confirm:
15
51
  4. Stack + hosting target correct? (state your inference)
16
- 5. Scale expectation: users/reqs/day, data growth?
17
- 6. Integration surfaces: auth, payments, email, existing APIs?
52
+ 5. Integration surfaces: auth, payments, email, existing APIs?
53
+
54
+ Then PROPOSE a strawman module map from the domain talk — one line per
55
+ candidate module as `name — responsibility` (mirroring `modules[]`:
56
+ name/responsibility/owns) — and ask the user to react:
57
+
58
+ 6. React to this strawman module map: [list]. What is missing, misnamed, or
59
+ should be merged/split? Iterate until agreement — this seeds
60
+ architecture.yaml `modules`.
61
+
62
+ ### R3 — data & API sketches → `data_contracts`, `api_contracts`
63
+
64
+ 7. Core data entities and relationships — one line each: Entity — key fields —
65
+ belongs-to / has-many? (seeds `data_contracts`)
66
+ 8. Primary API surface: the 5–10 operations users/systems perform, verb +
67
+ resource? (seeds `api_contracts`)
68
+
69
+ ### R4 — NFRs with numbers → PRD
70
+
71
+ Numbers or it didn't happen — reject "fast"/"scalable" without figures.
72
+
73
+ 9. Performance budgets: p95 latency, throughput at peak?
74
+ 10. Scale targets: users, reqs/day, data growth per year?
75
+ 11. Security/compliance checklist level (GDPR/HIPAA/PCI)? i18n locales?
76
+ Accessibility level (e.g. WCAG 2.2 AA)?
77
+
78
+ ### R5 — environment & naming → `environment_matrix`, `naming_conventions`
79
+
80
+ 12. Environment/deploy reality: which environments exist (dev/staging/prod),
81
+ hosting, config/secrets handling, deploy cadence? (seeds
82
+ `environment_matrix`)
83
+ 13. Naming/brand conventions that already exist: product-name casing, domain
84
+ terms to preserve, UI copy language(s)? (seeds `naming_conventions`;
85
+ "none" is a valid answer)
18
86
 
19
- ## Round 3 — constraints & risks
87
+ ### R6 — close-out → PRD
20
88
 
21
- 7. Compliance needs? (GDPR/HIPAA/PCI — checklist level only)
22
- 8. What must NOT change?
23
- 9. Top 2 risks the user already knows about?
89
+ 14. Explicit out-of-scope list — adjacent things on record as NOT in this build?
90
+ 15. Top 2 risks you already know about?
91
+
92
+ Close by presenting the agreed module map + captured NFR numbers for final
93
+ confirmation ([wait for user]).
94
+
95
+ ### Traceability — `feeds:` tags
96
+
97
+ Every recorded answer MAY carry a `feeds:` tag naming the artifact section it
98
+ lands in. Keep the vocabulary literal — downstream templates consume these
99
+ exact names:
100
+
101
+ - PRD sections: `prd.problem`, `prd.goals`, `prd.non_goals`, `prd.personas`,
102
+ `prd.metrics`, `prd.nfrs`, `prd.constraints`, `prd.integrations`,
103
+ `prd.risks`, `prd.out_of_scope`
104
+ - architecture.yaml keys: `arch.modules`, `arch.data_contracts`,
105
+ `arch.api_contracts`, `arch.environment_matrix`, `arch.naming_conventions`
106
+
107
+ Multiple targets join with `|`, e.g. `feeds: prd.goals|arch.modules`.
108
+
109
+ ## GREENFIELD-MODULE — net-new inside an existing system (≤3 rounds)
110
+
111
+ Infer first from the host repo (structure, conventions, neighboring modules),
112
+ confirm second:
113
+
114
+ 1. Where does it plug in — which host modules does it read from / expose to?
115
+ 2. Contract with the host: data it consumes/produces, APIs or events it
116
+ exposes? (seeds `data_contracts` / `api_contracts` deltas)
117
+ 3. Inherited vs new NFRs: follow host perf/a11y/i18n baselines or set new ones?
118
+ 4. Naming follows host conventions — confirm? (seeds `naming_conventions`)
119
+
120
+ ## BROWNFIELD classes — survey BEFORE questioning (mandatory)
121
+
122
+ Run the survey first (SKILL.md BROWNFIELD steps 1–2): prefer the codegraph MCP
123
+ (`codegraph_explore`) when configured, else structured glob/grep; produce or
124
+ update `.archgen/<slug>/codebase-map.md`. Then ask ONLY what the survey could
125
+ not answer. NEVER ask what a file already answers — quote the file and ask for
126
+ confirmation instead.
127
+
128
+ ### BROWNFIELD-FEATURE (additive; max ~5 questions, one batched message)
129
+
130
+ Ask only unresolved gaps, typically:
131
+
132
+ 1. Acceptance criteria the code cannot reveal — exact expected behavior, edge
133
+ cases that matter.
134
+ 2. Back-compat expectations for existing records or clients.
135
+ 3. Rollout preference: feature flag, staged, immediate?
136
+ 4. Must-NOT-touch paths beyond what the map shows?
137
+ 5. Anything the codebase-map got wrong?
138
+
139
+ ### BROWNFIELD-CHANGE (behavior modification; ≤3 rounds)
140
+
141
+ Survey focus: current behavior + blast radius (callers, tests, consumers).
142
+
143
+ 1. Current vs desired behavior — precise diff, including what must stay.
144
+ 2. Compatibility: migrate in place, version alongside, or breaking change?
145
+ 3. Acceptance for "changed": how do we prove old behavior is gone and the new
146
+ behavior holds?
24
147
 
25
148
  ## Conflict detection
26
149
 
@@ -32,18 +155,46 @@ While collecting, watch for and surface immediately:
32
155
  Format: "I see a tension between X and Y. Which wins?" — one per message,
33
156
  resolve before proceeding. [wait for user]
34
157
 
158
+ ## Token discipline
159
+
160
+ - Batch 3–5 questions per message; never ping-pong one-per-message.
161
+ - Hard round caps: GREENFIELD-SYSTEM ≤6 rounds, every other class ≤3
162
+ (round 0 counts when it runs).
163
+ - Skip any question already answered by the opening message, calibration, or
164
+ survey artifacts.
165
+
35
166
  ## Answers-file format (machine-readable, enables non-interactive runs)
36
167
 
37
168
  For scripted E2E or re-runs, requirements may come from a file instead of
38
169
  conversation — `.archgen/<slug>/answers.yaml`:
39
170
 
40
171
  ```yaml
41
- scope_class: MEDIUM # SMALL | MEDIUM | LARGE
172
+ scope_class: MEDIUM # SMALL | MEDIUM | LARGE — UNCHANGED; SKILL.md reads
173
+ # this for right-sizing. Never remove or rename.
174
+ intent_class: GREENFIELD-SYSTEM # optional: GREENFIELD-SYSTEM |
175
+ # GREENFIELD-MODULE | BROWNFIELD-FEATURE |
176
+ # BROWNFIELD-CHANGE
177
+ calibration: # optional — from round 0
178
+ scale: production # prototype | mvp | production
179
+ teamConstraints: solo dev, repo lint rules apply
180
+ pressure: medium # low | medium | high
42
181
  problem: one-line problem statement
43
182
  success_criteria:
44
- - measurable outcome
183
+ - text: measurable outcome # structured entries MAY carry feeds:
184
+ feeds: prd.metrics
45
185
  constraints:
46
- - must-not-change items
186
+ - must-not-change item # plain scalars stay valid; tag via
187
+ # trailing comment: # feeds: prd.constraints
188
+ non_goals: # optional (GREENFIELD-SYSTEM)
189
+ - multi-tenant accounts
190
+ personas: # optional (GREENFIELD-SYSTEM)
191
+ - role: shopper
192
+ goal: find and buy in under two minutes
193
+ nfrs: # optional; NUMBERS required for GREENFIELD-SYSTEM
194
+ - "p95 API latency < 300ms at 50 rps"
195
+ - "locales: en, de"
196
+ - "accessibility: WCAG 2.2 AA"
197
+ out_of_scope: [] # optional
47
198
  stack:
48
199
  language: typescript
49
200
  runtime: node
@@ -54,13 +205,26 @@ risks:
54
205
  - known risk text
55
206
  ```
56
207
 
208
+ Backward compatibility: ALL additions (`intent_class`, `calibration`,
209
+ `non_goals`, `personas`, `nfrs`, `out_of_scope`, per-answer `feeds:` tags) are
210
+ OPTIONAL. Existing fields keep their names and semantics; `scope_class` is
211
+ retained verbatim because SKILL.md consumes it. Consumers that do not trace
212
+ provenance ignore `feeds:` tags in both forms (sibling key on structured
213
+ entries, trailing comment on plain scalars).
214
+
57
215
  The orchestrator treats answers.yaml as authoritative user input and skips
58
216
  the conversational rounds when it exists and parses cleanly.
59
217
 
60
218
  ## Completion test
61
219
 
62
220
  Requirements are done when ALL hold:
63
- - Every ROUND-1 question answered
221
+ - Every applicable question in the chosen intent class's question set answered
222
+ (or explicitly waived by the user)
64
223
  - All drafted inferences confirmed or corrected
65
224
  - Zero unresolved conflicts
66
225
  - Scope class agreed (SMALL/MEDIUM/LARGE) — this gates artifact generation
226
+ (unchanged; SKILL.md consumes it)
227
+ - Chosen `intent_class` recorded in answers.yaml
228
+ - GREENFIELD-SYSTEM only: module-map agreement reached (user reacted to the
229
+ strawman and the revision is confirmed) AND NFR numbers captured — an NFR
230
+ without a number fails this gate