archgen-skill 0.0.5 → 0.0.7

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 (39) hide show
  1. package/README.md +20 -7
  2. package/bin/archgen.mjs +142 -15
  3. package/lib/block.js +52 -11
  4. package/lib/bootstrap.js +107 -0
  5. package/lib/config.js +3 -2
  6. package/lib/doctor.js +197 -77
  7. package/lib/init.js +77 -19
  8. package/lib/install.js +79 -7
  9. package/lib/mcp-server.js +241 -0
  10. package/lib/migrations/001-stamp-provenance.mjs +15 -8
  11. package/lib/migrations/index.mjs +19 -8
  12. package/lib/restore.js +52 -16
  13. package/lib/spawn-npm.js +99 -0
  14. package/lib/store.js +175 -28
  15. package/lib/uninstall-project.js +38 -7
  16. package/lib/version.js +20 -4
  17. package/package.json +3 -3
  18. package/vendor/skills/archgen/SKILL.md +363 -213
  19. package/vendor/skills/archgen/archgen.config.json +1 -1
  20. package/vendor/skills/archgen/references/code-standards.md +2 -2
  21. package/vendor/skills/archgen/assets/mcp-template.json +0 -42
  22. package/vendor/skills/archgen/assets/skill-registry.json +0 -24
  23. package/vendor/skills/archgen/references/artifact-templates.md +0 -406
  24. package/vendor/skills/archgen/references/interview.md +0 -275
  25. package/vendor/skills/archgen/references/mcp-and-skills.md +0 -117
  26. package/vendor/skills/archgen/references/orchestration.md +0 -292
  27. package/vendor/skills/archgen/references/platforms.md +0 -138
  28. package/vendor/skills/archgen/scripts/doc-index.mjs +0 -457
  29. package/vendor/skills/archgen/scripts/impact.mjs +0 -77
  30. package/vendor/skills/archgen/scripts/lib/graph.mjs +0 -222
  31. package/vendor/skills/archgen/scripts/lib/plan-coverage.mjs +0 -32
  32. package/vendor/skills/archgen/scripts/lib/scope.mjs +0 -65
  33. package/vendor/skills/archgen/scripts/lib/yaml.mjs +0 -492
  34. package/vendor/skills/archgen/scripts/next-tasks.mjs +0 -55
  35. package/vendor/skills/archgen/scripts/plan-graph.mjs +0 -329
  36. package/vendor/skills/archgen/scripts/set-status.mjs +0 -82
  37. package/vendor/skills/archgen/scripts/update-agents.mjs +0 -213
  38. package/vendor/skills/archgen/scripts/validate.mjs +0 -87
  39. package/vendor/skills/archgen/scripts/verify-plan.mjs +0 -70
