@punks/cli 2.1.9 → 2.1.11

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 (63) hide show
  1. package/README.md +1 -1
  2. package/dist/data/catalog/hooks.ts +8 -0
  3. package/dist/data/catalog/packs.ts +11 -3
  4. package/dist/data/catalog/skills.ts +48 -0
  5. package/dist/data/catalog/tools.ts +9 -1
  6. package/dist/data/hooks/scaffold-update-check.mjs +181 -0
  7. package/dist/data/hooks.test.ts +17 -0
  8. package/dist/data/scripts/sync-subagents.mjs +104 -32
  9. package/dist/data/subagents/manifest.mjs +120 -0
  10. package/dist/index.js +600 -85
  11. package/dist/skills/agnostic/cli/dp-cli/SKILL.md +3 -3
  12. package/dist/skills/agnostic/cli/dp-cli/references/commands.md +1 -1
  13. package/dist/skills/agnostic/cli/dp-cli/references/post-command-flow.md +1 -1
  14. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +46 -0
  15. package/dist/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +4 -0
  16. package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +67 -0
  17. package/dist/skills/agnostic/docs/writing-beats/SKILL.md +69 -0
  18. package/dist/skills/agnostic/docs/writing-fragments/SKILL.md +76 -0
  19. package/dist/skills/agnostic/docs/writing-shape/SKILL.md +75 -0
  20. package/dist/skills/agnostic/generic/handoff/SKILL.md +15 -0
  21. package/dist/skills/agnostic/planning/create-plan/SKILL.md +24 -8
  22. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +20 -0
  23. package/dist/skills/agnostic/planning/create-plan/references/planner-phase.md +1 -1
  24. package/dist/skills/agnostic/planning/create-plan/references/tdd-phase.md +23 -1
  25. package/dist/skills/agnostic/planning/create-spec/SKILL.md +63 -17
  26. package/dist/skills/agnostic/planning/create-spec/references/discovery.md +24 -16
  27. package/dist/skills/agnostic/planning/create-spec/references/folder-naming.md +6 -2
  28. package/dist/skills/agnostic/planning/create-spec/references/wiki-bookkeeping.md +29 -5
  29. package/dist/skills/agnostic/planning/implement-spec/SKILL.md +20 -2
  30. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +7 -1
  31. package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +15 -8
  32. package/dist/skills/agnostic/planning/implement-spec/references/sequential.md +8 -3
  33. package/dist/skills/agnostic/planning/stack/SKILL.md +89 -0
  34. package/dist/skills/agnostic/quality/tdd/SKILL.md +31 -0
  35. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +1 -0
  36. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +7 -5
  37. package/dist/skills/frameworks/tanstack-query/tanstack-query/SKILL.md +621 -830
  38. package/dist/skills/frameworks/tanstack-start/tanstack-start/SKILL.md +250 -0
  39. package/dist/skills/phases/bug-discovery-phase/REFERENCE.md +30 -0
  40. package/dist/skills/phases/bug-discovery-phase/SKILL.md +8 -1
  41. package/dist/skills/phases/debugging-phase/SKILL.md +1 -0
  42. package/dist/skills/phases/delivery-phase/SKILL.md +33 -65
  43. package/dist/skills/phases/delivery-phase/phases/closeout.md +33 -0
  44. package/dist/skills/phases/delivery-phase/phases/debug.md +30 -0
  45. package/dist/skills/phases/delivery-phase/phases/docs-ingest.md +27 -0
  46. package/dist/skills/phases/delivery-phase/phases/implement.md +30 -0
  47. package/dist/skills/phases/delivery-phase/phases/plan.md +27 -0
  48. package/dist/skills/phases/delivery-phase/phases/review.md +29 -0
  49. package/dist/skills/phases/delivery-phase/phases/router.md +46 -0
  50. package/dist/skills/phases/delivery-phase/phases/spec.md +26 -0
  51. package/dist/skills/phases/delivery-phase/references/artifact-state.md +42 -0
  52. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +25 -0
  53. package/dist/skills/phases/docs-ingest-phase/SKILL.md +28 -70
  54. package/dist/skills/phases/docs-ingest-phase/agents/openai.yaml +2 -2
  55. package/dist/skills/phases/docs-ingest-phase/phases/private-internal.md +57 -0
  56. package/dist/skills/phases/docs-ingest-phase/phases/public-docs.md +52 -0
  57. package/dist/skills/phases/docs-ingest-phase/phases/router.md +42 -0
  58. package/dist/skills/phases/docs-ingest-phase/references/fumadocs-routing.md +8 -5
  59. package/dist/skills/phases/docs-ingest-phase/references/learning-artifacts.md +96 -0
  60. package/dist/skills/phases/docs-ingest-phase/references/public-docs.md +90 -0
  61. package/dist/skills/phases/requirements-phase/SKILL.md +3 -0
  62. package/dist/skills/phases/review-phase/SKILL.md +5 -0
  63. package/package.json +1 -1
