@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,168 @@
1
+ ---
2
+ name: loop-review-fold
3
+ user-invocable: true
4
+ version: 2.0.0
5
+ argument-hint: <NN> | --fix <issue-number>
6
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
7
+ license: MIT
8
+ description: >
9
+ Run the simple review-change/fold-findings loop for an open feature or fix
10
+ unit. Inspect persisted review evidence first so a previous review resumes
11
+ with fold-findings instead of reviewing the same candidate again. Unresolved
12
+ findings go to triage-issue with an immediate-fix instruction; oversized
13
+ findings become a user-confirmed plan-feature or plan-fix replan with new
14
+ phases. Triggers: "loop-review-fold", "review and fold this PR", "run the
15
+ review fold loop".
16
+ ---
17
+
18
+ # Review / Fold Loop
19
+
20
+ Run one small state loop over the current feature or fix unit:
21
+
22
+ ```text
23
+ review-change ── findings ──▶ fold-findings ── changed HEAD ──▶ review-change
24
+ ▲ │
25
+ └──────── current PASS ◀───────┘
26
+ └─ unresolved ─▶ triage-issue
27
+ ```
28
+
29
+ This skill is a router, not a third review or repair implementation. It reads
30
+ the durable evidence left by `review-change` and `fold-findings`, chooses the
31
+ next action, and stops when a user decision or manual phase execution is
32
+ required. Never merge, create an unrelated issue, or silently discard a
33
+ finding.
34
+
35
+ ## Turn contract
36
+
37
+ ```text
38
+ ✓ The feature/fix unit, branch, PR, current HEAD, acceptance, and finding ledger were checked
39
+ ✓ The first action was selected from persisted evidence: PASS, review-change, or fold-findings
40
+ ✓ review-change ran only when no current review result required fold-findings first
41
+ ✓ A successful fold was followed by review-change on the new HEAD
42
+ ✓ Every unresolved finding is named and routed to triage-issue --prioritize-now
43
+ ✓ An oversized finding routes to plan-feature or plan-fix, new P<n> phases, and manual user execution
44
+ ✓ No merge, unrelated issue, acceptance weakening, or silent finding drop occurred
45
+ ✓ The fixed result and the closing → Next: block are the final output
46
+ ```
47
+
48
+ Any unchecked box means the turn is not done.
49
+
50
+ ## When to use
51
+
52
+ Use after `execute-phase` opens the unit PR, or when the user asks to review and
53
+ fold an open feature or fix. The argument identifies the unit:
54
+
55
+ - `/loop-review-fold <NN>` for a feature unit.
56
+ - `/loop-review-fold --fix <issue-number>` for a fix unit.
57
+
58
+ Do not use this entrypoint to edit this skill, inspect its implementation as the
59
+ requested deliverable, or invent a target when the unit argument is missing.
60
+
61
+ ## Step 0 — Discover the project (always first)
62
+
63
+ Read the target project's agent guide and documentation map. Then verify the
64
+ target unit, current branch, open PR, remote HEAD, frozen acceptance artifact,
65
+ the latest `review-change` result/receipt, and the unit's `review-findings.md`.
66
+ Use repository and forge commands required by the project's own conventions.
67
+ Narration, an old chat result, or a clean worktree alone is not evidence.
68
+
69
+ If the target, PR, acceptance, or ledger cannot be verified, stop with
70
+ `BLOCKED` and name the exact missing input and recovery command. Do not create
71
+ replacement artifacts in this router.
72
+
73
+ ## Process
74
+
75
+ Apply this first-match table exactly:
76
+
77
+ | Persisted state on the current HEAD | First action |
78
+ |---|---|
79
+ | Exact current `REVIEW-PASS`, matching acceptance, and no open finding rows | `PASS`; do not run either skill |
80
+ | A review result exists for this HEAD and it leaves any `folded: no` row | `fold-findings` on the complete open queue |
81
+ | No usable current review result and no open queue | `review-change` on the current HEAD |
82
+
83
+ Then continue as follows:
84
+
85
+ 1. Run the selected skill in its own fresh context and follow that skill's
86
+ contract literally. This loop does not copy its internal checklist.
87
+ 2. If `review-change` returns `REVIEW-PASS`, verify its exact-HEAD receipt and
88
+ zero open rows, then return `PASS`.
89
+ 3. If `review-change` returns findings, run `fold-findings` for every open
90
+ `fix-now` row. Do not start another review before that queue is processed.
91
+ 4. If `fold-findings` changes and pushes the candidate, run `review-change` on
92
+ that new HEAD. Never review an unchanged HEAD a second time.
93
+ 5. If any finding remains unresolved (`DISPUTED`, `BLOCKED`, `REPLAN`, or an
94
+ open row left after folding), stop the loop and hand every such ID to:
95
+
96
+ ```text
97
+ /triage-issue --prioritize-now <unit-or-fix> F1 F2 ...
98
+ ```
99
+
100
+ Tell `triage-issue` to try to resolve every named finding immediately. It
101
+ may route a small correction back to the current unit, but it must not hide,
102
+ downgrade, or postpone a review finding merely to finish the loop.
103
+ 6. When the smallest correct correction is too large for the current fold,
104
+ `triage-issue` must choose a replan route: re-run `/plan-feature <slug>` for
105
+ a feature or `/plan-fix <issue-number>` for a fix, append explicit new
106
+ `P<n>` phases to the unit's SPEC, and stop. The loop then asks the user to
107
+ execute those phases manually with `/execute-phase <unit> P<n>` (or the
108
+ fix equivalent) before invoking this loop again.
109
+
110
+ Do not use a hidden retry count. The loop ends at the first `PASS`, blocked
111
+ prerequisite, unresolved finding, or required manual replan. A later user
112
+ invocation starts from the newly persisted state.
113
+
114
+ ## Fixed output contract
115
+
116
+ Return exactly:
117
+
118
+ ```text
119
+ REVIEW-FOLD LOOP — PASS | TRIAGE-REQUIRED | BLOCKED
120
+ Unit: <unit> · PR: <url> · HEAD: <sha>
121
+ First action: PASS | review-change | fold-findings
122
+ Review: <PASS | FAIL | not-run> · Fold: <changed | unchanged | not-run>
123
+ Unresolved: <F1 + F2 + … | none>
124
+ Evidence: <one concise line explaining the selected action and result>
125
+
126
+ → Next: <one concrete command or user action> — <why>
127
+ · <alternative when applicable>
128
+ ```
129
+
130
+ Use `TRIAGE-REQUIRED` whenever a finding needs `triage-issue`, a replan, or a
131
+ user decision. Replace every placeholder, list each actual finding ID exactly
132
+ once joined with ` + `, and never emit a literal ellipsis.
133
+
134
+ ## Guardrails
135
+
136
+ Allowed: read target evidence, invoke `review-change`, invoke `fold-findings`,
137
+ and route unresolved findings to `triage-issue`.
138
+
139
+ Forbidden: implementing a fix in this router, editing review classifications,
140
+ marking findings folded, creating unrelated issues, weakening acceptance or
141
+ checks, merging, or claiming that a user has implemented newly planned phases.
142
+
143
+ ## Relationship to other skills
144
+
145
+ `execute-phase` hands off here after a unit PR opens. `review-change` owns
146
+ read-only classification and the SHA-bound pass receipt. `fold-findings` owns
147
+ the actual correction and ledger tick. `triage-issue --prioritize-now` owns the
148
+ decision for unresolved findings and routes oversized work to `plan-feature` or
149
+ `plan-fix`; the user then executes the appended phases manually.
150
+
151
+ ## Portability (agents other than Claude Code)
152
+
153
+ If fresh contexts or subagents are unavailable, invoke each delegated skill in
154
+ a new conversation and re-read the persisted HEAD, receipt, and ledger before
155
+ continuing. If the host has no slash-command menu, open each named `SKILL.md`
156
+ and follow it literally. Never claim a clean review after the same context
157
+ implemented the correction.
158
+
159
+ ## Done when
160
+
161
+ The current HEAD has a verified `REVIEW-PASS` and no open findings, or every
162
+ remaining finding has a concrete triage/replan hand-off and the user has been
163
+ told to implement the new phases manually.
164
+
165
+ → Next: print the matching terminal route from the fixed output contract — never send a non-PASS result to audit-pr
166
+ · PASS → /audit-pr — consume the current exact-HEAD REVIEW-PASS
167
+ · TRIAGE-REQUIRED → /triage-issue --prioritize-now <unit> F<k> — resolve every actual unresolved finding, then plan/execute new phases manually
168
+ · BLOCKED → the exact recovery command — supply the missing target, PR, acceptance, or ledger input before re-running the loop
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: orchestration-envelope
3
+ user-invocable: false
4
+ version: 2.0.2
5
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
6
+ license: MIT
7
+ description: >
8
+ Internal machine-result contract for headless agentic-workflow drivers. The
9
+ executable source is @gtrabanco/agentic-workflow-schema: strict Envelope v2
10
+ for workflow-status, compact SkillOutcome v1 for driven work, compatibility
11
+ parsing, and deterministic document snapshots. Not a menu entry.
12
+ ---
13
+
14
+ # Machine result contract (internal)
15
+
16
+ Interactive skills remain text-first. A headless driver obtains a compact,
17
+ validated result at the boundary; it does not add a repeated JSON section to
18
+ every user-facing skill.
19
+
20
+ The canonical [Turn contract](references/TURN_CONTRACT.md) remains here for
21
+ the executor and review skills that load it.
22
+
23
+ The executable source of truth is
24
+ [`@gtrabanco/agentic-workflow-schema`](../../packages/agentic-workflow-schema/):
25
+ types, JSON Schemas, `renderOutputInstruction(skill)`, `parseTurn(input)`, and
26
+ `compileWorkflowSnapshot(input)`. This document states the policy only; do not
27
+ copy a second schema here.
28
+
29
+ ## Output profiles
30
+
31
+ `WORKFLOW_SKILL_PROFILES` is the authoritative inventory.
32
+
33
+ - `workflow-status` always returns the strict **Envelope v2** sensor result.
34
+ Its envelope includes the detailed project view under `detail`.
35
+ - The other driver-invoked skills return **SkillOutcome v1** only when the
36
+ driver appends `renderOutputInstruction(skill)` to that invocation. It has
37
+ the small model-owned fields: outcome, next intent/targets, blockers,
38
+ questions, discoveries, and evidence references.
39
+ - `ship-roadmap` is the conductor, not a worker profile: it keeps its native
40
+ terminal `SHIP:` banner and is parsed by its own fixed turn contract.
41
+ - Interactive invocations emit their normal human-readable reports; no driver
42
+ result is required.
43
+
44
+ Both results are one final fenced `json` block. The package rejects unknown
45
+ keys at the routing boundary. Repository facts are never reconstructed from
46
+ model prose: the driver compiles `WorkflowSnapshot v1` from its selected,
47
+ versioned documents and caller-supplied repository facts.
48
+
49
+ ## Driver protocol
50
+
51
+ 1. Read the profile and append `renderOutputInstruction(skill)` only for a
52
+ driven invocation.
53
+ 2. Pass the final response to `parseTurn({skill, text, context})`. Keep the
54
+ returned source and diagnostics with the run journal.
55
+ 3. On an absent, malformed, or invalid machine result, re-invoke the same
56
+ session once with: `Emit only the machine result for the turn above.`
57
+ 4. Parse the repair reply. A second failure is driver-level `FAILED`; never
58
+ retry indefinitely and never turn arbitrary prose into workflow facts.
59
+
60
+ Compatibility is deliberately narrow: it can repair documented legacy v2
61
+ shapes only when the missing value is mechanically knowable. A nonzero issue
62
+ count without issue identities, an unmatched numeric unit id, or unrelated
63
+ prose remains invalid and is surfaced to the driver.
64
+
65
+ ## Contract evolution
66
+
67
+ - Envelope v2 is strict for new drivers. `detail` is required (usually `null`)
68
+ and skill-specific extensions live inside it; `design_candidates`, for
69
+ example, is `detail.design_candidates`, never a root key.
70
+ - `workflow-status` retains Envelope v2 for existing sensor consumers.
71
+ `parseEnvelope()` remains the legacy-compatible package API; new consumers
72
+ use `parseEnvelopeV2Strict()` or `parseTurn()`.
73
+ - `SkillOutcome v1` and `WorkflowSnapshot v1` are separate, versioned JSON
74
+ Schemas. A breaking change to any published contract is a package major.
75
+
76
+ ## Normalized Repository State
77
+
78
+ Drivers call `discover-repository-state` before planning and retain the frozen
79
+ `docs/workflow/REPOSITORY_STATE.md` reference. `WorkflowSnapshot v1` preserves
80
+ unknowns, provenance, and declared contradictions; a driver routes a
81
+ contradiction to `resolve-repository-state` rather than silently replacing it.
@@ -0,0 +1,21 @@
1
+ # Canonical Turn Contract (orchestration-envelope owner)
2
+
3
+ ## Turn contract — verify before ending the turn
4
+
5
+ ```
6
+ ✓ 1. Branch verified FIRST (`git branch --show-current` RUN, output pasted; default branch → new branch created before edits). Never work on main/master.
7
+ ✓ 2. All pre-edit gates (phase-lint, architectural invariants, dependency) RUN, plus frozen acceptance verified, with commands/exit codes pasted. Any FAIL without an allowed override → STOP.
8
+ ✓ 3. `git add`, `git commit -m "<type>(<scope>): <summary>"` EXECUTED; SHA pasted. Commits you did not run do not count.
9
+ ✓ 4. Unit finished (single-pass/--fix/final phase)? `git push`, `gh pr create` EXECUTED; PR URL printed in chat (with --body-file, real Markdown, Closes #N). Roadmap/fix-index updated to `done · [#<pr>](<pr-url>)` in follow-up commit. For mid-phase push rules when a PR is already open, see per-consumer supplement (§ Push policy supplement).
10
+ ✓ 5. Clean-tree check LAST (`git status --porcelain` RUN, output pasted). No uncommitted changes (code or docs). PR branch not ahead of remote.
11
+ ✓ 6. Artifact language: explicit user > project docs > English.
12
+ ✓ 7. Descope guard applied to every issue created this turn (dated ## Amendments in SPEC before issue).
13
+ ✓ 8. Out-of-scope findings classified per Opportunistic finding policy, recorded in decisions.md; proposals created no issue without explicit user triage.
14
+ ✓ 9. Closing `→ Next:` block printed as ABSOLUTE last output.
15
+ ✓ 10. Machine result emitted if driver requested (package output profile).
16
+ ✓ 11. No reconstruction from memory — missing reference → STOP.
17
+ ```
18
+
19
+ **Single owner:** orchestration-envelope/references/TURN_CONTRACT.md. All skills load this + skill-specific additions only. Duplication forbidden. Missing reference = STOP.
20
+
21
+ **Push policy supplement:** Box 4 covers the end-of-unit push. Some consumers (e.g. `execute-phase/references/PREFLIGHT.md`) define additional push rules for mid-phase commits when a PR is already open — those per-consumer supplements extend this contract and must be loaded alongside it by the consumer skill.
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: phase-contract
3
+ user-invocable: false
4
+ version: 1.0.1
5
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
6
+ license: MIT
7
+ description: >
8
+ Internal contract: the single owner of the eight phase-lint rules, the fixed
9
+ PASS/BLOCKED result, and the normalized phase fingerprint. Consumed by
10
+ plan-feature-scaffold, plan-fix, and execute-phase. Not a menu entry.
11
+ ---
12
+
13
+ # Phase Contract (internal)
14
+
15
+ The one authoritative owner of phase shape for this workflow. Planners lint
16
+ every phase they emit against the eight rules below; `execute-phase` re-checks
17
+ the same rules before any edit. Nothing else may define what a valid phase is.
18
+
19
+ ## When to use
20
+
21
+ - `plan-feature-scaffold` — lint every phase of a feature plan before emission.
22
+ - `plan-fix` — lint every phase of a fix SPEC before commit.
23
+ - `execute-phase` — phase-lint pre-flight guard before editing a phase.
24
+ - Templates store the contract version + fingerprint + lint result, never the
25
+ eight rules (they point here).
26
+
27
+ ## The eight phase-lint rules
28
+
29
+ Every implementation phase must pass all 8 boxes before it is emitted (planner
30
+ skills) or executed (`execute-phase` pre-flight). Fail-closed: any unticked box
31
+ blocks emission/execution until the phase is re-cut or split.
32
+
33
+ 1. **Title names ONE deliverable** — FAIL if it joins nouns with `+`, `,`, `&`,
34
+ `and`/`y`, or `/`.
35
+ 2. **One declared layer** — each phase declares exactly one of the fixed enum
36
+ `schema/db | domain | api | ui | config/infra | docs | hardening | close-out`;
37
+ FAIL if any task's target file belongs to another. Tests for the phase's own
38
+ layer belong to the phase; a test-only phase declares `hardening`.
39
+ 3. **≤ 8 tasks** (close-out phase: ≤ 10, only the literal close-out chain).
40
+ 4. **One checkbox = one deliverable** — FAIL if a task contains a `→` chain of
41
+ implementation steps, enumerates > 3 cases/scenarios, or creates > 1 file of
42
+ distinct concerns.
43
+ 5. **Zero decision words** — FAIL on `Decide`, `choose`, `OR` between
44
+ alternatives, `If … then <change scope>`.
45
+ 6. **No conditional scope mutation** — a task may not move work between phases
46
+ at runtime.
47
+ 7. **No external/manual gates inside implementation phases** —
48
+ human/out-of-repo verifications live in the hardening/close-out phase,
49
+ marked `manual`.
50
+ 8. **Machine-checkable done-when** — every phase ends with one verifiable
51
+ invariant (a command + expected outcome).
52
+
53
+ ## Result — fixed PASS/BLOCKED output
54
+
55
+ ```text
56
+ Phase-lint: PASS (8/8)
57
+ ```
58
+
59
+ or, on the first failing box:
60
+
61
+ ```text
62
+ Phase-lint: BLOCKED — box <n>: <one-line reason>
63
+ ```
64
+
65
+ A BLOCKED phase is re-cut or split; it is never emitted, committed, or executed
66
+ as-is (no `--force` bypass exists for a non-atomic phase — that decision belongs
67
+ to the user).
68
+
69
+ ## Normalized phase fingerprint
70
+
71
+ Each phase's fingerprint is a deterministic string over the phase's shape:
72
+ `P<n>:<layer>:<n-tasks>:<title-deliverable>`. It binds the lint result to the
73
+ exact phase version a plan committed to — templates and plans record
74
+ `Phase-lint: PASS (8/8) · fingerprint <fingerprint>` so later re-lints and
75
+ `execute-phase` can confirm nothing in the phase shape drifted since planning.
76
+
77
+ ## Guardrails
78
+
79
+ - Sole owner of the eight rules — planners and executor point here, never carry
80
+ their own copy.
81
+ - Never relax a rule to let a phase pass; re-cut the phase instead.
82
+ - Docs only — no code, no branch.
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: plan-feature
3
+ user-invocable: true
4
+ version: 3.5.1
5
+ argument-hint: <NN-slug | #N> | --from-issue N | --scaffold <slug> | --next
6
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
7
+ license: MIT
8
+ description: >
9
+ Route designed features or issues into engineering planning and roadmap
10
+ registration; undesigned work stops at design-feature. Supports `--next`,
11
+ `--from-issue`, and `--scaffold`. Triggers: "plan-feature", "plan a feature",
12
+ "plan the next roadmap feature", "create SPEC and TASKS".
13
+ ---
14
+
15
+ # Plan Feature (router)
16
+
17
+ The engineering-planning door for a feature whose product definition already
18
+ exists. Routes to a focused internal step so only the work you need runs (no
19
+ fat single skill). **Docs only — no code, no branch.** Product definition
20
+ (raw-idea interview, capability closure) is `design-feature`'s job, not this
21
+ one — the routed redirect gate enforces that split.
22
+
23
+ ## Turn contract — verify before ending the turn
24
+
25
+ ```
26
+ ✓ The redirect gate ran FIRST, before any SPEC edit: undesigned input → STOP,
27
+ print the fixed `/design-feature <slug>` block, do nothing else this turn
28
+ ✓ Designed input only: engineering half filled, artifacts written, and the
29
+ roadmap entry registered (number, order, deps verified)
30
+ ✓ If `plan-feature-scaffold` ran this turn: the roadmap row was re-read
31
+ AFTER the write and literally reads `planned` — a dropped `defined→planned`
32
+ write fails this box; do not end the turn until it's fixed
33
+ ✓ The dependency & blocker check was RUN and its result decides which closing block is printed
34
+ ✓ An unmet dependency? The closing block lists the complete dependency chain, deepest first, joined with ` + `
35
+ ✓ Artifact language: explicit user instruction > the project's declared docs language > English. The CONVERSATION language never decides — a Spanish prompt still produces English PRs/issues/commits/SPECs unless one of the first two says otherwise
36
+ ✓ The closing `→ Next:` block is printed as the ABSOLUTE last output
37
+ ```
38
+
39
+ About to end the turn with any box unchecked? The turn is NOT done — complete
40
+ the missing box first (weak models drop end-of-document duties; this list is
41
+ first on purpose).
42
+
43
+ ## Step 0 — Discover the project (always first)
44
+
45
+ Per the agent guide's **Workflow conventions** + **documentation map**, then read
46
+ what THIS skill needs: the **roadmap** (`docs/features/ROADMAP.md`), so routing
47
+ and roadmap registration match the project's real layout.
48
+
49
+ ## Progressive loading — route before planning
50
+
51
+ The reference allowlist is exactly the two paths below:
52
+
53
+ 1. Every invocation: read [redirect gate and routing](references/ROUTING.md),
54
+ apply the status gate first, and stop on its exact block when instructed.
55
+ 2. Any route that can write planning artifacts: after the redirect gate permits
56
+ routing, consume the [planning preflight](<../planning-preflight/SKILL.md>) —
57
+ it owns the normalized repository state read and the ONE final architectural
58
+ classification — before composing an internal step, including the
59
+ issue-derived route.
60
+ 3. Before composing an internal step: load the [phase contract](<../phase-contract/SKILL.md>)
61
+ so every SPEC written this turn carries the canonical 8-box phase-lint and
62
+ the normalized phase fingerprint.
63
+
64
+ Do not load planning gates after a redirect stop. Both resources are normative,
65
+ one hop from this file, and fail closed when missing.
66
+
67
+ ## Process
68
+
69
+ 1. **Redirect gate** from `ROUTING.md` — always first.
70
+ 2. **Route** from the same resource. For issue input, resolve and validate the issue
71
+ identity only; after the [planning preflight](<../planning-preflight/SKILL.md>)
72
+ confirms that planning may write, compose the from-issue internal to produce
73
+ a **filled, sized SPEC product half**; then invoke `plan-feature-scaffold`,
74
+ which fills the engineering half and scales the artifacts to the SPEC's size
75
+ (XS/S → SPEC-only; M/L → full set) and registers the roadmap. The
76
+ already-designed scoped path runs `plan-feature-scaffold` directly. Every
77
+ path holds **one immutable planning context** — the roadmap snapshot taken
78
+ before writing (and one issue payload when `--from-issue`) — reused across
79
+ the internal steps; never re-fetched mid-plan.
80
+ 3. **Confirm roadmap.** Verify the feature is registered in
81
+ `docs/features/ROADMAP.md` with the right number, ordering, and dependencies;
82
+ if any of the three is missing or wrong, fix the entry now — never leave
83
+ registration for later.
84
+ 4. **Dependency & blocker check (always, before recommending execution).**
85
+ - Walk the feature's `Depends on:` closure (transitively): every dependency
86
+ must be `done` **and merged**. Any unmet → the closing block recommends
87
+ building the deepest unmet dependency first, NOT this feature.
88
+ - Check the fix index + open issues (forge CLI) for fix-now items touching
89
+ the same modules this SPEC names. Any hit → the closing block recommends
90
+ `/plan-fix <n>` before execution ("building on a known defect bakes it in").
91
+ - Planning itself never blocks on either — the SPEC/artifacts are still
92
+ written; only the **recommended next step** changes.
93
+ 5. **Print the next step** per the check above (see Done when).
94
+
95
+ ## Guardrails
96
+
97
+ - Docs only — no code, no branch (that is `execute-phase`).
98
+ - **Never plan an undesigned feature** — the redirect gate has no bypass flag,
99
+ ever. Do not add one, even if asked; point at `/design-feature` instead.
100
+ - Don't re-ask what a flag, the issue, or the docs already settle.
101
+ - Surface conflicts (numbering clashes, dependency cycles, scope overlap) before
102
+ writing, not after.
103
+ - Otherwise per the project's **Workflow conventions** (docs-language).
104
+
105
+ ## Internal steps (not user-invocable)
106
+
107
+ - `plan-feature-from-issue` — issue → scoped SPEC product half, `Closes #N`.
108
+ - `plan-feature-scaffold` — SPEC → engineering half + full artifact set +
109
+ roadmap entry.
110
+
111
+ These run **within this same conversation** (that's what "composing" means) —
112
+ on any agent, just follow their `SKILL.md` inline as the routed step. The
113
+ raw-idea interview that used to be an internal step of this router is retired
114
+ — see `docs/workflow/MIGRATION.md`; that logic now lives in `design-feature`,
115
+ a user-facing skill in its own right (product definition is its own pipeline
116
+ stage, not an internal routing detail of this one).
117
+
118
+ ## Portability (agents other than Claude Code)
119
+
120
+ The workflow is the contract; Claude Code features are conveniences. On an
121
+ agent that lacks one, apply the fallback — never skip the step the feature
122
+ enables:
123
+
124
+ - **No slash-command menu** — where this skill says `/<skill>`, open that
125
+ skill's `SKILL.md` (wherever your agent installed the skills) and follow it
126
+ literally, in a fresh conversation: hand-offs assume a clean context. The
127
+ internal steps above are the exception — they run inline, in this one.
128
+ - **No per-skill `model:`/`effort:`** — on the `#claude` branch the frontmatter pins these tiers; here, pick tiers yourself:
129
+ planning is judgment work — run it on your **strongest** model. The
130
+ execution it hands off to may run cheaper.
131
+
132
+ ## Relationship to other skills
133
+
134
+ - **Redirects to** `design-feature` when the redirect gate stops on an
135
+ undesigned feature — never composed in-turn (planning-class, ≥-tier hand-off).
136
+ - `triage-issue` routes here to promote an issue to a feature (still subject to
137
+ the redirect gate if the promoted issue is undesigned).
138
+ - `execute-phase` executes the phases afterward (`audit-docs` audits anytime).
139
+
140
+ ## Done when
141
+
142
+ - The redirect gate ran, and if it stopped, nothing else in this turn touched
143
+ the SPEC.
144
+ - Designed input only: a planned feature with its full artifact set exists and
145
+ is roadmap-registered — **and the roadmap row was re-read after the write and
146
+ literally reads `planned`** (never assumed from having run the write step).
147
+ - The dependency & blocker check ran, and **the closing `→ Next:` block matches
148
+ its result** — clean:
149
+
150
+ ```
151
+ → Next: /execute-phase <NN> — execute every remaining phase and open the PR
152
+ · explicit atomic mode → /execute-phase <NN> P1
153
+ · adjust scope first → re-run /design-feature <slug> · audit the planning docs → /audit-docs
154
+ ```
155
+
156
+ already-planned feature (redirect gate stopped, never re-scaffolded):
157
+
158
+ ```
159
+ → Next: /execute-phase <NN> — this feature is already planned; execute every
160
+ remaining phase, don't re-plan it.
161
+ · explicit atomic mode → /execute-phase <NN> P1
162
+ ```
163
+
164
+ undesigned feature (redirect gate stopped):
165
+
166
+ ```
167
+ → Next: /design-feature <slug> — this feature has no completed product design yet
168
+ (capability closure not done). Design it first; then re-run /plan-feature <slug>.
169
+ ```
170
+
171
+ unmet dependency and/or blocking fix-now issue:
172
+
173
+ ```
174
+ Dependency chain (deepest first): <deepest> + <dependency> + <NN> (replace with every actual member; never print `…`)
175
+ → Next: /plan-feature <deepest-unmet-dep> (or /execute-phase <deepest-unmet-dep>) — build the
176
+ complete dependency chain first: <deepest> + <dependency> + <NN>
177
+ · blocking fix-now issue #<n> in the same area → /plan-fix <n> before executing
178
+ · proceed anyway → /execute-phase <NN> --force (the gate logs the override)
179
+ ```
@@ -0,0 +1,83 @@
1
+ ## Redirect gate (always, before routing)
2
+
3
+ Before any other step, resolve the target slug/issue. An issue input
4
+ (`--from-issue <N>` or issue URL/number) resolves and validates the issue
5
+ identity only; it does not invoke `plan-feature-from-issue` here. The parent
6
+ must consume the [planning preflight](<../../planning-preflight/SKILL.md>) and
7
+ confirm that planning may write before composing that internal writer. The
8
+ internal step supplies the feature slug for the later roadmap gate. For other
9
+ inputs, read **the roadmap status** (`docs/features/ROADMAP.md` → the five-state machine
10
+ `idea/defined/planned/in-progress/done`) — the **primary** gate signal. The
11
+ SPEC's `## Design status` marker is the SPEC-local record and the
12
+ **legacy-compat fallback** only (see step 6 below), never the primary check:
13
+
14
+ 1. **Roadmap row status `defined`** → proceed to Routing below (the product
15
+ half is designed; the engineering half still needs scaffolding).
16
+ 2. **Roadmap row status `planned`** (SPEC + artifacts already present) →
17
+ **STOP**. Never invoke `plan-feature-scaffold` — re-scaffolding an
18
+ already-planned feature is the re-plan-loop bug this gate exists to close.
19
+ Print exactly:
20
+
21
+ ```
22
+ → Next: /execute-phase <NN> — this feature is already planned; execute every
23
+ remaining phase, don't re-plan it.
24
+ · explicit atomic mode → /execute-phase <NN> P1
25
+ ```
26
+ 3. **Roadmap row status `in-progress`** → **STOP**. Print exactly:
27
+
28
+ ```
29
+ → Next: /execute-phase <NN> <next-phase> — this feature is already being
30
+ implemented; resume the current phase, don't re-plan it.
31
+ ```
32
+ 4. **Roadmap row status `done`** → **STOP**. Print exactly:
33
+
34
+ ```
35
+ → Next: nothing — <NN>-<slug> already shipped (roadmap status `done`).
36
+ ```
37
+ 5. **Roadmap row status `idea`, or no row at all** → **STOP**. Print exactly:
38
+
39
+ ```
40
+ → Next: /design-feature <slug> — this feature has no completed product design yet
41
+ (capability closure not done). Design it first; then re-run /plan-feature <slug>.
42
+ ```
43
+
44
+ No bypass flag exists for this gate — an undesigned feature is never
45
+ planned by this skill, under any flag or instruction.
46
+ 6. **Legacy compat.** A roadmap row still reading a plain `planned` with no
47
+ five-state history (predates this repo's roadmap-status-machine feature):
48
+ fall back to the SPEC marker — `## Design status: designed` and Capability
49
+ closure filled → treat as `defined`+`planned`, STOP per step 2 above (a
50
+ legacy `planned` row is still already-planned — hand off to
51
+ `/execute-phase`, never re-scaffold). Marker missing/`not designed`/closure
52
+ empty → treat as `idea`, STOP per step 5. See `docs/workflow/MIGRATION.md`.
53
+ 7. **A raw idea with no slug at all** (nothing to check) → the same STOP
54
+ applies: print the block above pointing at `/design-feature "<idea>"`
55
+ instead of a slug.
56
+
57
+ ## Routing
58
+
59
+ Once the gate passes, pick the mode — first match wins:
60
+
61
+ 1. **Flag forces it** (skip detection): `--scaffold <slug>`, `--next`.
62
+ 2. **Issue input** — `--from-issue <N>`, an issue URL, or a bare numeric argument
63
+ `<N>` (for example, `131`) selects the issue-derived route; detection itself
64
+ does not compose `plan-feature-from-issue`. The parent route owns the
65
+ [planning preflight](<../../planning-preflight/SKILL.md>) consumption and must
66
+ confirm that planning may write before it composes `plan-feature-from-issue`,
67
+ then `plan-feature-scaffold`.
68
+ 3. **Scoped** — an existing, designed roadmap slug or a filled `SPEC.md` →
69
+ `plan-feature-scaffold`.
70
+ 4. **`--next` / no input** — read the roadmap, take the next `defined` entry
71
+ (the units that still need engineering planning — a `planned` row is
72
+ already scaffolded); apply the redirect gate to it, then scaffold.
73
+ 5. **Ambiguous** — ask one question, then route.
74
+
75
+ ### Example (routing)
76
+
77
+ | You run | Detected | Routes to | Then |
78
+ |---|---|---|---|
79
+ | `plan-feature 14-csv-export` (not designed) | undesigned slug | — | STOP → `/design-feature 14-csv-export` |
80
+ | `plan-feature 131` | issue #131 | `plan-feature-from-issue` → `plan-feature-scaffold` | PR carries `Closes #131` |
81
+ | `plan-feature 14-csv-export` (designed, `defined`) | designed slug | `plan-feature-scaffold` | `execute-phase 14 P1` |
82
+ | `plan-feature 14-csv-export` (already `planned`) | already-planned slug | — | STOP → `/execute-phase 14 P1` (no re-scaffold) |
83
+ | `plan-feature --next` | next `defined` roadmap entry | gate, then scaffold | `execute-phase NN P1` |