@lifeaitools/rdc-skills 0.9.32 → 0.9.33

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 (55) hide show
  1. package/.claude-plugin/plugin.json +24 -2
  2. package/.github/workflows/self-test.yml +34 -34
  3. package/MANIFEST.md +4 -0
  4. package/commands/build.md +183 -183
  5. package/commands/collab.md +180 -180
  6. package/commands/deploy.md +152 -152
  7. package/commands/fixit.md +116 -104
  8. package/commands/handoff.md +173 -173
  9. package/commands/overnight.md +220 -220
  10. package/commands/plan.md +158 -158
  11. package/commands/preplan.md +131 -131
  12. package/commands/prototype.md +145 -145
  13. package/commands/report.md +99 -99
  14. package/commands/review.md +120 -120
  15. package/commands/status.md +86 -86
  16. package/commands/workitems.md +132 -127
  17. package/guides/agent-bootstrap.md +265 -206
  18. package/guides/agents/backend.md +104 -104
  19. package/guides/agents/content.md +94 -94
  20. package/guides/agents/cs2.md +56 -56
  21. package/guides/agents/data.md +87 -87
  22. package/guides/agents/design.md +77 -77
  23. package/guides/agents/frontend.md +92 -92
  24. package/guides/agents/infrastructure.md +81 -81
  25. package/guides/agents/setup.md +279 -279
  26. package/guides/agents/verify.md +119 -119
  27. package/guides/agents/viz.md +106 -106
  28. package/hooks/foreground-process-gate.js +109 -0
  29. package/hooks/hook-logger.js +25 -0
  30. package/hooks/run-hidden-hook.ps1 +47 -0
  31. package/hooks/work-item-exit-gate.js +297 -0
  32. package/package.json +3 -3
  33. package/rules/work-items-rpc.md +56 -7
  34. package/scripts/install-rdc-skills.js +53 -9
  35. package/scripts/install.ps1 +17 -11
  36. package/scripts/self-test.mjs +1323 -1323
  37. package/skills/build/SKILL.md +355 -355
  38. package/skills/co-develop/SKILL.md +182 -0
  39. package/skills/collab/SKILL.md +217 -217
  40. package/skills/deploy/SKILL.md +198 -198
  41. package/skills/design/SKILL.md +211 -211
  42. package/skills/fixit/SKILL.md +132 -122
  43. package/skills/handoff/SKILL.md +200 -200
  44. package/skills/help/SKILL.md +104 -102
  45. package/skills/overnight/SKILL.md +224 -224
  46. package/skills/plan/SKILL.md +252 -251
  47. package/skills/preplan/SKILL.md +86 -86
  48. package/skills/prototype/SKILL.md +150 -150
  49. package/skills/release/SKILL.md +342 -342
  50. package/skills/report/SKILL.md +100 -100
  51. package/skills/review/SKILL.md +121 -120
  52. package/skills/self-test/SKILL.md +126 -126
  53. package/skills/status/SKILL.md +99 -97
  54. package/skills/watch/SKILL.md +91 -91
  55. package/skills/workitems/SKILL.md +151 -146