@@ -10,20 +10,20 @@ description: Create a SPEC.md file for a new feature, product, or system using t
10
10
  - **Role:** higher-order spec authoring skill
11
11
  - **Entrypoint type:** public entrypoint
12
12
  - **Upstream:** new idea, feature request, epic/capability issue, or problem statement
13
- - **Delegates to:** `$parallel-research` for split-friendly readonly discovery; `$requirements-grill` when discovery leaves meaningful spec-affecting unknowns; `$write-backlog` when the spec objective or grill outcomes change epic/story scope
13
+ - **Delegates to:** `planning-discovery` for bounded readonly orientation when subagents are available; `$parallel-research` for split-friendly readonly discovery; `$requirements-grill` when discovery leaves meaningful spec-affecting unknowns; `$write-backlog` when the spec objective or grill outcomes change epic/story scope; `spec-reviewer` for a final readonly quality pass when subagents are available
14
14
  - **Downstream:** reviewed `SPEC.md`, then usually `create-plan` or `implement-spec`
15
- - **Entry conditions:** wiki root exists and a primary spec domain or project area can be resolved from existing specs, routed project docs, backlog context, or the user's request
16
- - **Stop conditions:** `SPEC.md`, wiki index, and wiki log are updated, then wait for user review
15
+ - **Entry conditions:** a planning surface can be resolved from routed wiki docs, legacy wiki specs, existing docs, backlog context, or the user's request
16
+ - **Stop conditions:** `SPEC.md` and any existing planning-surface indexes/logs are updated, then wait for user review
17
17
 
18
18
  This skill creates `SPEC.md` files that stay in the problem space: what to build, who it is for, why it matters, what counts as done, and what is out of scope.
19
19
 
20
20
  When backlog context exists, one `SPEC.md` maps to one parent epic/capability issue and must cover the full scope of that epic. If the epic has child stories, the spec must explicitly incorporate and unify the requirements of all of them.
21
21
 
22
- The output lives at `apps/wiki/specs/<domain>/<folder-name>/SPEC.md`.
22
+ Resolve the output root from the repo before writing. Prefer `apps/wiki/content/docs/project/specs/<domain>/<folder-name>/SPEC.md`, then legacy `apps/wiki/specs/<domain>/<folder-name>/SPEC.md`, then `docs/specs/<domain>/<folder-name>/SPEC.md`.
23
23
 
24
24
  ## Quick start
25
25
 
26
- 1. Read `apps/wiki/AGENTS.md` first. Stop if the wiki is not bootstrapped.
26
+ 1. Resolve the planning surface with `references/discovery.md`; do not block solely because legacy `apps/wiki/AGENTS.md` is absent.
27
27
  2. Read `references/discovery.md` and orient yourself in the right spec domain or project area before asking questions.
28
28
  3. When discovery spans independent code paths, docs, backlog items, prior specs, or hypotheses, read and use `$parallel-research` for readonly sidecar coverage before synthesizing.
29
29
  4. If backlog context exists, read the parent epic and every child story before asking questions.
@@ -34,23 +34,69 @@ The output lives at `apps/wiki/specs/<domain>/<folder-name>/SPEC.md`.
34
34
  9. Read `references/folder-naming.md` to resolve the domain and spec folder path.
35
35
  10. Read `assets/SPEC-TEMPLATE.md` and write the spec.
36
36
  11. Read `references/spec-quality-bar.md` before saving.
37
- 12. Read `references/wiki-bookkeeping.md` to update `index.md`, `<domain>-specs.md`, and `log.md`.
38
- 13. Read `references/handoff.md` to choose the next-step recommendation and stop after user review.
37
+ 12. If subagents are available, use `spec-reviewer` for a readonly pass over the draft before user review.
38
+ 13. Read `references/wiki-bookkeeping.md` to update the indexes/logs that exist for the resolved planning surface.
39
+ 14. Read `references/handoff.md` to choose the next-step recommendation and stop after user review.
39
40
 
40
41
  ## Workflow
41
42
 
42
43
  ### Default workflow
43
44
 
44
45
  1. Build orientation first; do not jump straight into writing.
