@gtrabanco/pi-agentic-workflow 0.1.0

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +154 -0
  3. package/README.md +148 -0
  4. package/dist/config/defaults.d.ts +8 -0
  5. package/dist/config/defaults.js +11 -0
  6. package/dist/config/load.d.ts +19 -0
  7. package/dist/config/load.js +76 -0
  8. package/dist/config/merge.d.ts +4 -0
  9. package/dist/config/merge.js +43 -0
  10. package/dist/config/schema.d.ts +21 -0
  11. package/dist/config/schema.js +144 -0
  12. package/dist/config/types.d.ts +53 -0
  13. package/dist/config/types.js +12 -0
  14. package/dist/extension/factory.d.ts +47 -0
  15. package/dist/extension/factory.js +49 -0
  16. package/dist/extension/index.d.ts +4 -0
  17. package/dist/extension/index.js +84 -0
  18. package/dist/routing/catalogue.d.ts +35 -0
  19. package/dist/routing/catalogue.js +79 -0
  20. package/dist/routing/dispatch.d.ts +34 -0
  21. package/dist/routing/dispatch.js +191 -0
  22. package/dist/routing/state.d.ts +13 -0
  23. package/dist/routing/state.js +65 -0
  24. package/dist/routing/types.d.ts +90 -0
  25. package/dist/routing/types.js +3 -0
  26. package/dist/settings/console.d.ts +55 -0
  27. package/dist/settings/console.js +266 -0
  28. package/dist/settings/store.d.ts +3 -0
  29. package/dist/settings/store.js +24 -0
  30. package/dist/settings/view.d.ts +11 -0
  31. package/dist/settings/view.js +46 -0
  32. package/package.json +59 -0
  33. package/skills/audit-docs/SKILL.md +171 -0
  34. package/skills/audit-pr/SKILL.md +201 -0
  35. package/skills/audit-pr/references/01_MERGE_GATES.md +24 -0
  36. package/skills/audit-pr/references/02_CLOSURE_AND_SCOPE_GATES.md +83 -0
  37. package/skills/audit-pr/references/03_AUDIT_PROCESS.md +69 -0
  38. package/skills/audit-pr/references/04_VERDICT.md +69 -0
  39. package/skills/audit-pr/references/05_ROUTING_AND_GUARDRAILS.md +58 -0
  40. package/skills/audit-pr/references/PORTABILITY.md +17 -0
  41. package/skills/design-feature/SKILL.md +162 -0
  42. package/skills/design-feature/references/INTERVIEW.md +52 -0
  43. package/skills/design-feature/references/PORTABILITY.md +15 -0
  44. package/skills/design-feature/references/UPSERT_EXAMPLE.md +8 -0
  45. package/skills/design-feature/references/WRITE_AND_UPSERT.md +92 -0
  46. package/skills/discover-repository-state/SKILL.md +83 -0
  47. package/skills/execute-phase/SKILL.md +115 -0
  48. package/skills/execute-phase/references/BATCH_AND_PORTABILITY.md +54 -0
  49. package/skills/execute-phase/references/CLOSEOUT.md +74 -0
  50. package/skills/execute-phase/references/DESCOPE.md +35 -0
  51. package/skills/execute-phase/references/EXECUTION_CONTRACT.md +147 -0
  52. package/skills/execute-phase/references/FOLDING.md +73 -0
  53. package/skills/execute-phase/references/FORGE_BODY.md +24 -0
  54. package/skills/execute-phase/references/HANDOFF.md +21 -0
  55. package/skills/execute-phase/references/OPPORTUNISTIC_FINDING.md +45 -0
  56. package/skills/execute-phase/references/PREFLIGHT.md +152 -0
  57. package/skills/execute-phase/references/UNIT_LOOP.md +88 -0
  58. package/skills/execute-phase/references/WORKFLOWS_FEATURE.md +37 -0
  59. package/skills/execute-phase/references/WORKFLOWS_FIX.md +43 -0
  60. package/skills/execute-phase/references/WORKFLOWS_LEGACY.md +26 -0
  61. package/skills/execute-phase/references/WORKFLOWS_SMALL_PHASED.md +38 -0
  62. package/skills/fold-findings/SKILL.md +141 -0
  63. package/skills/fold-findings/references/FOLD_POLICY.md +43 -0
  64. package/skills/fold-findings/references/FOLD_PROCESS.md +41 -0
  65. package/skills/generate-docs/SKILL.md +145 -0
  66. package/skills/generate-docs/references/ADAPTERS.md +15 -0
  67. package/skills/generate-docs/references/ADAPTER_DISCOVERY.md +33 -0
  68. package/skills/generate-docs/references/GENERATION_PROCESS.md +90 -0
  69. package/skills/init-workspace/SKILL.md +152 -0
  70. package/skills/init-workspace/references/BOOTSTRAP_DISCOVERY.md +70 -0
  71. package/skills/init-workspace/references/BOOTSTRAP_WRITE.md +58 -0
  72. package/skills/init-workspace/references/PORTABILITY.md +16 -0
  73. package/skills/init-workspace/references/UPGRADE.md +83 -0
  74. package/skills/log-session/SKILL.md +159 -0
  75. package/skills/loop-review-fold/SKILL.md +168 -0
  76. package/skills/orchestration-envelope/SKILL.md +81 -0
  77. package/skills/orchestration-envelope/references/TURN_CONTRACT.md +21 -0
  78. package/skills/phase-contract/SKILL.md +82 -0
  79. package/skills/plan-feature/SKILL.md +179 -0
  80. package/skills/plan-feature/references/ROUTING.md +83 -0
  81. package/skills/plan-feature-from-issue/SKILL.md +140 -0
  82. package/skills/plan-feature-scaffold/SKILL.md +93 -0
  83. package/skills/plan-feature-scaffold/references/SCAFFOLD_PROCESS.md +76 -0
  84. package/skills/plan-fix/SKILL.md +115 -0
  85. package/skills/plan-fix/references/PLANNING_PROCESS.md +118 -0
  86. package/skills/plan-fix/references/SPEC_CONTRACT.md +22 -0
  87. package/skills/planning-preflight/SKILL.md +130 -0
  88. package/skills/product-audit/SKILL.md +225 -0
  89. package/skills/product-audit/references/AUDIT_DIMENSIONS.md +24 -0
  90. package/skills/product-audit/references/AUDIT_PROCESS.md +85 -0
  91. package/skills/resolve-repository-state/SKILL.md +79 -0
  92. package/skills/review-a11y/SKILL.md +60 -0
  93. package/skills/review-brand/SKILL.md +65 -0
  94. package/skills/review-change/SKILL.md +156 -0
  95. package/skills/review-change/references/ADVERSARIAL_RECOMMENDATION.md +31 -0
  96. package/skills/review-change/references/ADVERSARIAL_SETUP.md +86 -0
  97. package/skills/review-change/references/ADVERSARIAL_SYNTHESIS.md +53 -0
  98. package/skills/review-change/references/OUTPUT_AND_GUARDRAILS.md +85 -0
  99. package/skills/review-change/references/PERSIST_AND_DECIDE.md +151 -0
  100. package/skills/review-change/references/PORTABILITY.md +74 -0
  101. package/skills/review-change/references/REVIEW_PROCESS.md +86 -0
  102. package/skills/review-code/SKILL.md +69 -0
  103. package/skills/review-debt/SKILL.md +72 -0
  104. package/skills/review-design/SKILL.md +60 -0
  105. package/skills/review-implementation/SKILL.md +108 -0
  106. package/skills/review-implementation/references/CLASSIFY.md +96 -0
  107. package/skills/review-implementation/references/FIND.md +35 -0
  108. package/skills/review-perf/SKILL.md +79 -0
  109. package/skills/review-security/SKILL.md +65 -0
  110. package/skills/review-seo/SKILL.md +65 -0
  111. package/skills/review-verify/SKILL.md +66 -0
  112. package/skills/ship-roadmap/SKILL.md +120 -0
  113. package/skills/ship-roadmap/references/ADVANCE.md +90 -0
  114. package/skills/ship-roadmap/references/AUDIT_AND_MERGE.md +64 -0
  115. package/skills/ship-roadmap/references/CLOSEOUT_AND_LOG.md +26 -0
  116. package/skills/ship-roadmap/references/FOUNDING.md +101 -0
  117. package/skills/ship-roadmap/references/GUARDRAILS.md +56 -0
  118. package/skills/ship-roadmap/references/MODEL_ROUTING.md +14 -0
  119. package/skills/ship-roadmap/references/PORTABILITY.md +34 -0
  120. package/skills/ship-roadmap/references/RECOVERY_AND_SELECTION.md +93 -0
  121. package/skills/ship-roadmap/references/STOP_CONDITIONS.md +9 -0
  122. package/skills/ship-roadmap/references/TERMINAL_REPORT.md +34 -0
  123. package/skills/triage-issue/SKILL.md +148 -0
  124. package/skills/triage-issue/references/AUDIT_FINDINGS.md +35 -0
  125. package/skills/triage-issue/references/FOLD_LEDGER.md +32 -0
  126. package/skills/triage-issue/references/ISSUE_PROCESS.md +101 -0
  127. package/skills/triage-issue/references/LABELS.md +83 -0
  128. package/skills/triage-issue/references/REVIEW_FINDING_PROCESS.md +41 -0
  129. package/skills/verification-contract/SKILL.md +77 -0
  130. package/skills/workflow-status/SKILL.md +143 -0
  131. package/skills/workflow-status/references/CRASH_RECOVERY.md +66 -0
  132. package/skills/workflow-status/references/ENVELOPE_CORE.md +107 -0
  133. package/skills/workflow-status/references/ENVELOPE_FIELDS.md +77 -0
  134. package/skills/workflow-status/references/GUARDRAILS.md +17 -0
  135. package/skills/workflow-status/references/PORTABILITY.md +14 -0
  136. package/skills/workflow-status/references/SENSOR_CORE.md +95 -0
  137. package/skills/workflow-status/references/SENSOR_SIGNALS.md +128 -0