@@ -1,355 +1,355 @@
1
- ---
2
- name: rdc:build
3
- description: "You have a planned epic with tasks ready to execute. Dispatches parallel typed agents, each commits atomically to develop, closes work items, and runs the validator gate. Call after rdc:plan or when told to build."
4
- ---
5
-
6
- > **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
7
- > Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
8
- > One checklist upfront, updated in place, shown again at end with a 1-line verdict.
9
-
10
- > **Sandbox contract:** This skill honors `RDC_TEST=1` per `guides/agent-bootstrap.md` § RDC_TEST Sandbox Contract. Destructive external calls short-circuit under the flag.
11
-
12
-
13
- # rdc:build — Typed Agent Dispatch Engine
14
-
15
- ## When to Use
16
- - Plan is approved and ready to execute
17
- - Project lead says "build it", "go", "execute", "do not stop"
18
- - An epic exists with child tasks ready for implementation
19
- - Called by `rdc:overnight` as part of the automated build loop
20
-
21
- ## Arguments
22
- - `rdc:build <epic-id>` — build from a specific Supabase epic
23
- - `rdc:build <topic>` — find the epic by label/title match
24
- - `rdc:build` (no args) — show open epics and ask which to build (interactive only)
25
- - `rdc:build <epic-id> --unattended` — silent mode for overnight builds
26
-
27
- ## Agent Types & Guide Files
28
-
29
- Every dispatched agent MUST read two files before starting — in this order:
30
- 1. `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` — credentials, git rules, completion report format
31
- (fallback: `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` if `.rdc/` does not exist)
32
- 2. `{PROJECT_ROOT}/.rdc/guides/<type>.md` — role-specific guide
33
- (fallback: `{PROJECT_ROOT}/.rdc/guides/<type>.md`)
34
-
35
- Include both lines in every agent prompt:
36
- ```
37
- "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."
38
- ```
39
-
40
- | Agent Type | Guide File | When to dispatch |
41
- |-----------|-----------|-----------------|
42
- | `frontend` | `.rdc/guides/frontend.md` | React components, pages, UI, Tailwind, animation |
43
- | `backend` | `.rdc/guides/backend.md` | API routes, server components, database queries, auth |
44
- | `data` | `.rdc/guides/data.md` | Migrations, schema changes, RPC functions |
45
- | `design` | `.rdc/guides/design.md` | Visual design, brand palettes, OG images, token work |
46
- | `infra` | `.rdc/guides/infrastructure.md` | CI/CD, deployment, DNS, SSL |
47
- | `content` | `.rdc/guides/content.md` | Marketing copy, messaging, tone |
48
- | `cs2` | `.rdc/guides/cs2.md` | CS 2.0 paradigm work (generic) |
49
- | `hail` | `.rdc/guides/cs2.md` + `packages/hail/CLAUDE.md` | Grammar, DSL compiler, evolution |
50
- | `pal` | `.rdc/guides/cs2.md` + `packages/pal/CLAUDE.md` | Sessions, moment windows, graph memory |
51
- | `bpmn` | `.rdc/guides/cs2.md` + `docs/systems/<domain>/flowable-bpmn-architecture.md` | BPMN flows, governance |
52
- | `virtue` | `.rdc/guides/cs2.md` + `packages/virtue-engine/CLAUDE.md` | Virtue weights, coherence, certification |
53
- | `viz` | `.rdc/guides/frontend.md` + `.rdc/guides/design.md` | Custom viz components, charts, diagrams |
54
-
55
- ### How to classify a task → agent type
56
-
57
- Read the task title and description, then:
58
- - Mentions React, component, page, UI, Tailwind → `frontend`
59
- - Mentions API route, server, database query, auth → `backend`
60
- - Mentions migration, schema, table, RPC → `data`
61
- - Mentions brand, palette, typography, OG image → `design`
62
- - Mentions deploy, infrastructure, CI, DNS → `infra`
63
- - Mentions copy, messaging, email template → `content`
64
- - Mentions grammar, DSL, compiler → `hail`
65
- - Mentions session, moment, memory graph → `pal`
66
- - Mentions BPMN, flow, governance → `bpmn`
67
- - Mentions virtue, coherence, certification → `virtue`
68
- - Mentions visualization, chart, diagram, SVG → `viz`
69
- - Multiple types? Dispatch multiple agents, each with its guide.
70
-
71
- ## Procedure
72
-
73
- 1. **Load the epic and run pre-flight gate:**
74
- ```sql
75
- SELECT get_work_items_by_epic('<epic-id>', 'todo');
76
- ```
77
-
78
- **Session lock — claim the epic immediately (before any agent dispatch):**
79
-
80
- After loading the epic, check its status:
81
- - If `status = 'in_progress'` → **ABORT** with:
82
- ```
83
- SKIP: epic <id> is already in_progress — claimed by another session. Pick a different epic.
84
- ```
85
- Do NOT proceed. Do NOT dispatch any agents.
86
- - If `status = 'todo'` or `status = 'blocked'` → immediately claim it:
87
- ```sql
88
- SELECT update_work_item_status('<epic-id>'::uuid, 'in_progress',
89
- '["Claimed by build session — dispatching agents"]'::jsonb
90
- );
91
- ```
92
- This is an atomic Supabase write. A concurrent session that loads the same epic after this point will see `in_progress` and abort. **Do this before any classification, planning, or agent dispatch.**
93
-
94
- **Pre-flight gate — run after claiming:**
95
-
96
- | Condition | Action |
97
- |-----------|--------|
98
- | No child tasks returned | → Invoke `rdc:plan` on this epic. Do NOT proceed with build. |
99
- | Tasks exist but all have empty `description` fields | → Invoke `rdc:plan` on this epic. Tasks without descriptions cannot be safely dispatched. |
100
- | Plan doc missing `## Checklist Decomposition Matrix` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
101
- | Plan doc missing `## Checklist Quality Gate` with `verdict: PASS` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
102
- | Any implementation task lacks `decomp-*` checklist items | → Invoke `rdc:plan` on this epic. Coarse checklists cannot be safely dispatched. |
103
- | Any `decomp-*` item lacks route/file, action, expected result, or evidence artifact | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
104
- | Tasks exist and have descriptions | → Continue with build. |
105
-
106
- **Re-planning is not a failure — it is correct behavior.** The build skill is the last gate before agent dispatch; catching an under-specified epic here is cheaper than a wasted agent run.
107
-
108
- **How to re-plan:**
109
- - Interactive: tell the user — "Epic has no tasks / tasks lack descriptions — invoking rdc:plan first." Then invoke `rdc:plan <epic-id>`.
110
- - Unattended: invoke `rdc:plan <epic-id> --unattended` inline, wait for it to complete, then reload tasks and re-run this gate once. If tasks still missing after re-plan, escalate via advisor.
111
-
112
- **Interactive (no args):** show open epics, ask which to build.
113
-
114
- 2. **CHECK FOR EXISTING WORK (mandatory — never skip):**
115
- ```sql
116
- -- Check if prototypes exist from earlier sessions
117
- SELECT name, component, source_path, status, notes
118
- FROM prototype_registry
119
- WHERE status IN ('prototype', 'converting')
120
- ORDER BY created_at DESC;
121
-
122
- -- Check for design decisions on this topic
123
- SELECT topic, context_type, summary, source
124
- FROM design_context
125
- WHERE topic ILIKE '%<epic-topic>%'
126
- ORDER BY created_at DESC;
127
- ```
128
- **If a prototype exists: ADAPT IT. Do not build from scratch.**
129
- Tell the agent: "Read <source_path> first and convert it to the production contract."
130
-
131
- **If design decisions exist: follow them.** Include the summary in the agent prompt.
132
-
133
- 3. **Load the plan** (mandatory): check `.rdc/plans/` for matching topic (fallback: `.rdc/plans/`).
134
-
135
- 3b. **Checklist decomposition quality gate (mandatory before code):**
136
-
137
- `rdc:build` is the final gate before implementation. It MUST reject any plan or work item that is too coarse for an agent to execute and verify independently.
138
-
139
- Required plan sections:
140
- - `## Checklist Decomposition Matrix`
141
- - `## Checklist Quality Gate`
142
- - `verdict: PASS`
143
-
144
- Required task checklist shape:
145
- - Every implementation work item has at least one `decomp-*` checklist row and one `test-*` checklist row.
146
- - Every `decomp-*` row names a concrete route or file path.
147
- - Every `decomp-*` row names one user/agent action.
148
- - Every `decomp-*` row names one expected UI/API/DB result.
149
- - Every `decomp-*` row names one verification artifact: test name, route probe, Playwright screenshot, SQL query, API response, type-check, migration proof, or CLI transcript.
150
-
151
- Atomicity rubric:
152
- - One observable behavior per `decomp-*` row.
153
- - The row can pass or fail without reading hidden intent from the plan narrative.
154
- - The row is small enough for a worker to implement, tick, and cite evidence for directly.
155
- - Vague rows such as "theme management works", "UI implemented", "verified", "all screens", or "integration complete" are failures.
156
-
157
- Minimum decomposition heuristics:
158
- - UI route: at least empty/loading/loaded/error or the documented reason a state does not apply.
159
- - CRUD surface: at least list, create, edit, detail, duplicate/delete/archive where applicable, and validation failure.
160
- - API route: at least successful read/write, validation failure, and unauthorized/forbidden or documented auth bypass.
161
- - DB/migration task: at least schema object, relationship/guard, policy/permission, seed/fixture or backfill, and smoke query.
162
- - Editor/sidebar/CLI workflow: at least start, attach/open, enqueue action, observe result, timeout/error, and live refresh where applicable.
163
-
164
- If the gate fails:
165
- - Interactive: show the failing rows and invoke `rdc:plan <epic-id>` to repair the matrix before dispatch.
166
- - Unattended: invoke `rdc:plan <epic-id> --unattended`, reload tasks, and run this gate once more.
167
- - If the second gate fails, abort the build and return the failure list. Do not dispatch implementation agents.
168
-
169
- **Plan verifier escalation:** A separate verifier agent is optional, not default. Dispatch one only when the plan touches 5+ UI routes, 3+ data/API boundaries, auth/security, production deployment, or when this rubric fails twice. The verifier reads the plan and work-item checklists only; it does not write code.
170
-
171
- 4. **Read CLAUDE.md files** for all affected packages.
172
-
173
- 5. **Classify each task** → assign agent type from the table above.
174
-
175
- 5b. **Write or refresh the checklist into every work item before dispatching:**
176
- For each task, append the exact `decomp-*` and `test-*` checklist rows to its notes BEFORE setting to `in_progress`:
177
- ```sql
178
- SELECT update_work_item_status('<id>'::uuid, 'in_progress',
179
- '["CHECKLIST: [ ] decomp-ui-route-state: <route/file> | action=<action> | expect=<result> | evidence=<artifact>, [ ] test-smoke-route: <route probe>, [ ] committed"]'::jsonb
180
- );
181
- ```
182
- The agent must complete every item on this checklist and return it checked off in AGENT_COMPLETE.
183
- A checklist with unchecked items = incomplete work. Do not proceed to next wave with unchecked items.
184
-
185
- 6. **Group tasks into waves** — parallelize tasks with no file overlap:
186
- - Wave 1: independent tasks (different packages/files)
187
- - Wave 2: tasks that depend on Wave 1 outputs
188
- - Wave 3: integration tasks
189
-
190
- 7. **For each wave — dispatch typed agents in parallel:**
191
-
192
- ### ⛔ Agent Dispatch Non-Negotiable Defaults
193
- Every `Agent()` call MUST include these parameters — no exceptions:
194
- ```
195
- model: "sonnet"
196
- max_turns: 70
197
- isolation: "worktree"
198
- ```
199
- Agents run Sonnet 4.6 — capable for implementation work, budget-safe for parallel dispatch. The supervisor session model does NOT cascade to agents; you must set it explicitly.
200
- Without `max_turns: 70`, agents hit the default turn cap mid-task and stop.
201
- `isolation: "worktree"` gives each agent its own git worktree and branch — eliminates push race conditions and index lock contention when multiple agents commit in parallel. The supervisor merges worktree branches after each wave (Step 9).
202
-
203
- ### Forked agents vs. standalone agents
204
-
205
- **When the supervisor has already read the plan** (via a prior `Read` tool call in the same session),
206
- dispatch **forked agents** with short prompts. Forked agents inherit the full conversation context —
207
- including every file the supervisor has read — so you do NOT need to copy plan sections, file specs,
208
- or architecture details into the prompt. The agent already sees them.
209
-
210
- Short forked prompt template:
211
- ```
212
- You are a frontend agent building <WP name>. Work item: <uuid>.
213
- Scope: <one sentence>. Files: <list>. Verification: tsc --noEmit.
214
- Set item to review when done, return AGENT_COMPLETE with verification evidence.
215
- Read .rdc/guides/agent-bootstrap.md + .rdc/guides/frontend.md before starting.
216
- ```
217
-
218
- **When the supervisor has NOT read the plan** (e.g. dispatching from a fresh `rdc:build` call with
219
- only an epic ID), the agent has no plan context — write a full briefing prompt with all specs.
220
-
221
- ---
222
-
223
- ### Required agent prompt contents
224
- - Set work item to `in_progress` before dispatching
225
- - Each agent prompt MUST include:
226
- - `"Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."`
227
- - Specific files to create/modify (or omit if forked agent inherits plan context)
228
- - Exact deliverables and commit message
229
- - `"NEVER run pnpm build/test. NEVER modify files outside your scope."`
230
- - **`"You are running in an isolated git worktree. Commit your work normally. Do NOT push to origin — the supervisor merges your branch after the wave completes."`**
231
- - **`"When done, set your work item to 'review' (NOT 'done') and return AGENT_COMPLETE with a verification field. The validator closes work items — you do not."`**
232
- - **`"COMPLETION PROOF REQUIRED in AGENT_COMPLETE: list every file written, the exact commit hash, and paste the vitest/tsc output. A report without this evidence will be rejected."`**
233
- - **`"If you find that a file or feature already exists: you MUST still verify it satisfies the full task spec before marking review. Finding a file is not completion. Run verification, check every requirement, and report what you found vs. what was required."`**
234
- - **The decomposition items from the work item's checklist** (all `decomp-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
235
- ```
236
- DECOMPOSITION CHECKLIST — you MUST implement/verify each row and tick it immediately via update_checklist_item:
237
- - decomp-ui-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
238
- - decomp-api-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
239
- Tick each item as soon as that specific behavior is implemented and proven. Do NOT batch.
240
- ```
241
- - **The test plan items from the work item's checklist** (all `test-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
242
- ```
243
- TEST PLAN — you MUST implement/verify each of these and tick them off via update_checklist_item:
244
- - test-assert-xxx: <description> → write a vitest test that proves this
245
- - test-smoke-xxx: <description> → run the command and confirm the result
246
- - test-visual-xxx: <description> → note: delegate to UI audit (you cannot verify this yourself)
247
- - test-contract-xxx: <description> → verify the export/type/shape exists
248
- Tick each item as you complete it. Do NOT batch — tick immediately after each verification.
249
- ```
250
- - Use `run_in_background: true` for parallel execution
251
- - NEVER let agents overlap on the same files
252
-
253
- 8. **Post-wave test gate (mandatory):**
254
- After all agents in a wave complete, before proceeding:
255
- ```bash
256
- # For each package modified in this wave:
257
- cd packages/<name> && npx vitest run 2>&1 | tail -20
258
- ```
259
- - All tests must pass before proceeding to next wave
260
- - If tests fail: fix before proceeding
261
- - NEVER use `pnpm build` or `pnpm turbo test` — vitest only per package
262
- - New code must have tests: if a modified package shows 0 new test files, flag it
263
-
264
- 9. **After all wave agents complete — merge worktrees and push:**
265
-
266
- Each completed agent returns a worktree branch (e.g. `claude/agent-frontend-abc123`). Merge them all to develop before running the test gate:
267
-
268
- ```bash
269
- # For each worktree branch returned by agents in this wave:
270
- git merge --no-ff <worktree-branch> -m "merge(<agent-type>): <task-title>"
271
- ```
272
-
273
- - Resolve any conflicts before proceeding — do not skip
274
- - Worker agents set items to `review` — **do NOT close to `done` yet**
275
- - After all branches merged, push once:
276
- ```bash
277
- if [ "$RDC_TEST" != "1" ]; then
278
- git push origin develop
279
- else
280
- echo "[RDC_TEST] skipping git push"
281
- fi
282
- ```
283
- - Then run the post-wave test gate (Step 8) on the merged state
284
- - Continue to next wave
285
-
286
- **If an agent fails (returns no worktree branch):**
287
- - Interactive: diagnose before retrying
288
- - Unattended: retry once; on second failure escalate via advisor
289
- ```
290
- BUILD_STATUS: { wave, tasks_done, tasks_failed, commits, escalated: true }
291
- ```
292
-
293
- 10. **Mandatory validator gate (runs after ALL waves complete — before any work item closes):**
294
-
295
- ⛔ **NO work item may be set to `done` without the validator passing it.**
296
-
297
- Dispatch ONE validator agent with the complete list of `review` work items and the full git diff.
298
- ⚠️ The validator does NOT use `isolation: "worktree"` — it must read the fully merged develop branch. Omit the isolation parameter for this dispatch only.
299
-
300
- ```
301
- "Read C:/Dev/regen-root/.rdc/guides/agent-bootstrap.md then C:/Dev/regen-root/.rdc/guides/verify.md.
302
- Validate these work items: [list of IDs and titles].
303
- Apps touched: [list].
304
- Git diff since build start: [attach or reference].
305
- You are the ONLY agent that closes work items to done.
306
- Follow verify.md procedure exactly: tsc → vitest → dev server route probes → record result per item."
307
- ```
308
-
309
- The validator:
310
- - Runs `npx tsc --noEmit` for every touched app/package
311
- - Starts the dev server and probes every modified route (expects HTTP 200, not 500)
312
- - Runs vitest for every touched package
313
- - **Verifies checklist decomposition quality per work item before functional validation:**
314
- - Every implementation work item has at least one `decomp-*` item and one `test-*` item
315
- - Every `decomp-*` item includes route/file, action, expected result, and evidence artifact
316
- - Any unchecked `decomp-*` item with `required: true` = work item CANNOT be set to `done`
317
- - Any coarse or non-falsifiable `decomp-*` item = reopen to `todo` with the specific failure
318
- - **Verifies test plan completion per work item:**
319
- - For each `test-assert-*` checklist item: confirm a corresponding vitest test exists and passes
320
- - For each `test-smoke-*` checklist item: run the command and confirm exit code / HTTP status
321
- - For each `test-visual-*` checklist item: note as "delegated to UI audit" (validator cannot verify visuals)
322
- - For each `test-contract-*` checklist item: verify the export/type/shape exists in the built code
323
- - Any unchecked `test-*` item with `required: true` = work item CANNOT be set to `done` (DB enforces this)
324
- - Sets passing items to `done`, failing items back to `todo` with failure detail
325
- - Returns `VALIDATOR_COMPLETE` report with test plan status per item
326
-
327
- **If the validator finds failures:** fix them in a new wave, then re-run the validator. Do not skip.
328
- **File existence alone is NOT verification.** A route returning 500 is a failure regardless of tsc passing.
329
- **Unchecked test plan items are a hard gate** — `update_work_item_status('done')` will raise an exception if any `required: true` checklist item is unchecked.
330
-
331
- 11. **After verification passes:**
332
- - All wave commits are already on develop and pushed (Step 9 pushes after each wave merge).
333
- - Update epic version: `bump_epic_version()`
334
- - Report summary with verification evidence quoted
335
-
336
- ## Agent TDD Requirements
337
-
338
- When dispatching agents, include in every prompt:
339
- ```
340
- TDD REQUIREMENT: Write tests FIRST for new functions/modules.
341
- Run: npx vitest run packages/<name> to verify red → implement → verify green.
342
- NEVER run pnpm build or pnpm turbo. Use npx vitest run only.
343
- ```
344
-
345
- ## Rules
346
- - Branch: development branch only (auto-commit, no confirmation needed)
347
- - NEVER let two agents edit the same file
348
- - NEVER run `pnpm build` (crashes system) — code only
349
- - Every agent reads its guide file — no exceptions
350
- - Update Supabase work items IN REAL TIME — not batch at end
351
- - Push after each wave, not just at the end
352
- - Unattended: NEVER pause — continue automatically
353
- - Unattended: max 2 retries per task before escalating to advisor
354
- - Every Agent() dispatch: `model: "sonnet"` + `max_turns: 70` + `isolation: "worktree"` — non-negotiable (Sonnet agents, Opus supervisor). Exception: validator agent in Step 10 omits isolation.
355
- - Finding an existing file is NOT task completion — verify it satisfies the spec
1
+ ---
2
+ name: rdc:build
3
+ description: "Usage `rdc:build <epic-id>` — You have a planned epic with tasks ready to execute. Dispatches parallel typed agents, each commits atomically to develop, closes work items, and runs the validator gate. Call after rdc:plan or when told to build."
4
+ ---
5
+
6
+ > **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
7
+ > Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
8
+ > One checklist upfront, updated in place, shown again at end with a 1-line verdict.
9
+
10
+ > **Sandbox contract:** This skill honors `RDC_TEST=1` per `guides/agent-bootstrap.md` § RDC_TEST Sandbox Contract. Destructive external calls short-circuit under the flag.
11
+
12
+
13
+ # rdc:build — Typed Agent Dispatch Engine
14
+
15
+ ## When to Use
16
+ - Plan is approved and ready to execute
17
+ - Project lead says "build it", "go", "execute", "do not stop"
18
+ - An epic exists with child tasks ready for implementation
19
+ - Called by `rdc:overnight` as part of the automated build loop
20
+
21
+ ## Arguments
22
+ - `rdc:build <epic-id>` — build from a specific Supabase epic
23
+ - `rdc:build <topic>` — find the epic by label/title match
24
+ - `rdc:build` (no args) — show open epics and ask which to build (interactive only)
25
+ - `rdc:build <epic-id> --unattended` — silent mode for overnight builds
26
+
27
+ ## Agent Types & Guide Files
28
+
29
+ Every dispatched agent MUST read two files before starting — in this order:
30
+ 1. `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` — credentials, git rules, completion report format
31
+ (fallback: `.rdc/guides/agent-bootstrap.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
32
+ 2. `{PROJECT_ROOT}/.rdc/guides/<type>.md` — role-specific guide
33
+ (fallback: `.rdc/guides/<type>.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
34
+
35
+ Include both lines in every agent prompt:
36
+ ```
37
+ "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."
38
+ ```
39
+
40
+ | Agent Type | Guide File | When to dispatch |
41
+ |-----------|-----------|-----------------|
42
+ | `frontend` | `.rdc/guides/frontend.md` | React components, pages, UI, Tailwind, animation |
43
+ | `backend` | `.rdc/guides/backend.md` | API routes, server components, database queries, auth |
44
+ | `data` | `.rdc/guides/data.md` | Migrations, schema changes, RPC functions |
45
+ | `design` | `.rdc/guides/design.md` | Visual design, brand palettes, OG images, token work |
46
+ | `infra` | `.rdc/guides/infrastructure.md` | CI/CD, deployment, DNS, SSL |
47
+ | `content` | `.rdc/guides/content.md` | Marketing copy, messaging, tone |
48
+ | `cs2` | `.rdc/guides/cs2.md` | CS 2.0 paradigm work (generic) |
49
+ | `hail` | `.rdc/guides/cs2.md` + `packages/hail/CLAUDE.md` | Grammar, DSL compiler, evolution |
50
+ | `pal` | `.rdc/guides/cs2.md` + `packages/pal/CLAUDE.md` | Sessions, moment windows, graph memory |
51
+ | `bpmn` | `.rdc/guides/cs2.md` + `docs/systems/<domain>/flowable-bpmn-architecture.md` | BPMN flows, governance |
52
+ | `virtue` | `.rdc/guides/cs2.md` + `packages/virtue-engine/CLAUDE.md` | Virtue weights, coherence, certification |
53
+ | `viz` | `.rdc/guides/frontend.md` + `.rdc/guides/design.md` | Custom viz components, charts, diagrams |
54
+
55
+ ### How to classify a task → agent type
56
+
57
+ Read the task title and description, then:
58
+ - Mentions React, component, page, UI, Tailwind → `frontend`
59
+ - Mentions API route, server, database query, auth → `backend`
60
+ - Mentions migration, schema, table, RPC → `data`
61
+ - Mentions brand, palette, typography, OG image → `design`
62
+ - Mentions deploy, infrastructure, CI, DNS → `infra`
63
+ - Mentions copy, messaging, email template → `content`
64
+ - Mentions grammar, DSL, compiler → `hail`
65
+ - Mentions session, moment, memory graph → `pal`
66
+ - Mentions BPMN, flow, governance → `bpmn`
67
+ - Mentions virtue, coherence, certification → `virtue`
68
+ - Mentions visualization, chart, diagram, SVG → `viz`
69
+ - Multiple types? Dispatch multiple agents, each with its guide.
70
+
71
+ ## Procedure
72
+
73
+ 1. **Load the epic and run pre-flight gate:**
74
+ ```sql
75
+ SELECT get_work_items_by_epic('<epic-id>', 'todo');
76
+ ```
77
+
78
+ **Session lock — claim the epic immediately (before any agent dispatch):**
79
+
80
+ After loading the epic, check its status:
81
+ - If `status = 'in_progress'` → **ABORT** with:
82
+ ```
83
+ SKIP: epic <id> is already in_progress — claimed by another session. Pick a different epic.
84
+ ```
85
+ Do NOT proceed. Do NOT dispatch any agents.
86
+ - If `status = 'todo'` or `status = 'blocked'` → immediately claim it:
87
+ ```sql
88
+ SELECT update_work_item_status('<epic-id>'::uuid, 'in_progress',
89
+ '["Claimed by build session — dispatching agents"]'::jsonb
90
+ );
91
+ ```
92
+ This is an atomic Supabase write. A concurrent session that loads the same epic after this point will see `in_progress` and abort. **Do this before any classification, planning, or agent dispatch.**
93
+
94
+ **Pre-flight gate — run after claiming:**
95
+
96
+ | Condition | Action |
97
+ |-----------|--------|
98
+ | No child tasks returned | → Invoke `rdc:plan` on this epic. Do NOT proceed with build. |
99
+ | Tasks exist but all have empty `description` fields | → Invoke `rdc:plan` on this epic. Tasks without descriptions cannot be safely dispatched. |
100
+ | Plan doc missing `## Checklist Decomposition Matrix` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
101
+ | Plan doc missing `## Checklist Quality Gate` with `verdict: PASS` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
102
+ | Any implementation task lacks `decomp-*` checklist items | → Invoke `rdc:plan` on this epic. Coarse checklists cannot be safely dispatched. |
103
+ | Any `decomp-*` item lacks route/file, action, expected result, or evidence artifact | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
104
+ | Tasks exist and have descriptions | → Continue with build. |
105
+
106
+ **Re-planning is not a failure — it is correct behavior.** The build skill is the last gate before agent dispatch; catching an under-specified epic here is cheaper than a wasted agent run.
107
+
108
+ **How to re-plan:**
109
+ - Interactive: tell the user — "Epic has no tasks / tasks lack descriptions — invoking rdc:plan first." Then invoke `rdc:plan <epic-id>`.
110
+ - Unattended: invoke `rdc:plan <epic-id> --unattended` inline, wait for it to complete, then reload tasks and re-run this gate once. If tasks still missing after re-plan, escalate via advisor.
111
+
112
+ **Interactive (no args):** show open epics, ask which to build.
113
+
114
+ 2. **CHECK FOR EXISTING WORK (mandatory — never skip):**
115
+ ```sql
116
+ -- Check if prototypes exist from earlier sessions
117
+ SELECT name, component, source_path, status, notes
118
+ FROM prototype_registry
119
+ WHERE status IN ('prototype', 'converting')
120
+ ORDER BY created_at DESC;
121
+
122
+ -- Check for design decisions on this topic
123
+ SELECT topic, context_type, summary, source
124
+ FROM design_context
125
+ WHERE topic ILIKE '%<epic-topic>%'
126
+ ORDER BY created_at DESC;
127
+ ```
128
+ **If a prototype exists: ADAPT IT. Do not build from scratch.**
129
+ Tell the agent: "Read <source_path> first and convert it to the production contract."
130
+
131
+ **If design decisions exist: follow them.** Include the summary in the agent prompt.
132
+
133
+ 3. **Load the plan** (mandatory): check `.rdc/plans/` for matching topic (fallback: `.rdc/plans/`).
134
+
135
+ 3b. **Checklist decomposition quality gate (mandatory before code):**
136
+
137
+ `rdc:build` is the final gate before implementation. It MUST reject any plan or work item that is too coarse for an agent to execute and verify independently.
138
+
139
+ Required plan sections:
140
+ - `## Checklist Decomposition Matrix`
141
+ - `## Checklist Quality Gate`
142
+ - `verdict: PASS`
143
+
144
+ Required task checklist shape:
145
+ - Every implementation work item has at least one `decomp-*` checklist row and one `test-*` checklist row.
146
+ - Every `decomp-*` row names a concrete route or file path.
147
+ - Every `decomp-*` row names one user/agent action.
148
+ - Every `decomp-*` row names one expected UI/API/DB result.
149
+ - Every `decomp-*` row names one verification artifact: test name, route probe, Playwright screenshot, SQL query, API response, type-check, migration proof, or CLI transcript.
150
+
151
+ Atomicity rubric:
152
+ - One observable behavior per `decomp-*` row.
153
+ - The row can pass or fail without reading hidden intent from the plan narrative.
154
+ - The row is small enough for a worker to implement, tick, and cite evidence for directly.
155
+ - Vague rows such as "theme management works", "UI implemented", "verified", "all screens", or "integration complete" are failures.
156
+
157
+ Minimum decomposition heuristics:
158
+ - UI route: at least empty/loading/loaded/error or the documented reason a state does not apply.
159
+ - CRUD surface: at least list, create, edit, detail, duplicate/delete/archive where applicable, and validation failure.
160
+ - API route: at least successful read/write, validation failure, and unauthorized/forbidden or documented auth bypass.
161
+ - DB/migration task: at least schema object, relationship/guard, policy/permission, seed/fixture or backfill, and smoke query.
162
+ - Editor/sidebar/CLI workflow: at least start, attach/open, enqueue action, observe result, timeout/error, and live refresh where applicable.
163
+
164
+ If the gate fails:
165
+ - Interactive: show the failing rows and invoke `rdc:plan <epic-id>` to repair the matrix before dispatch.
166
+ - Unattended: invoke `rdc:plan <epic-id> --unattended`, reload tasks, and run this gate once more.
167
+ - If the second gate fails, abort the build and return the failure list. Do not dispatch implementation agents.
168
+
169
+ **Plan verifier escalation:** A separate verifier agent is optional, not default. Dispatch one only when the plan touches 5+ UI routes, 3+ data/API boundaries, auth/security, production deployment, or when this rubric fails twice. The verifier reads the plan and work-item checklists only; it does not write code.
170
+
171
+ 4. **Read CLAUDE.md files** for all affected packages.
172
+
173
+ 5. **Classify each task** → assign agent type from the table above.
174
+
175
+ 5b. **Write or refresh the checklist into every work item before dispatching:**
176
+ For each task, append the exact `decomp-*` and `test-*` checklist rows to its notes BEFORE setting to `in_progress`:
177
+ ```sql
178
+ SELECT update_work_item_status('<id>'::uuid, 'in_progress',
179
+ '["CHECKLIST: [ ] decomp-ui-route-state: <route/file> | action=<action> | expect=<result> | evidence=<artifact>, [ ] test-smoke-route: <route probe>, [ ] committed"]'::jsonb
180
+ );
181
+ ```
182
+ The agent must complete every item on this checklist and return it checked off in AGENT_COMPLETE.
183
+ A checklist with unchecked items = incomplete work. Do not proceed to next wave with unchecked items.
184
+
185
+ 6. **Group tasks into waves** — parallelize tasks with no file overlap:
186
+ - Wave 1: independent tasks (different packages/files)
187
+ - Wave 2: tasks that depend on Wave 1 outputs
188
+ - Wave 3: integration tasks
189
+
190
+ 7. **For each wave — dispatch typed agents in parallel:**
191
+
192
+ ### ⛔ Agent Dispatch Non-Negotiable Defaults
193
+ Every `Agent()` call MUST include these parameters — no exceptions:
194
+ ```
195
+ model: "sonnet"
196
+ max_turns: 70
197
+ isolation: "worktree"
198
+ ```
199
+ Agents run Sonnet 4.6 — capable for implementation work, budget-safe for parallel dispatch. The supervisor session model does NOT cascade to agents; you must set it explicitly.
200
+ Without `max_turns: 70`, agents hit the default turn cap mid-task and stop.
201
+ `isolation: "worktree"` gives each agent its own git worktree and branch — eliminates push race conditions and index lock contention when multiple agents commit in parallel. The supervisor merges worktree branches after each wave (Step 9).
202
+
203
+ ### Forked agents vs. standalone agents
204
+
205
+ **When the supervisor has already read the plan** (via a prior `Read` tool call in the same session),
206
+ dispatch **forked agents** with short prompts. Forked agents inherit the full conversation context —
207
+ including every file the supervisor has read — so you do NOT need to copy plan sections, file specs,
208
+ or architecture details into the prompt. The agent already sees them.
209
+
210
+ Short forked prompt template:
211
+ ```
212
+ You are a frontend agent building <WP name>. Work item: <uuid>.
213
+ Scope: <one sentence>. Files: <list>. Verification: tsc --noEmit.
214
+ Set item to review when done, return AGENT_COMPLETE with verification evidence.
215
+ Read .rdc/guides/agent-bootstrap.md + .rdc/guides/frontend.md before starting.
216
+ ```
217
+
218
+ **When the supervisor has NOT read the plan** (e.g. dispatching from a fresh `rdc:build` call with
219
+ only an epic ID), the agent has no plan context — write a full briefing prompt with all specs.
220
+
221
+ ---
222
+
223
+ ### Required agent prompt contents
224
+ - Set work item to `in_progress` before dispatching
225
+ - Each agent prompt MUST include:
226
+ - `"Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."`
227
+ - Specific files to create/modify (or omit if forked agent inherits plan context)
228
+ - Exact deliverables and commit message
229
+ - `"NEVER run pnpm build/test. NEVER modify files outside your scope."`
230
+ - **`"You are running in an isolated git worktree. Commit your work normally. Do NOT push to origin — the supervisor merges your branch after the wave completes."`**
231
+ - **`"When done, set your work item to 'review' (NOT 'done') and return AGENT_COMPLETE with a verification field. The validator closes work items — you do not."`**
232
+ - **`"COMPLETION PROOF REQUIRED in AGENT_COMPLETE: list every file written, the exact commit hash, and paste the vitest/tsc output. A report without this evidence will be rejected."`**
233
+ - **`"If you find that a file or feature already exists: you MUST still verify it satisfies the full task spec before marking review. Finding a file is not completion. Run verification, check every requirement, and report what you found vs. what was required."`**
234
+ - **The decomposition items from the work item's checklist** (all `decomp-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
235
+ ```
236
+ DECOMPOSITION CHECKLIST — you MUST implement/verify each row and tick it immediately via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
237
+ - decomp-ui-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
238
+ - decomp-api-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
239
+ Tick each item as soon as that specific behavior is implemented and proven. Do NOT batch.
240
+ ```
241
+ - **The test plan items from the work item's checklist** (all `test-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
242
+ ```
243
+ TEST PLAN — you MUST implement/verify each of these and tick them off via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
244
+ - test-assert-xxx: <description> → write a vitest test that proves this
245
+ - test-smoke-xxx: <description> → run the command and confirm the result
246
+ - test-visual-xxx: <description> → note: delegate to UI audit (you cannot verify this yourself)
247
+ - test-contract-xxx: <description> → verify the export/type/shape exists
248
+ Tick each item as you complete it. Do NOT batch — tick immediately after each verification.
249
+ ```
250
+ - Use `run_in_background: true` for parallel execution
251
+ - NEVER let agents overlap on the same files
252
+
253
+ 8. **Post-wave test gate (mandatory):**
254
+ After all agents in a wave complete, before proceeding:
255
+ ```bash
256
+ # For each package modified in this wave:
257
+ cd packages/<name> && npx vitest run 2>&1 | tail -20
258
+ ```
259
+ - All tests must pass before proceeding to next wave
260
+ - If tests fail: fix before proceeding
261
+ - NEVER use `pnpm build` or `pnpm turbo test` — vitest only per package
262
+ - New code must have tests: if a modified package shows 0 new test files, flag it
263
+
264
+ 9. **After all wave agents complete — merge worktrees and push:**
265
+
266
+ Each completed agent returns a worktree branch (e.g. `claude/agent-frontend-abc123`). Merge them all to develop before running the test gate:
267
+
268
+ ```bash
269
+ # For each worktree branch returned by agents in this wave:
270
+ git merge --no-ff <worktree-branch> -m "merge(<agent-type>): <task-title>"
271
+ ```
272
+
273
+ - Resolve any conflicts before proceeding — do not skip
274
+ - Worker agents set items to `review` — **do NOT close to `done` yet**
275
+ - After all branches merged, push once:
276
+ ```bash
277
+ if [ "$RDC_TEST" != "1" ]; then
278
+ git push origin develop
279
+ else
280
+ echo "[RDC_TEST] skipping git push"
281
+ fi
282
+ ```
283
+ - Then run the post-wave test gate (Step 8) on the merged state
284
+ - Continue to next wave
285
+
286
+ **If an agent fails (returns no worktree branch):**
287
+ - Interactive: diagnose before retrying
288
+ - Unattended: retry once; on second failure escalate via advisor
289
+ ```
290
+ BUILD_STATUS: { wave, tasks_done, tasks_failed, commits, escalated: true }
291
+ ```
292
+
293
+ 10. **Mandatory validator gate (runs after ALL waves complete — before any work item closes):**
294
+
295
+ ⛔ **NO work item may be set to `done` without the validator passing it.**
296
+
297
+ Dispatch ONE validator agent with the complete list of `review` work items and the full git diff.
298
+ ⚠️ The validator does NOT use `isolation: "worktree"` — it must read the fully merged develop branch. Omit the isolation parameter for this dispatch only.
299
+
300
+ ```
301
+ "Read C:/Dev/regen-root/.rdc/guides/agent-bootstrap.md then C:/Dev/regen-root/.rdc/guides/verify.md.
302
+ Validate these work items: [list of IDs and titles].
303
+ Apps touched: [list].
304
+ Git diff since build start: [attach or reference].
305
+ You are the ONLY agent that closes work items to done.
306
+ Follow verify.md procedure exactly: tsc → vitest → dev server route probes → record result per item."
307
+ ```
308
+
309
+ The validator:
310
+ - Runs `npx tsc --noEmit` for every touched app/package
311
+ - Starts the dev server and probes every modified route (expects HTTP 200, not 500)
312
+ - Runs vitest for every touched package
313
+ - **Verifies checklist decomposition quality per work item before functional validation:**
314
+ - Every implementation work item has at least one `decomp-*` item and one `test-*` item
315
+ - Every `decomp-*` item includes route/file, action, expected result, and evidence artifact
316
+ - Any unchecked `decomp-*` item with `required: true` = work item CANNOT be set to `done`
317
+ - Any coarse or non-falsifiable `decomp-*` item = reopen to `todo` with the specific failure
318
+ - **Verifies test plan completion per work item:**
319
+ - For each `test-assert-*` checklist item: confirm a corresponding vitest test exists and passes
320
+ - For each `test-smoke-*` checklist item: run the command and confirm exit code / HTTP status
321
+ - For each `test-visual-*` checklist item: note as "delegated to UI audit" (validator cannot verify visuals)
322
+ - For each `test-contract-*` checklist item: verify the export/type/shape exists in the built code
323
+ - Any unchecked `test-*` item with `required: true` = work item CANNOT be set to `done` (DB enforces this)
324
+ - Sets passing items to `done`, failing items back to `todo` with failure detail
325
+ - Returns `VALIDATOR_COMPLETE` report with test plan status per item
326
+
327
+ **If the validator finds failures:** fix them in a new wave, then re-run the validator. Do not skip.
328
+ **File existence alone is NOT verification.** A route returning 500 is a failure regardless of tsc passing.
329
+ **Unchecked test plan items are a hard gate** — `update_work_item_status('done', ..., p_actor_role := 'validator')` will raise an exception if any `required: true` checklist item is unchecked, missing agent-session tick evidence, or re-ticked by a supervisor/validator.
330
+
331
+ 11. **After verification passes:**
332
+ - All wave commits are already on develop and pushed (Step 9 pushes after each wave merge).
333
+ - Update epic version: `bump_epic_version()`
334
+ - Report summary with verification evidence quoted
335
+
336
+ ## Agent TDD Requirements
337
+
338
+ When dispatching agents, include in every prompt:
339
+ ```
340
+ TDD REQUIREMENT: Write tests FIRST for new functions/modules.
341
+ Run: npx vitest run packages/<name> to verify red → implement → verify green.
342
+ NEVER run pnpm build or pnpm turbo. Use npx vitest run only.
343
+ ```
344
+
345
+ ## Rules
346
+ - Branch: development branch only (auto-commit, no confirmation needed)
347
+ - NEVER let two agents edit the same file
348
+ - NEVER run `pnpm build` (crashes system) — code only
349
+ - Every agent reads its guide file — no exceptions
350
+ - Update Supabase work items IN REAL TIME — not batch at end
351
+ - Push after each wave, not just at the end
352
+ - Unattended: NEVER pause — continue automatically
353
+ - Unattended: max 2 retries per task before escalating to advisor
354
+ - Every Agent() dispatch: `model: "sonnet"` + `max_turns: 70` + `isolation: "worktree"` — non-negotiable (Sonnet agents, Opus supervisor). Exception: validator agent in Step 10 omits isolation.
355
+ - Finding an existing file is NOT task completion — verify it satisfies the spec