45
- 2. Ask only enough to make the spec crisp, testable, and bounded.
46
- 3. Use `$parallel-research` when readonly orientation can be split cleanly across independent evidence sources; keep synthesis and spec decisions local.
47
- 4. When an epic has child stories, harvest and preserve each story's requirements before drafting.
48
- 5. Use `$requirements-grill` for meaningful spec-affecting unknowns; do not replace that phase with ad hoc `Open Questions` prompts.
49
- 6. Use `$write-backlog` automatically before final drafting when accepted spec direction implies backlog changes, whether that direction came from the user's objective, discovery, or a grill phase.
50
- 7. Keep the spec free of implementation detail.
51
- 8. Use the template structure exactly, then remove all template scaffolding.
52
- 9. Update wiki bookkeeping in the same run.
53
- 10. Stop after presenting the spec and the recommended next step.
46
+ 2. Scan relevant routed learning artifacts when prior bug knowledge, domain behavior, or project conventions could affect the spec.
47
+ 3. Ask only enough to make the spec crisp, testable, and bounded.
48
+ 4. Use `$parallel-research` when readonly orientation can be split cleanly across independent evidence sources; keep synthesis and spec decisions local.
49
+ 5. When an epic has child stories, harvest and preserve each story's requirements before drafting.
50
+ 6. Use `$requirements-grill` for meaningful spec-affecting unknowns; do not replace that phase with ad hoc `Open Questions` prompts.
51
+ 7. Use `$write-backlog` automatically before final drafting when accepted spec direction implies backlog changes, whether that direction came from the user's objective, discovery, or a grill phase.
52
+ 8. Keep the spec free of implementation detail.
53
+ 9. Use the template structure exactly, then remove all template scaffolding.
54
+ 10. Use `spec-reviewer` to catch invented requirements, missing constraints, vague acceptance criteria, and contradictions before yielding when subagents are available.
55
+ 11. Update planning-surface bookkeeping in the same run.
56
+ 12. Stop after presenting the spec and the recommended next step.
57
+
58
+ ### Dependency readiness and stack intent
59
+
60
+ When backlog context exists, inspect backlog dependencies before drafting.
61
+
62
+ - A task-level `depends_on` inside one epic or plan is implementation ordering,
63
+ not PR stack topology.
64
+ - A backlog dependency between epics/stories is a dependency-readiness gate.
65
+ - If the dependency has an `IMPLEMENTATION-NOTES.md` or equivalent
66
+ implemented-status artifact, trust it as implemented. Record
67
+ `No Stack Required` unless another open PR dependency still applies.
68
+ - If no implemented-status artifact exists, use local code evidence or merged PR
69
+ evidence as fallback proof that the dependency landed.
70
+ - If the dependency is represented by an open parent PR, record
71
+ `Branch/Base Intent`.
72
+ - If the dependency is neither proven implemented nor represented by an open
73
+ parent PR, block spec creation and report the missing dependency evidence.
74
+
75
+ When backlog dependencies exist, add this section to `SPEC.md`:
76
+
77
+ ```md
78
+ ## Dependency Readiness
79
+
80
+ - Status: No Stack Required | Branch/Base Intent | Blocked
81
+ - Dependency: <epic/story/pr/link>
82
+ - Evidence: <implementation notes path | implemented-status artifact | merged PR | parent PR>
83
+ - Reason: <why this status was chosen>
84
+ ```
85
+
86
+ Only for stack-dependent work, also add:
87
+
88
+ ```md
89
+ ## Branch/Base Intent
90
+
91
+ - Parent PR: #123
92
+ - Parent branch: team/name/parent
93
+ - Child branch: team/name/child
94
+ - PR base: team/name/parent
95
+ - Required gate: stack sync --dry-run after PR creation/update
96
+ ```
97
+
98
+ `create-spec` records stack intent only. Do not create, switch, or push git
99
+ branches unless the user explicitly requests branch setup during the spec turn.
54
100
 
55
101
  ## Advanced features
56
102
 
@@ -60,6 +106,6 @@ The output lives at `apps/wiki/specs/<domain>/<folder-name>/SPEC.md`.
60
106
  - Backlog sync after grilling: see [references/backlog-sync.md](references/backlog-sync.md)
61
107
  - Domain and folder naming rules: see [references/folder-naming.md](references/folder-naming.md)
62
108
  - Acceptance-criteria and quality bar: see [references/spec-quality-bar.md](references/spec-quality-bar.md)
63
- - Wiki index and log updates: see [references/wiki-bookkeeping.md](references/wiki-bookkeeping.md)
109
+ - Planning surface index/log updates: see [references/wiki-bookkeeping.md](references/wiki-bookkeeping.md)
64
110
  - Review closeout and next-step routing: see [references/handoff.md](references/handoff.md)
65
111
  - Canonical backlog model: see [../write-backlog/assets/concepts/backlog-model.md](../write-backlog/assets/concepts/backlog-model.md)
@@ -4,35 +4,43 @@ Use this reference before asking clarifying questions.
4
4
 
5
5
  ## Required order
6
6
 