@@ -1,275 +0,0 @@
1
- # Interview playbook — requirement elicitation
2
-
3
- Goal: complete, conflict-free requirements in the FEWEST round-trips.
4
- Batch 3–5 questions per message. Never ask what you can infer — ask only
5
- decision-forks, state everything else as a veto-able decision (§ How to ask).
6
-
7
- ## How to ask
8
-
9
- - **Tool-first, options-fallback.** Use your harness's ask-question /
10
- interactive multiple-choice tool when one exists; no such tool → ask inline
11
- with labeled options. Same content either way.
12
- - **Recommendation-first.** Every option set leads with YOUR best judgment
13
- tagged `(recommended)`, then alternatives. The user accepts the
14
- recommendation by default and may override — never present bare options
15
- without a recommendation.
16
- - **Ask forks, state decisions.** Ask ONLY the few decision-forks that
17
- materially branch the plan. Everything derivative: DECIDE autonomously and
18
- announce — "I'll use X because Y — say so if you'd rather Z" — so the user
19
- can veto without being interrogated.
20
- - **Volume scales with scope.** Round caps (§ Step 1) are MAXIMA, not targets:
21
- SMALL/simple prompt → at most 1–2 core questions, decide the rest; MEDIUM →
22
- the targeted set; LARGE — or an experienced engineer signaling they want
23
- control → the fuller discovery set.
24
-
25
- Worked example (recommendation-first, inline fallback form):
26
-
27
- > Rollout strategy?
28
- > 1. Feature flag + staged rollout **(recommended)** — existing users unaffected
29
- > 2. Immediate cutover — simpler, riskier
30
- > 3. Versioned API alongside — only if existing clients break
31
- > Reply 1–3, or just "ok" to accept the recommendation.
32
-
33
- ## Round 0 — calibration exchange (skippable)
34
-
35
- Two or three rapid items, asked once at the very start — each INFERRED first
36
- (§ How to ask), asked only when genuinely ambiguous:
37
-
38
- 1. Rough scale: prototype, MVP, or production-bound? INFER from the opening
39
- message + repo context; state the inference + one line of reasoning and
40
- let the user confirm or correct. Ask open-ended ONLY when genuinely
41
- ambiguous.
42
- 2. Team size + convention constraints? (solo? existing lint/CI/style guides?)
43
- 3. Deadline pressure: none, moderate, crunch?
44
-
45
- Purpose is ONLY to pick question-set depth and right-size later verification
46
- rigor — never to collect requirements. SKIP the whole exchange when the user's
47
- opening message already answers these items (e.g. "quick prototype by
48
- Friday"); SMALL/simple prompts skip calibration entirely and go straight to
49
- their 1–2 core forks (§ How to ask). Record whatever was captured under
50
- `calibration:` in answers.yaml.
51
-
52
- ## Step 1 — classify intent (decide during round 1)
53
-
54
- From the opening message + calibration, decide ONE intent class, state it to
55
- the user in one sentence, and record it as `intent_class` in answers.yaml:
56
-
57
- | intent_class | Signal | Question depth | Round cap |
58
- |---|---|---|---|
59
- | GREENFIELD-SYSTEM | net-new product/system from scratch; no host repo | full PRD-grade discovery | ≤6 |
60
- | GREENFIELD-MODULE | net-new capability inside an existing system/repo | targeted; infer from host repo first | ≤3 |
61
- | BROWNFIELD-FEATURE | existing repo, additive behavior | survey-first; ask only survey gaps (max ~5 questions) | ≤3 |
62
- | BROWNFIELD-CHANGE | modify existing behavior in place | survey-first; diff current vs desired | ≤3 |
63
-
64
- Never interrogate a BROWNFIELD-FEATURE with PRD-grade questions — token waste,
65
- user annoyance. Round caps INCLUDE round 0 when it runs.
66
-
67
- Default `scope_class` from the intent class (user's choice wins — scope_class
68
- is agreed in GENERATE step 1 and recorded in answers.yaml):
69
- GREENFIELD-SYSTEM→LARGE, GREENFIELD-MODULE→MEDIUM,
70
- BROWNFIELD-FEATURE→MEDIUM/SMALL, BROWNFIELD-CHANGE→SMALL.
71
-
72
- Scale is INFERRED, not asked: derive scope_class from the opening message +
73
- repo context + the class above, state it with one line of reasoning, and let
74
- the user confirm or correct. Ask about scale ONLY when genuinely
75
- ambiguous/confused. Small/simple prompts: skip heavy calibration, ask only
76
- the 1–2 core forks (§ How to ask), decide the rest.
77
-
78
- ## GREENFIELD-SYSTEM — professional discovery (≤6 rounds)
79
-
80
- Creating a system from scratch demands PRD-grade inputs. Each round below
81
- lists its questions and where the answers land (`feeds:` tags — see
82
- Traceability).
83
-
84
- ### R1 — problem, users, success → PRD
85
-
86
- 1. What problem does this solve, for whom — and what is explicitly NOT a goal?
87
- 2. Who uses it? Sketch 1–3 personas: role, key job-to-be-done, environment.
88
- 3. What does success look like — measurable (activation, conversion,
89
- time-saved, error rate)? Adjectives are not metrics.
90
-
91
- ### R2 — shape & module decomposition → architecture.yaml `modules`
92
-
93
- Infer stack/hosting from stated preferences, then confirm:
94
-
95
- 4. Stack + hosting target correct? (state your inference)
96
- 5. Integration surfaces: auth, payments, email, existing APIs?
97
-
98
- Then PROPOSE a strawman module map from the domain talk — one line per
99
- candidate module as `name — responsibility` (mirroring `modules[]`:
100
- name/responsibility/owns) — and ask the user to react:
101
-
102
- 6. React to this strawman module map: [list]. What is missing, misnamed, or
103
- should be merged/split? Iterate until agreement — this seeds
104
- architecture.yaml `modules`.
105
-
106
- ### R3 — data & API sketches → `data_contracts`, `api_contracts`
107
-
108
- 7. Core data entities and relationships — one line each: Entity — key fields —
109
- belongs-to / has-many? (seeds `data_contracts`)
110
- 8. Primary API surface: the 5–10 operations users/systems perform, verb +
111
- resource? (seeds `api_contracts`)
112
-
113
- ### R4 — NFRs with numbers → PRD
114
-
115
- Numbers or it didn't happen — reject "fast"/"scalable" without figures.
116
-
117
- 9. Performance budgets: p95 latency, throughput at peak?
118
- 10. Scale targets: users, reqs/day, data growth per year?
119
- 11. Security/compliance checklist level (GDPR/HIPAA/PCI)? i18n locales?
120
- Accessibility level (e.g. WCAG 2.2 AA)?
121
-
122
- ### R5 — environment & naming → `environment_matrix`, `naming_conventions`
123
-
124
- 12. Environment/deploy reality: which environments exist (dev/staging/prod),
125
- hosting, config/secrets handling, deploy cadence? (seeds
126
- `environment_matrix`)
127
- 13. Naming/brand conventions that already exist: product-name casing, domain
128
- terms to preserve, UI copy language(s)? (seeds `naming_conventions`;
129
- "none" is a valid answer)
130
-
131
- ### R6 — close-out → PRD
132
-
133
- 14. Explicit out-of-scope list — adjacent things on record as NOT in this build?
134
- 15. Top 2 risks you already know about?
135
-
136
- Close by presenting the agreed module map + captured NFR numbers for final
137
- confirmation ([wait for user]).
138
-
139
- ### Traceability — `feeds:` tags
140
-
141
- Every recorded answer MAY carry a `feeds:` tag naming the artifact section it
142
- lands in. Keep the vocabulary literal — downstream templates consume these
143
- exact names:
144
-
145
- - PRD sections: `prd.problem`, `prd.goals`, `prd.non_goals`, `prd.personas`,
146
- `prd.metrics`, `prd.nfrs`, `prd.constraints`, `prd.integrations`,
147
- `prd.risks`, `prd.out_of_scope`
148
- - architecture.yaml keys: `arch.modules`, `arch.data_contracts`,
149
- `arch.api_contracts`, `arch.environment_matrix`, `arch.naming_conventions`
150
-
151
- Multiple targets join with `|`, e.g. `feeds: prd.goals|arch.modules`.
152
-
153
- ## GREENFIELD-MODULE — net-new inside an existing system (≤3 rounds)
154
-
155
- Infer first from the host repo (structure, conventions, neighboring modules),
156
- confirm second:
157
-
158
- 1. Where does it plug in — which host modules does it read from / expose to?
159
- 2. Contract with the host: data it consumes/produces, APIs or events it
160
- exposes? (seeds `data_contracts` / `api_contracts` deltas)
161
- 3. Inherited vs new NFRs: follow host perf/a11y/i18n baselines or set new ones?
162
- 4. Naming follows host conventions — confirm? (seeds `naming_conventions`)
163
-
164
- ## BROWNFIELD classes — survey BEFORE questioning (mandatory)
165
-
166
- Run the survey first (SKILL.md BROWNFIELD steps 1–2): prefer the codegraph MCP
167
- (`codegraph_explore`) when configured, else structured glob/grep; produce or
168
- update `.archgen/<slug>/codebase-map.md`. Then ask ONLY what the survey could
169
- not answer. NEVER ask what a file already answers — quote the file and ask for
170
- confirmation instead.
171
-
172
- ### BROWNFIELD-FEATURE (additive; max ~5 questions, one batched message)
173
-
174
- Ask only unresolved gaps, typically:
175
-
176
- 1. Acceptance criteria the code cannot reveal — exact expected behavior, edge
177
- cases that matter.
178
- 2. Back-compat expectations for existing records or clients.
179
- 3. Rollout preference: feature flag, staged, immediate?
180
- 4. Must-NOT-touch paths beyond what the map shows?
181
- 5. Anything the codebase-map got wrong?
182
-
183
- ### BROWNFIELD-CHANGE (behavior modification; ≤3 rounds)
184
-
185
- Survey focus: current behavior + blast radius (callers, tests, consumers).
186
-
187
- 1. Current vs desired behavior — precise diff, including what must stay.
188
- 2. Compatibility: migrate in place, version alongside, or breaking change?
189
- 3. Acceptance for "changed": how do we prove old behavior is gone and the new
190
- behavior holds?
191
-
192
- ## Conflict detection
193
-
194
- While collecting, watch for and surface immediately:
195
- - Scale vs budget contradictions ("1M users" + "cheapest VPS")
196
- - Feature vs constraint collisions ("real-time" + "no websockets allowed")
197
- - Requirement vs existing-architecture conflicts (brownfield: check codebase-map)
198
-
199
- Format: "I see a tension between X and Y. Which wins?" — one per message,
200
- resolve before proceeding. [wait for user]
201
-
202
- ## Token discipline
203
-
204
- - Batch 3–5 questions per message; never ping-pong one-per-message.
205
- - Hard round caps — MAXIMA, not targets (small prompts ask far fewer;
206
- § How to ask): GREENFIELD-SYSTEM ≤6 rounds, every other class ≤3
207
- (round 0 counts when it runs).
208
- - Skip any question already answered by the opening message, calibration, or
209
- survey artifacts.
210
-
211
- ## Answers-file format (machine-readable, enables non-interactive runs)
212
-
213
- For scripted E2E or re-runs, requirements may come from a file instead of
214
- conversation — `.archgen/<slug>/answers.yaml`:
215
-
216
- ```yaml
217
- scope_class: MEDIUM # SMALL | MEDIUM | LARGE — UNCHANGED; SKILL.md reads
218
- # this for right-sizing. Never remove or rename.
219
- intent_class: GREENFIELD-SYSTEM # optional: GREENFIELD-SYSTEM |
220
- # GREENFIELD-MODULE | BROWNFIELD-FEATURE |
221
- # BROWNFIELD-CHANGE
222
- calibration: # optional — from round 0
223
- scale: production # prototype | mvp | production
224
- teamConstraints: solo dev, repo lint rules apply
225
- pressure: medium # low | medium | high
226
- problem: one-line problem statement
227
- success_criteria:
228
- - text: measurable outcome # structured entries MAY carry feeds:
229
- feeds: prd.metrics
230
- constraints:
231
- - must-not-change item # plain scalars stay valid; tag via
232
- # trailing comment: # feeds: prd.constraints
233
- non_goals: # optional (GREENFIELD-SYSTEM)
234
- - multi-tenant accounts
235
- personas: # optional (GREENFIELD-SYSTEM)
236
- - role: shopper
237
- goal: find and buy in under two minutes
238
- nfrs: # optional; NUMBERS required for GREENFIELD-SYSTEM
239
- - "p95 API latency < 300ms at 50 rps"
240
- - "locales: en, de"
241
- - "accessibility: WCAG 2.2 AA"
242
- out_of_scope: [] # optional
243
- stack:
244
- language: typescript
245
- runtime: node
246
- hosting: vercel
247
- integrations: [auth0, stripe]
248
- compliance: [] # checklist placeholders only
249
- risks:
250
- - known risk text
251
- ```
252
-
253
- Backward compatibility: ALL additions (`intent_class`, `calibration`,
254
- `non_goals`, `personas`, `nfrs`, `out_of_scope`, per-answer `feeds:` tags) are
255
- OPTIONAL. Existing fields keep their names and semantics; `scope_class` is
256
- retained verbatim because SKILL.md consumes it. Consumers that do not trace
257
- provenance ignore `feeds:` tags in both forms (sibling key on structured
258
- entries, trailing comment on plain scalars).
259
-
260
- The orchestrator treats answers.yaml as authoritative user input and skips
261
- the conversational rounds when it exists and parses cleanly.
262
-
263
- ## Completion test
264
-
265
- Requirements are done when ALL hold:
266
- - Every applicable question in the chosen intent class's question set answered
267
- (or explicitly waived by the user)
268
- - All drafted inferences confirmed or corrected
269
- - Zero unresolved conflicts
270
- - Scope class agreed (SMALL/MEDIUM/LARGE) — this gates artifact generation
271
- (unchanged; SKILL.md consumes it)
272
- - Chosen `intent_class` recorded in answers.yaml
273
- - GREENFIELD-SYSTEM only: module-map agreement reached (user reacted to the
274
- strawman and the revision is confirmed) AND NFR numbers captured — an NFR
275
- without a number fails this gate
@@ -1,117 +0,0 @@
1
- # MCP installation and skill fetching
2
-
3
- ## INSTALL-MCP procedure (approval-gated)
4
-
5
- 1. **Identify** the platform (SKILL.md Step 0), load its row from
6
- references/platforms.md section MCP: config file, top-level key, quirks.
7
- 2. **Discover** — when the correct installation method or config shape for
8
- the detected harness is not confidently known, web-search the CURRENT
9
- official installation docs/command FIRST. Never trust potentially-stale
10
- memorized commands or invented config shapes; uncertainty triggers search,
11
- not guessing.
12
- 3. **Scope** — choose and state the install scope explicitly:
13
- - **GLOBAL** — server types that are global entries (npx/npm-based MCP
14
- servers usable across harnesses). Recommended for universally-useful
15
- servers (codegraph is the canonical example) unless the user prefers
16
- project-local.
17
- - **HARNESS-SPECIFIC** — write into the detected platform's config only.
18
- Recommended when the server only matters to that platform.
19
- The user's approval covers the stated scope.
20
- 4. **Prefer the platform CLI** where the table lists one, passing the scope
21
- flag that matches the chosen scope:
22
- - `claude mcp add --scope project --transport http <name> <url>`
23
- - `codex mcp add <name> --url <url>` or `codex mcp add <n> -- cmd args`
24
- - `gemini mcp add -s project -t http <name> <url>`
25
- 5. No CLI available: draft the exact config diff against the platform's real
26
- shape (see assets/mcp-template.json for annotated canonical forms) and SHOW
27
- it to the user. **USER APPROVAL GATE** — wait for an explicit yes before any
28
- write; approval is never inferred from earlier steps.
29
- 6. Apply, then apply the restart semantics from the platforms table.
30
- 7. Verify the tool is visible after reload; report failure modes honestly.
31
-
32
- Never write MCP configs silently. Never invent config shapes — the four known
33
- top-level keys are mcpServers / servers / mcp / context_servers; remote URL
34
- fields vary (url vs serverUrl vs httpUrl) per the platforms table. Uncertainty
35
- triggers web-search of current official docs, never invention.
36
-
37
- ## FETCH-SKILL procedure
38
-
39
- Capability-skill loading is **REQUIRED, not opportunistic**. Whenever planned
40
- work touches a registry `matches` domain, the matching skill MUST be loaded —
41
- during planning (GENERATE / BROWNFIELD / UPDATE) AND re-verified during
42
- execution (worker dispatch). UI/design/frontend/animation/component/
43
- landing-page work REQUIRES the design skills (`ui-skills`, `policy:
44
- "required"`) loaded first. Referenced from elsewhere as:
45
- *see references/mcp-and-skills.md § FETCH-SKILL procedure*.
46
-
47
- 0. **WHEN** — mandatory, twice per matched task:
48
- - **Pre-planning scan**: while planning, check every task's title, summary,
49
- and `file_ownership` against the registry BEFORE the plan is finalized;
50
- fetch any matched skill at that point.
51
- - **Pre-dispatch verification**: immediately before dispatching each worker,
52
- re-verify its match; if the skill is missing from the platform skill dir,
53
- install it before dispatch proceeds.
54
- 1. **MATCH** — read assets/skill-registry.json. Test every task's title,
55
- summary, and file_ownership globs against each entry's `matches` patterns
56
- using case-insensitive substring matching (e.g. a task titled "polish
57
- landing page hero" matches ui-skills via `"landing page"`). One hit = this
58
- procedure is mandatory for that task.
59
- 2. **RESOLVE** — determine the CURRENT platform's skill dir from
60
- references/platforms.md § Skill install paths. That table owns the paths;
61
- never duplicate them here.
62
- 3. **INSTALL once if absent** — cached check first: if the skill is already
63
- present in the resolved platform skill dir, skip reinstall and go to step 4.
64
- Otherwise run the entry's `install` command (generic fallback:
65
- `npx skills add <owner>/<repo>`; `-g` for global; entry-specific commands
66
- like `npx ui-skills get baseline-ui` when present). Then VERIFY presence:
67
- confirm the skill directory/SKILL.md landed where platforms.md says it
68
- should. Fetch happens ONCE per project; later runs are cache hits.
69
- 4. **INTEGRATE** — inject the follow-instruction into (a) the planning context
70
- so tasks reference the skill's standards, and (b) EVERY affected worker
71
- prompt, using this sentence template:
72
-
73
- > `<Domain> work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its standards to every relevant decision.`
74
-
75
- Concrete design instantiation for ui-skills:
76
-
77
- > `Design work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its component/motion/baseline standards to every visual decision.`
78
-
79
- 5. **AUDIT** — workers MUST state in their completion report whether they
80
- followed the injected skill, one auditable line, e.g.:
81
- `Skill compliance: followed ui-skills (<skill-dir>/SKILL.md)` or
82
- `Skill compliance: NOT followed — <reason>`.
83
- 6. **MISSING CAPABILITY** — unmatched-but-obvious domain (user says "make it
84
- pretty" with no registry entry): web-search reputable skill repos, propose
85
- to user, on approval append an entry to the registry (PR or local edit).
86
- Never add registry entries without explicit user approval.
87
-
88
- ## Registry entry shape
89
-
90
- Canonical keys, in order — there are no others. Notably there is NO
91
- `npxCommand` field anywhere in the registry; the executable command lives in
92
- `install` (with optional `direct_fetch`):
93
-
94
- ```json
95
- {
96
- "name": "short-name",
97
- "purpose": "when to reach for it",
98
- "repo": "owner/repo",
99
- "install": "npx skills add owner/repo",
100
- "direct_fetch": "optional per-skill fetch command",
101
- "browse": "optional listing command",
102
- "mcp_endpoint": "optional MCP URL",
103
- "matches": ["frontend", "ui", "design"],
104
- "policy": "required"
105
- }
106
- ```
107
-
108
- - `matches[]`: case-insensitive substrings tested against task titles,
109
- summaries, and file_ownership during the FETCH-SKILL domain scan (step 1).
110
- - `policy` (`required` | `on-demand`) — how mandatory loading is:
111
- - `"required"`: loading is MANDATORY whenever work touches any of the
112
- entry's `matches` domains — pre-planning fetch plus pre-dispatch
113
- verification (FETCH-SKILL steps 0–5 all apply). Currently only ui-skills
114
- carries this; design/UI/frontend work must not proceed without it.
115
- - `"on-demand"`: fetched only when a task explicitly names the installer or
116
- another registry entry lacks a usable command (e.g.
117
- vercel-skills-installer).
@@ -1,292 +0,0 @@
1
- # Orchestration playbook — survey, verify, dispatch
2
-
3
- Sub-agent briefs and the wave-execution mechanics. The orchestrator (SKILL.md)
4
- calls into these sections; workers never read this file.
5
-
6
- ## §survey — brownfield codebase analysis brief
7
-
8
- Dispatch 1–2 sub-agents with this prompt shape:
9
-
10
- ```
11
- TASK: Survey this repository to prepare a feature plan for: <feature request>
12
- DELIVERABLE: write .archgen/<slug>/codebase-map.md containing EXACTLY these
13
- sections:
14
- ## Structure — top-2-levels folder tree w/ one-line purpose each
15
- ## Modules — table: module | responsibility | key entry points
16
- ## Conventions — naming, error-handling, test layout actually observed
17
- ## Affected — files/modules the feature will touch, with evidence paths
18
- SCOPE: read-only. Use codegraph MCP tools when available
19
- (codegraph_explore / codegraph_files); otherwise Glob+Grep systematically.
20
- VERIFY: every claim cites a real path; no guessed APIs.
21
- ```
22
-
23
- Accept the map only if every section is present and non-empty.
24
-
25
- ## §verifier — plan review brief
26
-
27
- Dispatch AFTER artifacts exist and validate.mjs passes.
28
-
29
- ### Agent tier — EVERY verifier dispatch
30
-
31
- Verification is judgment-heavy: a weak verifier misses real defects AND raises
32
- false positives — costing MORE rounds, not fewer. Dispatch on the strongest
33
- reasoning agent the harness offers (best agent present), or a mid/high-tier
34
- sub-agent scaled to plan complexity:
35
-
36
- - SMALL/MEDIUM plan → one strong (mid/high-tier) agent.
37
- - LARGE plan → the stronger/highest tier available.
38
- - NEVER an explore / research / quick / small / cheap / fast sub-agent,
39
- whatever the harness calls its low-end tiers.
40
-
41
- ### Verification pass — FULL-DEPTH, every run
42
-
43
- Each verifier run executes ALL four steps:
44
-
45
- 1. Runs `node <skill>/scripts/verify-plan.mjs .archgen/<slug>/tasks.yaml --plan .archgen/<slug>/plans`
46
- — deterministic floor: cycles, dangling refs, same-wave ownership overlap,
47
- missing acceptance criteria, plan↔task coverage.
48
- 2. When markdown artifacts exist under `.archgen/<slug>/`, runs
49
- `node <skill>/scripts/doc-index.mjs .archgen/<slug> --validate` — must be
50
- clean (zero broken references, exit 0) alongside verify-plan APPROVE;
51
- broken references block APPROVAL.
52
- 3. Reads plans + tasks.yaml and judges what scripts cannot:
53
- - Are wave boundaries sensible (no artificial serialization)?
54
- - Do acceptance criteria objectively verify (command or observable)?
55
- - Edge cases covered per SKILL.md right-sizing class?
56
- - Code-standards compliance plausible for the planned structure?
57
- - CONTRACT-COMPLETENESS sweep — round 1 must confirm OR flag-as-missing
58
- every APPLICABLE dimension (later discovery = the round-1 sweep failed,
59
- not a gap). Apply a dimension only where the system actually has that
60
- concern — skip what genuinely doesn't apply, but NEVER skip a dimension
61
- the system touches:
62
- - **Functional coverage**: every stated requirement/feature has tasks +
63
- objectively verifiable acceptance.
64
- - **Security & data protection** (if it authenticates, authorizes,
65
- encrypts, or handles sensitive data): authn/authz flows, session &
66
- credential lifecycle, replay/CSRF protection, encryption & privacy
67
- boundaries, input validation — each fully specified, not named-and-
68
- skipped.
69
- - **Data integrity**: schemas, relationships, validation, and migration /
70
- back-compat for any persisted state.
71
- - **State, lifecycle & recovery** (if any operation is stateful,
72
- long-running, or multi-step): checkpointing/resume, idempotency,
73
- cleanup, expiry, compensation/rollback semantics.
74
- - **Resource limits & abuse** (if it exposes shared or anonymous
75
- resources): quotas, rate limits, retention/deletion, anonymous-abuse
76
- controls.
77
- - **Operational entrypoints**: every stack-required build/deploy/test/
78
- bootstrap entrypoint is OWNED by some task (no orphan entrypoint).
79
- - **Metric traceability**: every PRD success metric maps to a task
80
- acceptance criterion with a reproducible command / sample size / data
81
- source.
82
- - **Consistency**: actively check cross-contract claims for internal
83
- contradiction (a claim in one artifact that another artifact violates).
84
- These failure classes are the TOP cause of multi-round loops — round 1
85
- MUST sweep the applicable dimensions exhaustively.
86
- 4. Returns EXACTLY one line verdict: `APPROVE` or `ISSUES:` + numbered list.
87
-
88
- ### Efficiency — fewer rounds + zero duplicate work, NEVER shallower checks
89
-
90
- Every run stays FULL-DEPTH: both scripts run to completion and the full
91
- judgment checklist applies each time. Efficiency comes ONLY from:
92
-
93
- - capping automatic rounds at 2 (gate protocol below);
94
- - batching fixes per file (fix discipline below);
95
- - never re-fixing an already-resolved finding.
96
-
97
- "Efficient" NEVER means skipping or lightening verify-plan.mjs, doc-index.mjs,
98
- or any judgment-checklist item.
99
-
100
- ### Fix discipline — batch per file, dedupe repeats
101
-
102
- On `ISSUES:` the orchestrator fixes ALL findings before re-dispatching:
103
-
104
- - Group findings BY FILE; apply each file's fixes in ONE edit pass — open
105
- each file once per round, not once per finding.
106
- - Round N reports the SAME finding as round N-1 (same file + same issue) →
107
- the prior fix did not land: re-read the file and fix it properly — never
108
- re-apply the identical edit.
109
-
110
- ### Gate protocol — 2 automatic rounds, then ask the user
111
-
112
- The initial VERIFIER GATE flow (GENERATE step 5). Rounds 1–2 run
113
- automatically; fix ALL findings between rounds (fix discipline above):
114
-
115
- 1. Round 1: dispatch verifier. `APPROVE` → gate passed → §plan-review.
116
- `ISSUES:` → fix ALL findings → round 2.
117
- 2. Round 2: dispatch verifier.
118
- - Clean `APPROVE` → ask the user once more, recommending NO, proceed.
119
- - `ISSUES:` → fix ALL findings → ask the user once more, recommending
120
- YES, one more pass.
121
- Ask recommendation-first per interview.md § How to ask: "Run the verifier
122
- once more to make sure everything passes?"
123
- 3. On YES → run another round; if it returns `ISSUES:`, fix all and ask again
124
- — every round beyond 2 is user-approved. On NO → proceed to §plan-review.
125
- 4. On NO with findings still outstanding and no verifier `APPROVE` on record:
126
- surface every outstanding finding verbatim and require an EXPLICIT user
127
- waiver — never proceed silently. Hard rule 2 stands: the plan MUST NOT
128
- reach the USER GATE without at least one verifier `APPROVE` (or that
129
- explicit waiver on the record). An earlier `APPROVE` on record → proceed
130
- to §plan-review, noting the latest unverified fixes.
131
-
132
- ## §plan-review — post-plan review stage
133
-
134
- Run AFTER verify-plan returns APPROVE and BEFORE the user gate. Dispatch
135
- REVIEWER sub-agents sized by the right-sizing class — always ONE holistic
136
- review of the WHOLE plan, never per-concern splits:
137
-
138
- - SMALL: main-agent self-review acceptable if no reviewer mechanism exists.
139
- - MEDIUM: 1 reviewer.
140
- - LARGE: 1 holistic reviewer on the strongest reasoning tier. A 2nd reviewer
141
- ONLY if the plan is genuinely too large for one reviewer's context — split
142
- by ARTIFACT/VOLUME then (e.g. plans vs docs), never by concern.
143
-
144
- One holistic reviewer analyzes ALL issues together: cross-issue reasoning
145
- catches contradictions a narrow per-concern slice misses, and one reviewer
146
- costs far fewer tokens than several. NEVER dispatch one sub-agent per
147
- individual issue/concern.
148
-
149
- ```
150
- TASK: Review the plan in .archgen/<slug>/ READ-ONLY.
151
- EXAMINE:
152
- - edge cases per module
153
- - task ordering / parallelization sanity (waves vs real dependencies)
154
- - cross-module contract mismatches (interfaces, paths, naming)
155
- - enhancement recommendations
156
- - documentation completeness
157
- DELIVERABLE: numbered findings list; each finding = what + where + why.
158
- You NEVER edit files. Report only.
159
- ```
160
-
161
- Reviewers are read-only and report-only — they never edit artifacts or code.
162
- The orchestrator fixes the artifacts itself, re-runs validate.mjs +
163
- re-dispatches the verifier gate after every change.
164
-
165
- ### Review loop — bounded passes, then ask
166
-
167
- The fix→re-verify cycle stays, but reviewer passes are countable and bounded:
168
-
169
- 1. Pass 1: holistic review. Zero findings → stage done.
170
- 2. Findings → fix ALL (batched per file), re-run validate.mjs + the verifier
171
- gate → pass 2.
172
- 3. Pass 2 still yields findings → do NOT spawn more reviewers. Consolidate
173
- the outstanding findings and ask the user once, recommendation-first per
174
- interview.md § How to ask: "Run one more targeted review pass on the N
175
- open findings? 1. One more pass (recommended) 2. Waive these findings and
176
- proceed."
177
- 4. On YES → run EXACTLY ONE more pass, then consolidate and STOP. Zero
178
- findings → stage done; findings remain → surface them and require an
179
- explicit user waiver before the user gate. On NO → record the explicit
180
- waiver, proceed.
181
-
182
- A "more review" approval authorizes EXACTLY ONE additional pass — never a
183
- fresh loop, never more reviewers. The stage ends ONLY at zero findings or an
184
- explicit user waiver on record.
185
-
186
- ## §investigate — root-cause protocol
187
-
188
- Triggered when the USER reports repetitive/recurring issues AFTER implementation
189
- waves completed. Do NOT patch-fix under this protocol. Complexity-sized dispatch:
190
-
191
- - SMALL scope: main agent investigates directly.
192
- - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
193
-
194
- Investigators produce ALL four:
195
-
196
- 1. Root cause statement — one sentence naming the actual defect.
197
- 2. Evidence — files/lines/repro steps.
198
- 3. Blast radius — which tasks/artifacts are affected.
199
- 4. Remediation plan — routed through the normal gates: new fix tasks get fresh
200
- ids inheriting the affected task's ownership globs.
201
-
202
- Token discipline: investigators read narrowly around evidence, not whole-repo
203
- sweeps. Patch-fixes without a root-cause statement are forbidden under this
204
- protocol.
205
-
206
- ## §dispatch — wave execution
207
-
208
- Dispatch policy: dispatch each task to the harness's NATIVE sub-agent mechanism
209
- when available AND functional. If sub-agents do not exist on this platform, or
210
- the sub-agent fails, or lacks required tool permissions (read/write/etc.), the
211
- MAIN AGENT executes the task ITSELF — sequentially, respecting waves and
212
- ownership globs. Cross-harness/platform delegation is allowed ONLY through an
213
- explicit user gate (below). There is NO automatic fallback to other harnesses,
214
- platforms, or CLIs — ever.
215
-
216
- ### Native sub-agents (preferred)
217
-
218
- - Claude Code: background Agent tool per task; add worktree isolation for
219
- tasks whose ownership might brush shared files.
220
- - Cursor: background subagents; request isolation when >2 parallel workers.
221
- - Antigravity: invoke_subagent async.
222
- - Codex: spawn_agent works but children can't nest — flatten the plan instead.
223
- - Gemini CLI: parallel @agents are hub-and-spoke only AND have no isolation →
224
- use them ONLY for read-only/research waves unless wrapping in worktrees.
225
-
226
- ### When sub-agents are unavailable or fail
227
-
228
- Detect first — one of:
229
-
230
- - mechanism missing on this platform;
231
- - spawn failure (sub-agent never started / crashed at launch);
232
- - tool-permission gaps (sub-agent runs but cannot read/write/edit files).
233
-
234
- Then, in order:
235
-
236
- 1. DEFAULT — main agent executes the task itself, sequentially, respecting
237
- waves and file_ownership globs. No user permission needed for this.
238
- 2. USER GATE — cross-harness/platform delegation ONLY. When the sub-agent
239
- problem looks platform-specific, STOP and tell the user the concrete issue,
240
- propose using another platform/harness for that specific task (name the
241
- harness + its command shape), and proceed ONLY after the user explicitly
242
- allows it. Log the user's choice in the final report.
243
-
244
- Never silently switch harnesses. Never ask permission to fall back for routine
245
- failures the main agent can simply do itself.
246
-
247
- A sub-agent MECHANISM failure (missing/spawn/permissions) is not a TASK
248
- failure — run the diagnose-and-ask flow above first. Mark a task failed only
249
- after execution was actually attempted (by sub-agent or main agent) and did
250
- not complete.
251
-
252
- Isolation for native sub-agents when ownership borders are tight:
253
-
254
- ```bash
255
- git worktree add ".worktrees/$id" -b "task-$id"
256
- # point the sub-agent's cwd at .worktrees/$id, then merge task-$id on success
257
- ```
258
-
259
- ### Worker prompt contract
260
-
261
- Every worker receives ALL of:
262
-
263
- - task id + title;
264
- - its acceptance criteria VERBATIM;
265
- - its file_ownership globs ("edit NOTHING outside these");
266
- - the code-standards reference (`references/code-standards.md`);
267
- - instruction to run set-status done/failed immediately upon finishing:
268
- `node <skill>/scripts/set-status.mjs .archgen/<slug>/tasks.yaml <id> done|failed`;
269
- - commit guidance: commit completed work scoped to the owned files;
270
- - BEFORE writing code run
271
- `node <skill>/scripts/plan-graph.mjs <slug-dir-or-tasks.yaml> --node <task-id>`
272
- and honor every connected dependency shown;
273
- - all file paths come from tasks.yaml/architecture.yaml VERBATIM — never
274
- reconstruct paths from memory.
275
- - working state goes under `.archgen/<slug>/.agent/` — execution decisions to
276
- `.agent/decisions/`, notes to `.agent/notes/<id>.md` (see
277
- references/artifact-templates.md § Agent workspace & artifact location).
278
- NEVER create ad-hoc note/context/decision folders at the repo root or
279
- anywhere outside `.archgen/`.
280
-
281
- Workers do NOT talk to each other; coordination happens only through
282
- tasks.yaml state.
283
-
284
- ## Failure policy
285
-
286
- - Sub-agent mechanism failure (missing/spawn/permissions) → §dispatch
287
- diagnose-and-ask flow FIRST. It is not yet a task failure.
288
- - Task exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
289
- - Downstream tasks stay blocked by the resolver (blockedByFailure).
290
- - Report to user: failed id, log path, proposed fix-task description.
291
- [wait for user] A fix task gets fresh id, depends_on=[], ownership of the
292
- failed task's globs.