@@ -0,0 +1,54 @@
1
+ ## Whole-unit execution and portability
2
+
3
+ The normal omitted-phase command is already the batch:
4
+
5
+ ```text
6
+ /execute-phase <NN>
7
+ /execute-phase --fix <n>
8
+ ```
9
+
10
+ It selects every unfinished phase, gates and commits each one, skips
11
+ intermediate review stops, opens the PR, then recommends
12
+ `/loop-review-fold`. An explicit `P<n>` keeps the atomic/manual path.
13
+
14
+ ### Fresh-context driver (recommended for cheap models)
15
+
16
+ When the host has subagents or headless invocation, the unit-loop conductor
17
+ uses one fresh worker per phase and carries only `ACCEPTANCE.md`, the phase task
18
+ slice, and compact receipts. An external driver may implement the same contract:
19
+
20
+ 1. Call `workflow-status` and choose the next unfinished phase.
21
+ 2. Invoke `/execute-phase <unit> P<n>` on the cheap tool-capable tier.
22
+ 3. Repeat `CONTINUE`; route `READY_FOR_REVIEW` to `/loop-review-fold` on the
23
+ required review/fold tiers.
24
+ 4. Stop on `NEEDS_INPUT`, `HALT`, repeated unchanged evidence, or the declared
25
+ attempt budget.
26
+
27
+ The protocol and envelope repair loop live in
28
+ `docs/workflow/ORCHESTRATION.md`. The user still starts one driver run; fresh
29
+ contexts are an implementation detail.
30
+
31
+ ### Inline fallback
32
+
33
+ A host without fresh-worker primitives executes the same queue inline. After
34
+ each phase it reduces state to `progress.md`'s unit-loop receipt and never
35
+ re-reads prior raw context. This is less context-efficient but behaviorally
36
+ equivalent. A user who wants maximum control may pass explicit phases manually.
37
+
38
+ ### Model routing
39
+
40
+ - Planning and acceptance freezing use the strongest available model.
41
+ - Mechanical phase execution may use a cheaper tool-capable model.
42
+ - Review is never weaker than the writer and should use a different family
43
+ where practical.
44
+ - A subtle security/logic fold uses the strongest required tier even when
45
+ surrounding mechanical folds are cheap.
46
+ - Cap parallel workers below the provider's concurrency limit; on 429 reduce
47
+ fan-out rather than retrying at the same concurrency.
48
+
49
+ ### Missing platform features
50
+
51
+ - No slash menu → open the named `SKILL.md` and follow it literally.
52
+ - No model tiers → select tiers manually using the rules above.
53
+ - No subagents/headless runs → use the inline fallback.
54
+ - No external driver → the built-in omitted-phase loop remains available.
@@ -0,0 +1,74 @@
1
+ ## Implementation guidance (single-pass & per-phase)
2
+
3
+ **Tests first where they pay.** For core/domain and orchestration phases, write
4
+ the phase's acceptance/integration tests first (red), then implement to green —
5
+ the SPEC's dev scenarios are the test list, so its failure modes get exercised,
6
+ not just documented. UI and adapter glue may test after implementation.
7
+
8
+ Map each change to the project's layers per its architecture doc; build inner layers first, outer last:
9
+
10
+ 1. **Persistence/schema** (if any) — update where defined, generate migrations with the project's tooling, never hand-edit generated output.
11
+ 2. **Core/domain** — no outer-layer imports; use the project's value objects/rules.
12
+ 3. **Orchestration/use-case** — inject dependencies, idempotent if re-callable, typed errors.
13
+ 4. **Adapters** — implement the project's ports; never leak raw external errors inward.
14
+ 5. **Controller/endpoint** — map errors to responses; webhooks: verify signature, enqueue, return fast.
15
+ 6. **UI** (if any) — follow the design-system/i18n/accessibility docs; no hardcoded strings.
16
+ 7. **Tests** — whatever wasn't written first (see above): light mocks of the project's interfaces; test orchestration, not adapters.
17
+
18
+ ## Completion checklist (single-pass)
19
+
20
+ Write `docs/features/<NN>-<slug>/CHECKLIST.md`: schema migration applied (if any) · core layer has no outer imports · orchestration idempotent + typed errors · adapters implement ports · tests pass · type-check/lint green · UI strings localized (if UI) · domain value-object rules respected · user-facing limitations disclosed · new deps pinned. Note any decisions not captured in the SPEC.
21
+
22
+ ## Review checkpoint & finishing a unit
23
+
24
+ **Independent final review is mandatory — every unit gets one before merge.**
25
+ Recommend `loop-review-fold` because it preserves fresh review contexts while
26
+ handling bounded corrections; direct `review-change` is the manual path. Review
27
+ runs in its own turn (hand-off, not composed): a skill's model and
28
+ effort are fixed at turn start, so invoking `review-change` from here would run it at
29
+ execute-phase's `sonnet`/`medium` rather than its own `opus`/`high` — under-powering
30
+ the review. So **suggest** it; don't compose it. (General rule: across a model/effort
31
+ boundary, hand off; don't compose.) On agents without per-skill model config the same
32
+ rule holds by hand: run the review as a **separate, fresh invocation** on your
33
+ strongest model — never inline in the implementation run.
34
+
35
+ **Cadence.** Explicit-phase feature mode: after each completed phase, the closing block
36
+ **recommends** the hand-off whenever a *Review checkpoint trigger* fires
37
+ (layer boundary, accumulation, or sensitivity — see above), naming which one —
38
+ a suggestion the user may skip to keep executing phases. Whole-unit mode records
39
+ triggers and continues without intermediate hand-offs; the skill never blocks
40
+ on an intermediate review. What is **never optional** is the end: every
41
+ unit gets one `review-change` pass before merge (single-pass and `--fix`
42
+ included — they have no intermediate phases, so the end review is their only
43
+ one).
44
+
45
+ **Finishing a unit (single-pass, `--fix`, or a feature's final phase): the last step
46
+ is always an open PR.** Mark the unit `done`, commit the flip, push, and `gh pr create`
47
+ (see the mode steps above) — regardless of the review/audit still to come. Then hand
48
+ off to `/loop-review-fold` (recommended) or direct `/review-change`, which feeds
49
+ `audit-pr` (the merge gate).
50
+
51
+ **Adversarial pass at that mandatory end review.** `review-change` evaluates its
52
+ own recommendation checklist there (`L`/sensitive change, reviewer not the
53
+ fleet's strongest or weaker than the author, or a single model family on a
54
+ `≥M` change) and — only when a box fires — recommends `--adversarial N`
55
+ (N=2 default, N=3 on a security/auth surface or a single-family fleet) instead
56
+ of its default single-reviewer pass. This is evaluated once, at that mandatory
57
+ end review; it does not change the trigger-based checkpoint cadence above.
58
+
59
+ Checkpoint hand-off (print it — every invocation ends by suggesting the next
60
+ step; when a trigger fires, the review is the recommendation, continuing is a
61
+ listed alternative — the user picks):
62
+
63
+ ```
64
+ Phase <N> done and committed. Review checkpoint (recommended) — <trigger name> fired: <one-line reason>.
65
+ → Next: /review-change — it reviews the branch at its own model/effort
66
+ · skip the checkpoint → /execute-phase <NN> <next phase> (the mandatory end review still covers everything)
67
+ · findings (if you review) → fold fix-now into the branch; independent work stays a proposal until user triage; then re-review
68
+ ```
69
+
70
+ `<trigger name>` is one of `layer boundary`, `accumulation`, or `sensitivity`
71
+ (see *Review checkpoint triggers*); `<one-line reason>` cites the evidence
72
+ (e.g. "next phase declares `api`, this one was `domain`", "612 lines / 11
73
+ files since `a1b2c3d`", "phase touched auth middleware"). No trigger fired?
74
+ Omit the checkpoint line entirely and go straight to naming the next phase.
@@ -0,0 +1,35 @@
1
+ ## Descope guard (run before creating any issue during this unit)
2
+
3
+ A cheap way to look finished is to quietly convert unfinished SPEC scope into a
4
+ follow-up issue — the unit reads as done, the scope silently moved to the
5
+ backlog. Before creating **any** issue while executing this unit, classify it
6
+ with the fixed **descope test**:
7
+
8
+ - **Descope** — the issue's content overlaps a SPEC acceptance criterion or a
9
+ phase task that is **not fully delivered** in this unit.
10
+ - **Discovered work** — everything else (genuinely new, outside the SPEC's
11
+ promises) — record it as a proposal; only explicit user triage may file it.
12
+
13
+ **On a descope → STOP before creating the issue.** An issue may never be the
14
+ first record of a descope. The descope must first be recorded as an explicit,
15
+ **user-approved, dated SPEC amendment**:
16
+
17
+ 1. Get explicit user approval for the descope **first** (ask; never
18
+ self-authorize moving a criterion out of scope — the amendment row must
19
+ never be written before approval is in hand).
20
+ 2. **Only then** move the criterion/task out of the active `## Acceptance` (or
21
+ `## Phases` ledger), and log it in the governing SPEC's `## Amendments`
22
+ section (create the section if absent) with this canonical row format:
23
+ ```
24
+ - <YYYY-MM-DD> — descoped: "<criterion/task>" — approved by user — follow-up: #<n>
25
+ ```
26
+ 3. **Only when the user explicitly requests backlog creation**, create the
27
+ follow-up issue and **link the amendment** in its
28
+ body. Immediately after, edit the `## Amendments` row to replace the
29
+ `#<n>` placeholder with the real issue number, and commit that edit — a
30
+ row still reading the literal `#<n>` placeholder is unlinked and fails
31
+ `audit-pr`'s symmetric check.
32
+
33
+ `audit-pr`'s scope-bleed gate and `product-audit`'s recurrence signal both key
34
+ off this same `## Amendments` log — it is the single authoritative record of
35
+ every descope, defined once here.
@@ -0,0 +1,147 @@
1
+ ## Review checkpoint triggers (feature mode)
2
+
3
+ The recommended, skippable checkpoint fires on **what accumulated since the
4
+ last checkpoint**, not on a phase count — a phase-counter cadence re-miscalibrates
5
+ whenever phase size changes (see `#77`). After each phase commit, check all
6
+ three; recommend the checkpoint (naming which trigger fired) the moment any
7
+ one does:
8
+
9
+ 1. **Layer boundary** — the phase about to start declares a different
10
+ `Layer:` (the phase-lint enum) than the phase just committed. The just-closed
11
+ layer is a coherent reviewable unit.
12
+ 2. **Accumulation** — the unreviewed diff since the last-reviewed marker
13
+ exceeds **> 400 changed lines (insertions + deletions) OR > 8 changed
14
+ files**, measured with `git diff --stat <baseline>..HEAD`. Covers a long run
15
+ of small same-layer phases the layer-boundary trigger would miss.
16
+ 3. **Sensitivity** — the phase just committed touches auth, payments,
17
+ destructive migrations, secrets, or CI config → recommend an **immediate**
18
+ checkpoint on closing it, regardless of the other two triggers. This is a
19
+ **single-reviewer** recommendation and does not change `review-change`'s
20
+ own once-per-unit adversarial cadence (`skills/review-change/SKILL.md`
21
+ "Cadence — once per unit") — the two are independent mechanisms.
22
+
23
+ **Last-reviewed marker.** Home: `progress.md`'s header line
24
+ `Last reviewed: <sha>`. Sole writer: `execute-phase` — stamped with the
25
+ just-committed phase's sha immediately after a checkpoint is taken (review
26
+ happens in a separate turn, so this skill records the marker at the start of
27
+ the *next* phase it executes, using the sha the user confirmed was reviewed).
28
+ If the marker is absent (unit's first checkpoint, or a legacy `progress.md`
29
+ predating this rule), the baseline is `git merge-base <default-branch> HEAD` —
30
+ never treat a missing marker as a blocker or crash condition.
31
+
32
+ ## Allowed & forbidden (fixed lists — no interpretation)
33
+
34
+ **Allowed changes in a phase:**
35
+ - The phase's own tasks (from `TASKS.md`, or the SPEC for single-pass/fix)
36
+ - Tests for the behavior this phase adds or alters
37
+ - The per-phase doc updates listed in the completion gate below
38
+ - The smallest refactor strictly required to land a task (state why in the commit)
39
+ - An `Autofix` or `Opportunistic Fix` that passes every box in the
40
+ *Opportunistic finding policy* below
41
+
42
+ **Forbidden — never, even if it "would help":**
43
+ - New abstractions beyond what the SPEC names (an interface with one
44
+ implementation is a violation)
45
+ - New dependencies not justified in the SPEC
46
+ - Public API / contract changes the SPEC doesn't name
47
+ - Architecture changes (layers, boundaries, patterns)
48
+ - Refactoring unrelated code
49
+ - Building future phases or features early
50
+ - Folding a discovered finding into the branch before it passes the
51
+ *Opportunistic finding policy*
52
+ - Creating an issue that descopes a SPEC acceptance criterion or phase task
53
+ without a user-approved, dated `## Amendments` entry (see *Descope guard*
54
+ under *Issue policy* below) — an issue may never be the first record of a
55
+ descope
56
+
57
+ Something forbidden looks necessary → stop, record it in `decisions.md` or
58
+ `known-issues.md`, and surface it — never do it silently.
59
+
60
+ ## Phase completion gate — pass only if (every box, every phase)
61
+
62
+ ```
63
+ ✓ Verification gate green — type-check + tests + build actually RUN (paste exit
64
+ status), never assumed
65
+ ✓ Every task of this phase checked off in TASKS.md, each mapped to evidence
66
+ (code path or test name)
67
+ ✓ Tests updated/added for every behavior this phase changed
68
+ ✓ No TODO/FIXME/HACK markers left in the diff
69
+ ✓ No duplicated logic (reuse the existing helper — cite it if one existed)
70
+ ✓ No dead code introduced (unused imports, functions, unreachable branches)
71
+ ✓ No hidden breaking change (changed public contracts diffed against their
72
+ consumers)
73
+ ✓ Architecture doc respected (dependency directions, layer boundaries)
74
+ ✓ Architectural invariants preserved or backed by an explicit recorded decision
75
+ ✓ Docs updated — at minimum verify each of: TASKS.md (checkboxes),
76
+ progress.md (one handoff entry in the fixed schema — Done / Remains /
77
+ Gotchas / Files / Next), testing.md, known-issues.md, decisions.md (if any
78
+ decision was taken), SPEC.md (only if scope/acceptance changed — with the
79
+ change logged), docs/CAPABILITIES.md (only if this phase introduced a new
80
+ cross-cutting subsystem, role, or permission — append the row, additive,
81
+ never rewrite existing ones; explicitly n/a when the project has no
82
+ inventory file)
83
+ ✓ Docs COMMITTED with the phase — after the phase commit,
84
+ `git status --porcelain -- docs/` returns nothing. Doc updates ride the
85
+ phase commit (same `git add`), never sit uncommitted "for later"
86
+ ```
87
+
88
+ A phase that cannot tick every box is **not done**: fix within the phase's
89
+ scope, or record the blocker in `known-issues.md`, leave the work uncommitted,
90
+ and stop with a clear report. Never commit red; never tick a box you didn't
91
+ verify.
92
+
93
+ ## Branch
94
+
95
+ | Mode | Format |
96
+ |------|--------|
97
+ | feature / single-pass | `feat/<NN>-<slug>` |
98
+ | `--fix` | `fix/<issue-number>-<topic>` |
99
+
100
+ Read the SPEC's `Branch` field; create with `git switch -c <name>`. If absent/ambiguous, ask. Never commit, amend, or force-push on `main`.
101
+
102
+ **Honor the project's declared Git workflow** (Workflow conventions — `branches`
103
+ or `worktrees`). Default and assumption everywhere: **`branches`** — one active
104
+ unit at a time, sequential, plain `git switch -c`; **never create a worktree**.
105
+ Only when the project explicitly declares `worktrees` may a unit get its own
106
+ checkout — and then one worktree per unit, removed after merge.
107
+
108
+ ## Normalized Repository State
109
+
110
+ When present, consume frozen facts and decisions in
111
+ `docs/workflow/REPOSITORY_STATE.md`. Inspect directly only for an absent fact;
112
+ route contradictory evidence to `resolve-repository-state`. Documentation,
113
+ planned work, and inference never prove implementation. A present ledger whose
114
+ status is `draft`, `contradicted`, or `resolved` stops implementation and routes
115
+ to discovery or resolution first. If no ledger exists, inspect the repository
116
+ directly and record `n/a: no normalized repository state`; NRS is optional.
117
+
118
+ ## Architectural invariants
119
+
120
+ Before any edit, discover the optional project invariant document declared in
121
+ the documentation map (normally
122
+ `docs/architecture/ARCHITECTURAL_INVARIANTS.md`). If absent, record
123
+ `n/a: no project invariants declared` and continue. For every applicable rule,
124
+ cite its ID and repository evidence and classify the phase as `preserves`,
125
+ `violates`, `introduces`, or `changes`. Use frozen NRS facts when present, but
126
+ the repository remains authoritative and conflicting evidence routes to the
127
+ resolver.
128
+
129
+ Only `preserves` may continue. A `violates`, `introduces`, or `changes` result
130
+ stops before edits and requires an explicit architectural decision through the
131
+ project's declared authority. A decision record alone is not sufficient: the
132
+ declared authority must apply the decision to the invariant document, and the
133
+ resulting rule must be re-evaluated and evidenced as `preserves` before the
134
+ phase can resume. The executor does not edit the invariant document itself.
135
+ Do not alter the SPEC or tests to make the phase pass, and do not convert the
136
+ decision into phase work. Return exactly:
137
+
138
+ ```
139
+ ARCHITECTURAL INVARIANT GATE — <NN|fix n> <P<k>|single-pass> BLOCKED
140
+ Invariant: <ID> — <violates|introduces|changes>
141
+ Evidence: <repository path:line or command result>
142
+ Decision required: <project-declared architectural authority>
143
+
144
+ → Next: <decision path> — record the explicit architectural decision, then re-run this phase
145
+ · evidence conflict → /resolve-repository-state — reconcile the frozen fact first
146
+ · no invariant document → record n/a and continue only when no other rule applies
147
+ ```
@@ -0,0 +1,73 @@
1
+ ### Folding review / audit findings (a first-class mini-cycle)
2
+
3
+ **`/fold-findings` is the standalone skill for this cycle** — it carries the
4
+ full frozen-classification rule and forbidden list (no known-issues dump, no
5
+ severity downgrade, no test loosening, no suppression-as-fix) as a fixed,
6
+ independently-invocable contract; prefer it as a fresh hand-off (its own
7
+ turn, its own model/effort) whenever one is available. The checklist below is
8
+ the in-context / portability fallback for folding inline within this skill's
9
+ own turn (e.g. no slash-command menu, or an agent that folds without leaving
10
+ its current context).
11
+
12
+ When `review-change` findings (fix-now) or `audit-pr` blockers are folded back
13
+ into a branch that already has an open PR, the fold is complete **only** when
14
+ every step below ran — fixing the code and stopping is the classic way findings
15
+ end up "solved" locally but absent from the merged PR:
16
+
17
+ ```
18
+ ✓ Fixes implemented (scope: only the routed findings — nothing extra)
19
+ ✓ Gate RUN and green (exit codes pasted)
20
+ ✓ Per-phase / unit docs updated where the finding touched them
21
+ (known-issues.md entry resolved? progress.md notes the fold)
22
+ ✓ Each folded finding's row in the unit's `review-findings.md` ledger (if one
23
+ exists — the ledger is optional; a unit with no fix-now findings has none)
24
+ flipped `folded: no → yes` — the one and only ledger state transition, owned
25
+ solely by this fold cycle
26
+ ✓ `git add` + `git commit` RUN (sha pasted) — e.g.
27
+ `fix(<scope>): fold review findings — <summary>`
28
+ ✓ `git push` RUN (PR is open → every commit pushes immediately)
29
+ ✓ `git status --porcelain` RUN → empty; `git status -sb` → not ahead of remote
30
+ ```
31
+
32
+ Then hand back to the gate that sent you (`/review-change` re-review, or
33
+ `/audit-pr` re-audit). Never report findings as resolved while any box is
34
+ unchecked — an unpushed fix does not exist for CI, the reviewer, or the merge.
35
+
36
+ Final-phase / single-pass / fix hand-off:
37
+
38
+ ```
39
+ <unit> implemented, gate green, marked done.
40
+ PR opened: <FULL PR URL — always printed here; not every agent shows open PRs>
41
+ Roadmap/fix-index row: done · #<n> (linked and pushed)
42
+ → Next: /loop-review-fold <unit> (recommended review/fold router; unresolved findings go to triage/replan)
43
+ · manual path → /review-change
44
+ · clean → /audit-pr (merge gate) → human merges
45
+ · findings → fold fix-now into this PR; independent work remains a proposal until user triage; re-review
46
+ · docs site declared (documentation map has a `Docs site` block) →
47
+ /generate-docs <unit> — document what this unit changed; the generated
48
+ pages ride this same PR (commit + push them before the merge gate)
49
+ ```
50
+
51
+ The `/generate-docs` line appears **only** when the project's documentation
52
+ map declares a `Docs site` block — never suggest it otherwise (a project
53
+ without a docs site has nowhere to publish).
54
+
55
+ This never auto-merges. Explicit `P<n>` stops after one phase; omitted-phase
56
+ mode gates and commits every remaining phase before the same final review.
57
+
58
+ ### Marking done (status semantics)
59
+
60
+ A unit flips to **`done` when its last step runs — opening the PR — even though it
61
+ isn't merged yet.** `done` means *built and PR-open*; merge state lives in the forge
62
+ (the open/merged PR), not in the status. **A `done` row always carries its PR
63
+ reference** — `done · [#<pr>](<pr-url>)` — added right after `gh pr create`
64
+ returns the URL (follow-up `docs: link PR #<n>` commit on the same branch);
65
+ `done` without a PR link is the tell-tale of an unfinished close-out. The flip is a doc change, so it rides the
66
+ PR-bound commit (never a lone commit on the default branch). **Never merge with docs
67
+ still pending, and never drop the issue / fix-index entry before merge** — those are
68
+ `audit-pr`'s gates, not removed at done-time.
69
+
70
+ **One phase = one worker context when available.** Whole-unit mode is one user
71
+ invocation, not one growing raw context: subagent/headless hosts use a fresh
72
+ worker per phase; inline-only hosts reduce state to compact receipts. Explicit
73
+ phase invocation remains the strict fresh-conversation fallback.
@@ -0,0 +1,24 @@
1
+ ## Forge body policy
2
+
3
+ Forge operations use the project's declared forge CLI (Workflow conventions —
4
+ examples use `gh`; translate if the project declares another forge).
5
+
6
+ > **Forge bodies are Markdown, not shell — never hand-escape them.** Backticks,
7
+ > `*`, `_`, `#`, `|` in an issue / PR / comment body are **formatting**; a `\`
8
+ > before them renders **literally** (`` \`code\` `` instead of `` `code` ``) —
9
+ > the #1 forge-formatting bug (worse on some agents than others). Fix it at the
10
+ > source: **never pass a Markdown body inline** (`--body "…"`, a quoted
11
+ > `<<'EOF'` heredoc, or single quotes — all of these preserve a stray `\` or
12
+ > mangle backticks). Instead **write the body to a file with the Write tool**
13
+ > (plain Markdown — real backticks, zero backslashes; scratchpad is fine) and
14
+ > pass **`--body-file <path>`**: `gh issue create --body-file <path>`,
15
+ > `gh pr create --body-file <path>`, `gh issue comment <n> --body-file <path>`
16
+ > (or the declared forge's equivalent). Short one-liners with no Markdown (e.g.
17
+ > a bare `Closes #12`) may stay inline. **Verify after creating:**
18
+ > `gh issue view <n> --json body` / `gh pr view <n> --json body` must show
19
+ > backticks rendering — a literal `` \` `` in the output means redo it with
20
+ > `--body-file`.
21
+
22
+ - **`--fix`:** every fix needs a tracked issue; create with `gh issue create --template fix.yml --body-file <path>` if missing, populating the body from the SPEC (body as a Markdown file — see the Markdown rule above). Use the returned number for branch and folder.
23
+ - **feature:** if it came from an issue, include `Closes #<n>` in the PR body. Don't create issues for features that didn't originate from one.
24
+ - **Language precedence for every artifact** (issues, PRs, commits, SPECs, docs): (1) an explicit user instruction in the prompt, else (2) the project's declared docs language (Workflow conventions), else (3) English. The conversation language is NOT a signal — being asked in Spanish never makes the PR Spanish. Non-matching source material gets translated first.
@@ -0,0 +1,21 @@
1
+ ## Phase handoff record (`progress.md` — fixed schema)
2
+
3
+ Every phase ends by APPENDING one entry to the unit's `progress.md`. Feature
4
+ mode: the file `plan-feature-scaffold` created. Phased XS/S single-pass and
5
+ `--fix` units: create `progress.md` beside the SPEC on P1 (the SPEC's
6
+ checkboxes stay the task ledger; this file is the **handoff channel**).
7
+ Fixed schema — all five lines present, `none` is valid, free prose is not:
8
+
9
+ ```
10
+ ## P<k> — <YYYY-MM-DD>
11
+ - Done: <the phase's delivered tasks, one line>
12
+ - Remains: <in-unit work still open, or none>
13
+ - Gotchas: <surprises, workarounds, or decisions the NEXT phase must know, or none>
14
+ - Files: <paths touched>
15
+ - Next: P<k+1> — <its title> | unit finished
16
+ ```
17
+
18
+ The entry rides the phase commit (no sha in the entry — the carrying commit is
19
+ the phase sha; `git log` resolves it). The next phase starts in a fresh
20
+ conversation and reads only `SPEC.md`, its phase's `TASKS.md` section (or SPEC
21
+ `## Phases`), and `progress.md`. Never rely on prior-session memory.
@@ -0,0 +1,45 @@
1
+ ## Opportunistic finding policy
2
+
3
+ Use this only for genuinely out-of-scope work discovered while implementing the
4
+ current unit. Missing acceptance, correctness, security, accessibility, required
5
+ UX/error behavior, or a phase task remains current-unit work — fix/replan/decide
6
+ inside the unit; it is never a proposal or issue.
7
+
8
+ ### Closed decision ladder
9
+
10
+ Evaluate rows in order; every box in a selected row must pass. Estimates include
11
+ tests and docs.
12
+
13
+ | Decision | Pass only if every box is true | Action |
14
+ |---|---|---|
15
+ | **Autofix** | ≤15 lines; ≤2 files; files already touched; low risk; no public API/schema/migration/dependency/permission/architecture/user-visible change; objective unchanged | Fix in the current phase commit and run its gate. |
16
+ | **Opportunistic Fix** | ≤40 lines; ≤3 files; files touched or directly covered by the phase test; supports touched behavior/consistency; low risk; no public API/schema/migration/dependency/permission/architecture/acceptance change; objective unchanged | Fix in the phase commit, add focused behavior coverage, run the gate. |
17
+ | **Proposal** | Either fix row fails, evidence is uncertain, work is independent, or product/risk judgment is needed | Do not edit or create an issue. Record a compact proposal with evidence and trigger for explicit user batch triage. |
18
+
19
+ `≤` is inclusive. Check Opportunistic Fix even after a non-size Autofix failure.
20
+ More than 40 lines/3 files is a Proposal unless it is current-unit work, in
21
+ which case it is `replan-in-unit` and stays on the same branch/PR.
22
+
23
+ ### Record before acting
24
+
25
+ Append one row to `decisions.md` before editing/recording:
26
+
27
+ ```markdown
28
+ | Date | Finding | Evidence | Estimate | Risk | Local files | Decision | Why | Trigger | Record |
29
+ |---|---|---|---|---|---|---|---|---|---|
30
+ | <date> | <finding> | <file:line/command> | <lines/files> | <low/med/high> | <yes/no + paths> | <Autofix/Opportunistic Fix/Proposal> | <boxes> | <when to reconsider> | <commit sha|proposal> |
31
+ ```
32
+
33
+ For a Proposal, `Record` stays `proposal`; no forge operation runs. Batch the
34
+ proposal in the unit's final report. Only an explicit user invocation of
35
+ `triage-issue`/the project's backlog intake may create tracked work, where it
36
+ must dedupe against existing issues first.
37
+
38
+ ### Guardrails
39
+
40
+ - No automatic `gh issue create` or equivalent from execution, review, fold,
41
+ audit, or their loops.
42
+ - Never use Proposal to move unfinished SPEC/task scope out of the unit.
43
+ - An uncertain classification becomes Proposal and may stop for user judgment;
44
+ it never authorizes adjacent edits.
45
+ - `known-issues.md` records blockers, not a substitute backlog.
@@ -0,0 +1,152 @@
1
+ ## Dependency gate (always, before any other step)
2
+
3
+ Run this check for **every** mode (feature phase, single-pass, and `--fix`)
4
+ before touching anything:
5
+
6
+ 1. Read the unit's `Depends on:` (SPEC) and its roadmap/fix-index row.
7
+ 2. Build the **transitive closure**: for each dependency, read *its* roadmap
8
+ row and collect its dependencies too, until none remain.
9
+ 3. For each entry in the closure, its status must be **merged in the forge**
10
+ (`gh pr view` on its PR, or the row's PR reference) — `done`-but-PR-open is
11
+ NOT met (its code isn't on the default branch), and a missing folder/row is
12
+ NOT met.
13
+ 4. **All met** → proceed to the **own-status precondition** below.
14
+ 5. **Any unmet → STOP before any edit** and print exactly:
15
+
16
+ ```
17
+ DEPENDENCY GATE — <NN>-<slug> BLOCKED
18
+ Unmet chain (deepest first is the one to start):
19
+ <NN> ← <dep> (<status>) [← <dep-of-dep> (<status>) …]
20
+ Build order to unblock: <deepest> → … → <NN>
21
+
22
+ → Next: /execute-phase <deepest> P1 — the deepest unmet dependency (plan it
23
+ first with /plan-feature <deepest> if it has no SPEC)
24
+ · fix-type dependency → /plan-fix then /execute-phase --fix
25
+ · proceed anyway, at your own risk → /execute-phase <NN> <phase> --force
26
+ (the override is recorded in decisions.md — never silent)
27
+ ```
28
+
29
+ 6. **`--force`** skips the stop (never the check): the gate still runs and its
30
+ result is **recorded in `decisions.md`** ("started with unmet deps: <list>,
31
+ user-forced <date>") before implementation begins. `--force` is a
32
+ user-only escape hatch — the autopilot (`ship-roadmap`) must never pass it.
33
+
34
+ ### Dependency receipt (v1) + fail-closed fast path
35
+
36
+ After a full pass with every dependency merged, append to the unit's `progress.md`:
37
+
38
+ ```
39
+ ## Dependency receipt v1
40
+ - Fingerprint: <sha> · Closure: <NN>-<slug> ← <dep> …
41
+ - Merged PRs: <dep> #<n> @ <merge sha> · Fully merged: yes · Verified: <date>
42
+ ```
43
+
44
+ Fingerprint = `git hash-object --stdin` over the SPEC `Depends on:` line and
45
+ each closure roadmap row (rows encode the merged PR, e.g. `22-other #7 @ a1b2c3
46
+ merged`). PR identities are provenance in the receipt, never fingerprint input —
47
+ the fingerprint covers only inputs the fast path can re-derive locally.
48
+
49
+ **Fast path (local only, no forge calls):** recompute the fingerprint (SPEC +
50
+ roadmap rows). Skip forge traversal **only when** a `v1` receipt exists, the
51
+ recomputed fingerprint matches, it records `Fully merged: yes`, and no `--force`
52
+ is recorded in `decisions.md` after the receipt date.
53
+
54
+ **Fail closed — invalidate and rerun the full gate** on any of: fingerprint
55
+ mismatch (graph changed), missing or older-version receipt (format drift), a
56
+ later `--force`, or the full gate itself finding an unmet dependency. On any
57
+ ambiguity never skip forge traversal; rewrite the receipt after every full pass.
58
+
59
+ ### Own-status precondition (runs after the dependency closure is met, still before any edit)
60
+
61
+ Feature mode only (a fix has no roadmap-status equivalent — its own state is
62
+ the fix-index entry, unaffected). Read this unit's own roadmap row status
63
+ (the five-state machine — `docs/features/ROADMAP.md` → Status legend):
64
+
65
+ 1. **`idea`** (or no `SPEC.md` with `## Design status: designed`) → STOP,
66
+ before any edit:
67
+
68
+ ```
69
+ OWN-STATUS GATE — <NN>-<slug> BLOCKED (idea)
70
+ This unit has no completed product design yet.
71
+
72
+ → Next: /design-feature <slug> — write the product half first
73
+ · proceed anyway, at your own risk → /execute-phase <NN> <phase> --force
74
+ (the override is recorded in decisions.md — never silent)
75
+ ```
76
+
77
+ 2. **`defined`** (product half designed, engineering half / planning
78
+ artifacts not yet scaffolded) → STOP:
79
+
80
+ ```
81
+ OWN-STATUS GATE — <NN>-<slug> BLOCKED (defined)
82
+ Product half designed; engineering half + planning artifacts not yet scaffolded.
83
+
84
+ → Next: /plan-feature <NN>-<slug> — scaffold the engineering half + TASKS.md
85
+ · proceed anyway, at your own risk → /execute-phase <NN> <phase> --force
86
+ (the override is recorded in decisions.md — never silent)
87
+ ```
88
+
89
+ 3. **`planned`+** → proceed to the normal workflow.
90
+ 4. **Legacy compat.** A row still reading a plain `planned` with no
91
+ five-state history: check its `SPEC.md` product half. Complete
92
+ (`## Design status: designed`) → treat as `defined`+`planned`, no
93
+ redirect. Incomplete/absent → treat as `idea`, redirect per step 1. See
94
+ `docs/workflow/MIGRATION.md`.
95
+ 5. **`--force`** skips the STOP (never the check), same rule as the
96
+ dependency gate: recorded in `decisions.md` before implementation begins;
97
+ the autopilot (`ship-roadmap`) must never pass it.
98
+
99
+ ## Acceptance-manifest gate (after dependency/own-status, before phase-lint)
100
+
101
+ Consume `skills/verification-contract/SKILL.md`. For a current-format unit,
102
+ validate sibling `ACCEPTANCE.md`, run `git hash-object` on it, and compare the
103
+ blob to `progress.md`'s `Acceptance receipt v1`.
104
+
105
+ - No receipt on the first phase → append the receipt before edits; it rides the
106
+ first phase/planning-artifact commit. The just-computed blob is the baseline.
107
+ - Exact receipt match → continue.
108
+ - Missing/mismatched manifest → print the verification contract's fixed
109
+ `ACCEPTANCE GATE` block and stop. `--force` never bypasses a changed finish line.
110
+ - Legacy unit with no manifest reference in its planning artifacts → hash the
111
+ committed `SPEC.md`, record `Manifest: legacy SPEC.md`, and apply the same
112
+ exact-blob rule.
113
+
114
+ Run this check again immediately before each phase in whole-unit mode and before
115
+ final close-out. The executor may add tests but may not narrow commands, weaken
116
+ assertions, or edit acceptance to make a candidate pass.
117
+
118
+ ## Phase-lint pre-flight guard (always, before any edit — after the dependency/own-status gates)
119
+
120
+ **Legacy-SPEC carve-out (check this first, before anything else in this
121
+ section):** if the target SPEC has **no `## Phases` section**, skip this
122
+ guard entirely — no lint run, no STOP — and fall straight through to the
123
+ legacy single-pass flow ("A SPEC without `## Phases`
124
+ … runs the legacy flow … end-to-end in one pass" — see
125
+ [legacy workflow](WORKFLOWS_LEGACY.md)). The guard below applies
126
+ only to a SPEC that carries a `## Phases` ledger.
127
+
128
+ Before touching any code, run the canonical 8-box phase-lint owned by
129
+ `skills/phase-contract/SKILL.md` (the fixed PASS/BLOCKED block and the
130
+ normalized phase fingerprint) against the **target phase** (its title,
131
+ declared layer, task list, and done-when).
132
+
133
+ 1. **All 8 boxes tick** → proceed to the normal workflow.
134
+ 2. **Any box FAILs → STOP before any edit** and print exactly:
135
+
136
+ ```
137
+ PHASE-LINT GATE — <NN|n>-<slug> <phase> BLOCKED
138
+ Failed boxes:
139
+ ✗ <box label> — <one-line reason>
140
+ [✗ <box label> — <one-line reason>] …
141
+
142
+ → Next: /plan-feature <NN> — re-cut or split the phase (feature)
143
+ · fix-type unit → /plan-fix — re-cut or split the phase
144
+ · proceed anyway, at your own risk → /execute-phase <NN|--fix n> <phase> --force
145
+ (the override is recorded in decisions.md — never silent)
146
+ ```
147
+
148
+ 3. **`--force`** skips the STOP (never the check): the lint still runs and its
149
+ result is **recorded in `decisions.md`** (feature mode) or the fix SPEC's
150
+ own notes / `progress.md` if present ("executed non-atomic phase: <failed
151
+ boxes>, user-forced <date>") before implementation begins. `--force` is a
152
+ user-only escape hatch — the autopilot (`ship-roadmap`) must never pass it.