7
- 1. Read `apps/wiki/AGENTS.md`.
8
- - Stop if it does not exist. The wiki is not bootstrapped yet.
9
- 2. Read `apps/wiki/index.md`.
10
- - Use it as the master map for source specs, routed project docs, and recent wiki activity.
11
- 3. Identify the primary spec domain or project area.
12
- - Prefer an existing `apps/wiki/specs/<domain>/` directory when one clearly owns the request.
7
+ 1. Resolve the planning surface. Prefer the first existing layout:
8
+ - routed project wiki: `apps/wiki/content/docs/project/specs`
9
+ - legacy source wiki: `apps/wiki/specs`
10
+ - docs fallback: `docs/specs`
11
+ 2. Read local guidance for the resolved surface when present:
12
+ - routed project wiki: `apps/wiki/AGENTS.md`, `apps/wiki/content/docs/project/index.mdx`, `apps/wiki/content/docs/project/meta.json`
13
+ - legacy source wiki: `apps/wiki/AGENTS.md`, `apps/wiki/index.md`
14
+ - docs fallback: `docs/README.md`, `docs/specs/index.md`
15
+ 3. If none of those roots exists, create `docs/specs/<domain>/<folder>/SPEC.md` rather than blocking on scaffold setup.
16
+ - Mention that the repo lacks a routed wiki planning surface in the handoff.
17
+ - Do not create or scaffold `apps/wiki` from this skill.
18
+ 4. Identify the primary spec domain or project area.
19
+ - Prefer an existing `<resolved-specs-root>/<domain>/` directory when one clearly owns the request.
13
20
  - Otherwise infer a concise domain slug from backlog context or the user's request.
14
21
  - If multiple domains are involved, pick the primary owner and note cross-domain scope in the spec.
15
22
  - Do not create `apps/wiki/domains/` just to make discovery work.
16
- 4. Read existing context for that area when present:
17
- - `apps/wiki/specs/<domain>/<domain>-specs.md`
18
- - `apps/wiki/content/docs/project/**` pages that match the area
19
- 5. Optionally read related routed project pages when they are obviously relevant.
20
- 6. Check for existing overlapping specs in:
21
- - `apps/wiki/specs/<domain>/<domain>-specs.md`
22
- 7. If backlog context exists, inspect the parent epic/capability and every child story beneath it.
23
+ 5. Read existing context for that area when present:
24
+ - `<resolved-specs-root>/<domain>/<domain>-specs.md`
25
+ - routed project pages under `apps/wiki/content/docs/project/**` that match the area
26
+ - docs pages under `docs/**` that match the area
27
+ 6. Optionally read related routed project pages when they are obviously relevant.
28
+ 7. Check for existing overlapping specs in:
29
+ - `<resolved-specs-root>/<domain>/<domain>-specs.md`
30
+ 8. If backlog context exists, inspect the parent epic/capability and every child story beneath it.
23
31
  Use [../../write-backlog/assets/concepts/backlog-model.md](../../write-backlog/assets/concepts/backlog-model.md) as the source of truth for how to interpret module -> epic -> story shape.
24
32
  Harvest:
25
33
  - epic outcome and constraints
26
34
  - each child story title
27
35
  - each child story body and acceptance signals
28
36
  - cross-story blockers or sequencing assumptions that affect the problem statement
29
- 8. Check existing DB schema when a matching domain schema file exists:
37
+ 9. Check existing DB schema when a matching domain schema file exists:
30
38
  - `packages/db/src/schema/<domain>.ts`
31
39
  Use it to:
32
40
  - avoid speccing duplicates
33
41
  - catch contradictions with the implemented model
34
42
  - surface open questions when a required field is absent
35
- 9. Glance at the top-level repo structure only if needed for terminology or context.
43
+ 10. Glance at the top-level repo structure only if needed for terminology or context.
36
44
 
37
45
  ## Exploration rule
38
46
 
@@ -43,4 +51,4 @@ This is orientation, not deep implementation research.
43
51
  - Prefer enough context to ask better questions
44
52
  - Do not drift into solution design
45
53
 
46
- If the Agent tool is available, use a subagent for this pass so the main thread stays clean.
54
+ If the Agent tool is available, use the `planning-discovery` subagent for this pass so the main thread stays clean. Its output should be evidence, contradictions, overlapping work, and open questions only; keep synthesis and spec decisions in the parent thread.
@@ -4,8 +4,12 @@ Use this reference after questioning and before writing the file.
4
4
 
5
5
  ## Domain resolution
6
6
 
7
- - The spec path is `apps/wiki/specs/<domain>/<folder-name>/SPEC.md`.
8
- - Use the exact existing domain directory name from `apps/wiki/specs/` when one clearly applies.
7
+ - The spec path is `<resolved-specs-root>/<domain>/<folder-name>/SPEC.md`.
8
+ - Resolve `<resolved-specs-root>` during discovery:
9
+ - `apps/wiki/content/docs/project/specs` for routed project wiki repos
10
+ - `apps/wiki/specs` for legacy source-wiki repos
11
+ - `docs/specs` when no wiki planning surface exists
12
+ - Use the exact existing domain directory name from `<resolved-specs-root>/` when one clearly applies.
9
13
  - If no existing spec domain applies, create a concise kebab-case domain from the request or backlog area.
