$npx -y skills add MageByte-Zero/spec-superflow --skill contract-builderConvert approved planning artifacts into an execution contract. Invoke when the user wants to start building, asks to move from planning to implementation, or when execution-contract.md is missing or stale.
| 1 | # Contract Builder |
| 2 | |
| 3 | Converts planning artifacts into a single execution handshake: `execution-contract.md`. Load the baseline with `npx --yes --package spec-superflow@0.11.0 ssf runtime asset read templates/execution-contract.md`. |
| 4 | |
| 5 | Read before generating: `.spec-superflow.yaml` (especially `dp_0_decisions`), |
| 6 | `proposal.md`, `specs/`, `design.md`, `tasks.md`, then load |
| 7 | `docs/artifact-contract.md` with `npx --yes --package spec-superflow@0.11.0 ssf runtime asset read docs/artifact-contract.md`. |
| 8 | |
| 9 | ## Artifact Language |
| 10 | |
| 11 | Read `artifact_language=<concrete-language>` from `dp_0_decisions`. Generate |
| 12 | `execution-contract.md` in the same language as that resolved value and the |
| 13 | approved planning artifacts. Preserve required schema keywords and code |
| 14 | identifiers verbatim; language consistency applies to explanatory prose and |
| 15 | headings. If the concrete artifact language is missing or still `auto`, route |
| 16 | back to `workflow-start` before writing the contract instead of guessing or |
| 17 | silently defaulting to English. |
| 18 | |
| 19 | ## Artifact Mapping |
| 20 | |
| 21 | | Source | Extract | |
| 22 | |--------|---------| |
| 23 | | `proposal.md` → `## Why` + `## What Changes` | Intent Lock (problem + scope) | |
| 24 | | `proposal.md` → `## Scope > ### Out of Scope` | Scope Fence | |
| 25 | | `specs/` → each `### Requirement:` | Approved Requirements, Scenarios, Test Obligations | |
| 26 | | `design.md` → `## Decisions` | Architecture, Interface, Dependency Constraints | |
| 27 | | `tasks.md` → numbered task groups | Execution Batches, Completion Definitions, Review Timing | |
| 28 | |
| 29 | ## Cross-Check: Requirement Coverage |
| 30 | |
| 31 | Before finalizing: |
| 32 | 1. List every SHALL/MUST from `specs/` |
| 33 | 2. Verify each is reflected in Approved Behavior, has a test obligation, and appears in at least one batch |
| 34 | 3. Flag unmapped requirements in Escalation Rules |
| 35 | 4. Note cross-batch dependencies |
| 36 | |
| 37 | ## Contract Structure |
| 38 | |
| 39 | Must make obvious: approved behavior, out-of-scope, constraints, batches, test obligations, review gates, and conditions that force a rewind to planning. Prefer compression over repeating planning details. |
| 40 | |
| 41 | ## Approval Model (DP-3) |
| 42 | |
| 43 | After drafting: summarize handoff rules, identify ambiguity, flag unmapped requirements, ask user to approve explicitly. After approval: |
| 44 | ```bash |
| 45 | npx --yes --package spec-superflow@0.11.0 ssf state set <change-dir> dp_3_result "approved: <summary>" |
| 46 | npx --yes --package spec-superflow@0.11.0 ssf state set <change-dir> dp_3_timestamp $(date -u +%Y-%m-%dT%H:%M:%SZ) |
| 47 | ``` |
| 48 | DP-3 is a hard gate — no implementation without this record. |
| 49 | |
| 50 | ## Stale Contract Detection |
| 51 | |
| 52 | Refresh if: scope changed in proposal, requirements changed in specs, constraints changed in design, batches changed materially in tasks, or the contract no longer matches intent. |
| 53 | |
| 54 | ## Hotfix Mode |
| 55 | |
| 56 | Generate minimal contract: Intent Lock (one sentence), Task List (numbered), Approval Gate (DP-3). Skip Scope Fence, Build Rules, Review Gates, Test Evidence. Still requires DP-3 approval. |
| 57 | |
| 58 | ## Guardrails |
| 59 | |
| 60 | - Do not continue to implementation if ambiguity remains |
| 61 | - Do not approve the contract on the user's behalf |
| 62 | - Do not skip the contract because planning docs look complete |
| 63 | - Flag unmapped requirements; do not silently drop them |
| 64 | |
| 65 | ## Post-Generation |
| 66 | |
| 67 | Run `npx --yes --package spec-superflow@0.11.0 ssf state init <change-dir>` to create `.spec-superflow.yaml` with hashes. |
| 68 | |
| 69 | For hotfix, after writing the minimal contract, run `npx --yes --package spec-superflow@0.11.0 ssf state init <change-dir>` or `npx --yes --package spec-superflow@0.11.0 ssf state rebuild <change-dir>` so `contract_hash` is recorded. DP-3 remains mandatory before build. |
| 70 | |
| 71 | ## Exception Handling |
| 72 | |
| 73 | - **Parse failures**: Report specific file and section. Suggest re-running `spec-writer`. |
| 74 | - **Missing files**: List every missing artifact. Route back to `spec-writer`. |
| 75 | - **User interruption**: Re-read all artifacts on resume; check contract staleness via content comparison. |
| 76 | - **Validation failure**: Flag unmapped requirements in Escalation Rules and approval summary. |