10
14
  - If multiple domains are touched, choose the primary owner and describe the cross-domain aspect in the spec body.
11
15
  - Do not create `apps/wiki/domains/` as part of spec authoring.
@@ -1,8 +1,22 @@
1
- # Wiki Bookkeeping
1
+ # Planning Surface Bookkeeping
2
2
 
3
3
  Use this reference after writing `SPEC.md`.
4
4
 
5
- ## Required updates
5
+ ## Required updates by surface
6
+
7
+ ### Routed project wiki
8
+
9
+ When using `apps/wiki/content/docs/project/specs`:
10
+
11
+ 1. Create or update `<resolved-specs-root>/<domain>/<domain>-specs.md` with:
12
+ - the spec name
13
+ - a one-line summary
14
+ 2. Update `meta.json` files only when needed for the new spec to appear in the routed tree.
15
+ 3. Update any existing project specs index page that already tracks specs.
16
+
17
+ ### Legacy source wiki
18
+
19
+ When using `apps/wiki/specs`:
6
20
 
7
21
  1. Add a row to the **Specs** table in `apps/wiki/index.md`:
8
22
 
@@ -13,8 +27,7 @@ Use this reference after writing `SPEC.md`.
13
27
  2. Create or update `apps/wiki/specs/<domain>/<domain>-specs.md` with:
14
28
  - the spec name
15
29
  - a one-line summary
16
-
17
- 3. Append to `apps/wiki/log.md`:
30
+ 3. Append to `apps/wiki/log.md` when it exists:
18
31
 
19
32
  ```md
20
33
  ## [YYYY-MM-DD] spec | <spec title>
@@ -23,4 +36,15 @@ Use this reference after writing `SPEC.md`.
23
36
  - Status: Draft
24
37
  ```
25
38
 
26
- Do not skip this step.
39
+ ### Docs fallback
40
+
41
+ When using `docs/specs`:
42
+
43
+ 1. Create or update `docs/specs/index.md` with:
44
+ - the domain
45
+ - the spec path
46
+ - status `Draft`
47
+ 2. Create or update `docs/specs/<domain>/<domain>-specs.md` with:
48
+ - the spec name
49
+ - a one-line summary
50
+ 3. Do not invent wiki logs or routed metadata for a repo that has not bootstrapped them.
@@ -25,7 +25,7 @@ Use `$agent-browser` when any task `review_mode` is `browser` or `mixed`.
25
25
 
26
26
  When `implement-spec` runs in `sequential` mode, it must follow [references/sequential.md](references/sequential.md).
27
27
 
28
- That means `implement-spec` itself owns orchestration and validation, while exactly one implementation worker owns the sequential coding loop. This keeps the parent context small and adds a parent review gate after worker handoff.
28
+ That means `implement-spec` itself owns orchestration and validation, while exactly one implementation worker owns the sequential coding loop. This is a hard gate: do not implement in the parent main thread when worker execution is unavailable. Stop, repair worker routing, or report the blocker.
29
29
 
30
30
  ## Parallel responsibilities
31
31
 
@@ -55,6 +55,24 @@ That means `implement-spec` itself owns all of the following in parallel mode:
55
55
  9. If backlog sync is in scope, keep epic/story bodies product-facing and use native metadata or comments instead of execution handoff rewrites.
56
56
  10. Finish with the shared acceptance audit, manual review checklist, and spec finalization contract.
57
57
 
58
+ ## Stack-aware branch gate
59
+
60
+ Before coding, inspect `PLAN.md` for `Branch/Base Intent`.
61
+
62
+ - If no `Branch/Base Intent` exists, continue with the normal execution flow.
63
+ - If it exists, verify the current branch is the intended child branch based on
64
+ the intended parent branch, or create/switch to the intended child branch from
65
+ the intended parent branch before implementation starts.
66
+ - Do not reinterpret intra-epic task dependencies as separate PRs.
67
+ - Default to PR-after-implementation: implement, commit, push, create or update
68
+ the PR with the recorded base, then run `stack sync --dry-run`.
69
+ - If the dry-run preview is correct and reports pending stack changes, run
70
+ `stack sync`.
71
+ - Early draft PRs are opt-in only when the user explicitly asks for them.
72
+ - If `stack` is unavailable and `Branch/Base Intent` exists, block the
73
+ stack-dependent workflow. Missing `stack` does not block independent
74
+ trunk-based work.
75
+
58
76
  ## Mode selection
59
77
 
60
78
  Choose `sequential` when:
@@ -70,7 +88,7 @@ Choose `parallel` when:
70
88
  - the plan contains independent waves
71
89
  - disjoint write scopes make worker fan-out safe
72
90
 
73
- If the user already chose a mode, honor it. If not, choose `sequential` and state that it uses one implementation worker plus parent validation.
91
+ If the user already chose a mode, honor it. If not, choose `sequential` and state that it spawns exactly one implementation worker plus parent validation.
74
92
 
75
93
  ## Advanced features
76
94
 
@@ -92,8 +92,13 @@ Do not create the file when nothing durable must survive the run.
92
92
  - Mode is manual. The chosen approach decides the execution path.
93
93
  - Do not switch modes mid-run unless the user explicitly redirects.
94
94
  - Default to `sequential` when the user does not choose a mode.
95
- - In `sequential`, keep implementation work inside one worker; the parent coordinates, reviews, validates, and finalizes.
95
+ - In `sequential`, keep implementation work inside exactly one worker; the parent coordinates, reviews, validates, and finalizes.
96
+ - If worker execution is unavailable, stop and repair worker routing or report the blocker. Do not implement in the parent main thread.
96
97
  - Treat every `tdd_target` as required RED-first behavior, never optional guidance.
98
+ - Treat `tdd_status`, `red_command`, `expected_red_failure`, `green_command`, `reason_not_testable`, `red_evidence`, and `green_evidence` as the task completion contract.
99
+ - For behavior-changing tasks, do not mark a task complete until real RED and GREEN evidence is recorded in `PLAN.md`.
100
+ - Accept missing RED/GREEN evidence only when the task has an explicit `reason_not_testable` or `tdd_status: not_applicable`.
101
+ - Do not accept `reason_not_testable` for forgotten RED. If code came first, recover by writing the public-result RED test, recording failure, patching to pass, and marking `tdd_status: recovered`.
97
102
  - Treat every `review_mode` as required validation routing, never optional metadata.
98
103
  - Keep an operator-visible execution board in the conversation so progress is obvious.
99
104
  - Keep scope discipline. Out-of-scope findings that do not affect the current implementation go to `IMPLEMENTATION-NOTES.md`, not silent scope creep.
@@ -110,6 +115,7 @@ After each completed task or wave:
110
115
  - update `PLAN.md` status
111
116
  - append a concise execution log in `PLAN.md`
112
117
  - record touched files in `PLAN.md`
118
+ - fill `red_evidence` and `green_evidence`, or the accepted non-testable reason, before marking behavior-changing work complete
113
119
  - update `IMPLEMENTATION-NOTES.md` with non-obvious decisions, surprises, or deviations
114
120
  - resolve any in-goal debt before advancing
115
121
  - update the spec-linked tech-debt file only for blocked or explicitly parked debt with exact owner/next action
@@ -16,6 +16,11 @@ Every worker brief should include:
16
16
  - acceptance criteria
17
17
  - validation contract
18
18
  - `tdd_target`
19
+ - `tdd_status`
20
+ - `red_command`
21
+ - `expected_red_failure`
22
+ - `green_command`
23
+ - `reason_not_testable`
19
24
  - `review_mode`
20
25
  - relevant risks or constraints from the plan
21
26
 
@@ -27,14 +32,16 @@ Each worker brief should require:
27
32
  2. reading all relevant files first, then doing targeted codebase research before editing
28
33
  3. starting from `tdd_target` and driving the task RED first when it is testable
29
34
  4. capturing failing evidence for the expected behavior gap before implementation
30
- 5. recording an explicit `reason_not_testable` plus exact alternative verification when the task is not a good TDD candidate
31
- 6. treating RED-phase tests or the approved non-testable verification plan as the implementation contract
32
- 7. not weakening or removing tests unless requirements changed
33
- 8. implementing only the assigned task scope and satisfying all acceptance criteria
34
- 9. running the exact task validation evidence before returning, plus extra plan validation when feasible
35
- 10. resolving any in-goal debt immediately instead of leaving TODOs, temporary workarounds, or "later" notes
36
- 11. stopping for parent clarification when a debt item requires a product/scope decision outside the assigned task
37
- 12. updating the plan entry with status, log, touched files, and gotchas before handoff closes
35
+ 5. recording `red_evidence` and `green_evidence` in the plan before marking behavior-changing tasks complete
36
+ 6. recovering code-before-RED by writing the intended public-result RED test and marking `tdd_status: recovered`, not by using `reason_not_testable`
37
+ 7. recording an explicit `reason_not_testable` plus exact alternative verification when the task is not a good TDD candidate
38
+ 8. treating RED-phase tests or the approved non-testable verification plan as the implementation contract
39
+ 9. not weakening or removing tests unless requirements changed
40
+ 10. implementing only the assigned task scope and satisfying all acceptance criteria
41
+ 11. running the exact task validation evidence before returning, plus extra plan validation when feasible
42
+ 12. resolving any in-goal debt immediately instead of leaving TODOs, temporary workarounds, or "later" notes
43
+ 13. stopping for parent clarification when a debt item requires a product/scope decision outside the assigned task
44
+ 14. updating the plan entry with status, log, touched files, and gotchas before handoff closes
38
45
 
39
46
  ## Worker output contract
40
47
 
@@ -8,6 +8,8 @@ Use this approach when execution should stay serial while avoiding main-context
8
8
  - **Worker policy:** spawn exactly one implementation worker
9
9
  - **Execution board:** completed, in progress, next, blocked
10
10
 
11
+ Hard gate: sequential implementation never runs in the parent main thread. If the worker cannot be spawned or routed, stop and repair the worker guard or report the blocker.
12
+
11
13
  ## Quick start
12
14
 
13
15
  1. Load the shared lifecycle from `lifecycle.md`.
@@ -23,9 +25,12 @@ Use this approach when execution should stay serial while avoiding main-context
23
25
  The worker owns this loop for every task:
24
26
 
25
27
  1. start from `tdd_target`
26
- 2. validate through the task's public interface
27
- 3. run the task-level validation gate before marking it done
28
- 4. update the execution board before advancing
28
+ 2. classify `tdd_status` and honor the task's RED/GREEN contract
29
+ 3. for behavior-changing work, run `red_command`, verify `expected_red_failure`, and record `red_evidence` before production edits
30
+ 4. patch only enough production code to pass the public behavior
31
+ 5. run `green_command`, record `green_evidence`, and only then mark the task done
32
+ 6. for non-testable or non-applicable tasks, record `reason_not_testable` plus the exact alternative verification
33
+ 7. update the execution board before advancing
29
34
 
30
35
  The parent owns:
31
36
 
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: stack
3
+ description: Use the local squash-safe `stack` CLI for stacked PR inspection, sync, merge, and undo workflows when backlog-dependent work is represented by open parent PRs.
4
+ ---
5
+
6
+ # Stack
7
+
8
+ Use the local `stack` CLI for squash-safe stacked PR workflows. It is for repos
9
+ where dependent PRs may be open at the same time and GitHub squash-merges parent
10
+ PRs.
11
+
12
+ Keep ordinary editing and commits on plain `git`. Use `stack` only for stack
13
+ intent, stack inspection, sync, merge, and undo workflows.
14
+
15
+ ## Mental Model
16
+
17
+ ```text
18
+ main
19
+ └─ parent-branch #101
20
+ └─ child-branch #102
21
+ ```
22
+
23
+ The GitHub PR base is the source of truth for ordinary stack inference. A child
24
+ PR should use its parent PR branch as its base. Independent PRs stay based on
25
+ trunk and do not need fake stack tracking.
26
+
27
+ ## Core Commands
28
+
29
+ - `stack status`: inspect the current tracked or inferred stack.
30
+ - `stack sync --dry-run`: required inspection gate before stack mutation.
31
+ - `stack sync`: approved mutation gate after the dry-run preview is correct.
32
+ - `stack merge --auto`: merge the current stack root with GitHub auto-merge,
33
+ wait for it to land, and repair descendants.
34
+ - `stack undo --apply`: restore the previous applied stack mutation when a
35
+ repair or merge needs to be rolled back.
36
+
37
+ ## Harness Workflow Rules
38
+
39
+ - Missing `stack` blocks stack-dependent workflows only. It does not block
40
+ independent trunk-based work.
41
+ - `create-spec` records stack intent through `Dependency Readiness` and
42
+ `Branch/Base Intent`; it does not mutate git state.
43
+ - `create-plan` preserves and validates those sections; it does not decide stack
44
+ topology.
45
+ - `implement-spec` executes recorded branch/base intent before coding and runs
46
+ stack sync only after PR base metadata exists.
47
+ - `delivery-phase` owns stack mutation and cleanliness.
48
+ - `review-phase` stays readonly and reports stack evidence.
49
+
50
+ ## Normal Stacked PR Flow
51
+
52
+ ```bash
53
+ git checkout -b team/name/child team/name/parent
54
+ # implement, commit, push
55
+ gh pr create --base team/name/parent --head team/name/child
56
+ stack sync --dry-run
57
+ stack sync
58
+ ```
59
+
60
+ Use `stack track <branch> --onto <parent>` only when GitHub PR bases cannot
61
+ encode the stack clearly. Prefer PR bases over hand-maintained metadata.
62
+
63
+ ## Delivery Closeout
64
+
65
+ When a PR exists, run:
66
+
67
+ ```bash
68
+ stack status
69
+ stack sync --dry-run
70
+ ```
71
+
72
+ If the PR is stack-dependent and the dry-run reports pending changes, run:
73
+
74
+ ```bash
75
+ stack sync
76
+ ```
77
+
78
+ Then rerun `stack status` if the final report needs evidence.
79
+
80
+ ## Recovery
81
+
82
+ For the most recent applied stack mutation:
83
+
84
+ ```bash
85
+ stack undo
86
+ stack undo --apply
87
+ ```
88
+
89
+ Run the dry-run form first unless the user explicitly asks for immediate restore.
@@ -7,6 +7,33 @@ description: Test-driven development with red-green-refactor loop. Use when user
7
7
 
8
8
  ## Philosophy
9
9
 
10
+ ## Hard Law
11
+
12
+ **No production code before RED.** For behavior-changing work, write a failing test through a public interface before editing production code.
13
+
14
+ This applies to features, bugfixes, risky refactors, and any production-code edit that changes observable behavior.
15
+
16
+ Allowed escapes:
17
+
18
+ - docs-only changes
19
+ - formatting-only changes
20
+ - generated-code-only changes
21
+ - config-only changes where no runtime behavior is asserted
22
+ - scaffold/bookkeeping-only changes
23
+ - truly non-testable work with an explicit `reason_not_testable`
24
+
25
+ `reason_not_testable` cannot cover forgotten RED.
26
+
27
+ If production code was written first:
28
+
29
+ 1. Stop advancing the slice.
30
+ 2. Write the RED test that proves the actual intended public result.
31
+ 3. Run it and record real failure evidence.
32
+ 4. Patch production code only enough to make that test pass.
33
+ 5. Record the task as `tdd_status: recovered`.
34
+
35
+ If the current code already passes the new test, do not fake RED. Isolate the pre-fix state or revert enough of the slice to observe the failure. If true RED cannot be reconstructed, record the deviation explicitly; do not call the task normally RED/GREEN compliant.
36
+
10
37
  **Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
11
38
 
12
39
  **Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
@@ -46,12 +73,14 @@ RIGHT (vertical):
46
73
 
47
74
  Before writing any code:
48
75
 
76
+ - [ ] Decide whether the work is behavior-changing and therefore `tdd_status: required`
49
77
  - [ ] Confirm with user what interface changes are needed
50
78
  - [ ] Confirm with user which behaviors to test (prioritize)
51
79
  - [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
52
80
  - [ ] Design interfaces for [testability](interface-design.md)
53
81
  - [ ] List the behaviors to test (not implementation steps)
54
82
  - [ ] Get user approval on the plan
83
+ - [ ] Record `red_command`, `expected_red_failure`, and `green_command` in the plan before implementation starts
55
84
 
56
85
  Ask: "What should the public interface look like? Which behaviors are most important to test?"
57
86
 
@@ -80,9 +109,11 @@ GREEN: Minimal code to pass → passes
80
109
  Rules:
81
110
 
82
111
  - One test at a time
112
+ - Run and read RED before production code
83
113
  - Only enough code to pass current test
84
114
  - Don't anticipate future tests
85
115
  - Keep tests focused on observable behavior
116
+ - Record `red_evidence` and `green_evidence` before claiming completion
86
117
 
87
118
  ### 4. Refactor
88
119
 
@@ -30,6 +30,7 @@ Both workflows can happen in one long session, but keep the responsibilities dis
30
30
  - Ask one question at a time by default.
31
31
  - For every question, provide a recommended answer and the reason for it.
32
32
  - Inspect code/docs first when the answer can be found locally.
33
+ - Inspect relevant routed learning artifacts before grilling requirements that depend on known behavior, prior bugs, project conventions, or domain facts.
33
34
  - Challenge conflicting glossary, vague terms, and hidden tradeoffs immediately.
34
35
  - Pin canonical terms, rejected aliases, relationships, and domain axioms as decisions crystallize.
35
36
  - Prefer conservative defaults once enough context exists.
@@ -9,11 +9,13 @@ description: Turns a large requirements discussion into a canonical backlog hier
9
9
 
10
10
  1. Read [REFERENCE.md](REFERENCE.md) and [assets/concepts/backlog-model.md](assets/concepts/backlog-model.md).
11
11
  2. If `requirements-grill` artifacts exist, read `*-grill-status.md` first and `*-grill-log.md` second.
12
- 3. Derive modules first, then epics, then stories.
13
- 4. Make story ordering explicit with native dependency primitives when the provider supports them.
14
- 5. Keep epic and story bodies product-facing.
15
- 6. Read the matching provider payload asset before generating or syncing create payloads.
16
- 7. Stop after the backlog structure and create payload guidance are complete.
12
+ 3. If subagents are available and the source material is large, use `requirements-synthesizer` to compress accepted, rejected, superseded, parked, and unresolved decisions.
13
+ 4. If subagents are available, use `backlog-shaper` for a draft module/epic/story hierarchy; keep final backlog judgment in the parent thread.
14
+ 5. Derive modules first, then epics, then stories.
15
+ 6. Make story ordering explicit with native dependency primitives when the provider supports them.
16
+ 7. Keep epic and story bodies product-facing.
17
+ 8. Read the matching provider payload asset before generating or syncing create payloads.
18
+ 9. Stop after the backlog structure and create payload guidance are complete.
17
19
 
18
20
  ## Workflows
19
21