bigpowers 2.12.1 → 2.14.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.
- package/.pi/package.json +2 -2
- package/.pi/prompts/audit-code.md +14 -0
- package/.pi/prompts/build-epic.md +10 -1
- package/.pi/prompts/validate-contracts.md +181 -0
- package/.pi/skills/audit-code/SKILL.md +14 -0
- package/.pi/skills/build-epic/SKILL.md +10 -1
- package/.pi/skills/validate-contracts/SKILL.md +183 -0
- package/CHANGELOG.md +14 -0
- package/SKILL-INDEX.md +36 -35
- package/audit-code/SKILL.md +14 -0
- package/build-epic/SKILL.md +10 -1
- package/package.json +1 -1
- package/scripts/generate-skill-index.sh +1 -0
- package/skills-lock.json +7 -2
- package/validate-contracts/SKILL.md +182 -0
package/.pi/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bigpowers",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.14.0",
|
|
4
|
+
"description": "67 skills — 61 agent skills for spec-driven, test-first software development by solo developers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
@@ -15,6 +15,7 @@ Run this self-review before asking anyone else to look at the code. The goal is
|
|
|
15
15
|
|
|
16
16
|
- Default: full checklist
|
|
17
17
|
- --quick: Run only Supply Chain and Test Coverage. Use for changes under 50 LOC.
|
|
18
|
+
- --gate: Non-interactive mode for automated CI gating (used by build-epic step 6). Exit with non-zero status code (`exit 1`) on ANY checklist failure; `exit 0` only if ALL items pass. Produces a compact pass/fail summary to stderr. On failure, list every ✗ item with reason.
|
|
18
19
|
|
|
19
20
|
## Checklist
|
|
20
21
|
|
|
@@ -104,6 +105,19 @@ Report the checklist with ✓ / ✗ per item. For each ✗, describe what needs
|
|
|
104
105
|
If all items pass: suggest running `request-review` for an independent second opinion.
|
|
105
106
|
If any items fail: fix them before proceeding.
|
|
106
107
|
|
|
108
|
+
### Gate mode output (`--gate`)
|
|
109
|
+
|
|
110
|
+
In `--gate` mode, print one summary line per checklist section:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
PASS Supply Chain & Security
|
|
114
|
+
FAIL Provenance & Metadata (2 items)
|
|
115
|
+
PASS Law of Demeter
|
|
116
|
+
...
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Aggregate exit code: `0` if all sections PASS, `1` (non-zero) if any section FAILs. Write the full audit report to `specs/verifications/AUDIT-<epic>-<story>.md` as a permanent record.
|
|
120
|
+
|
|
107
121
|
## Handoff
|
|
108
122
|
|
|
109
123
|
Gate: READY -> next: commit-message
|
|
@@ -22,7 +22,7 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
22
22
|
| 3 | `kickoff-branch` — feature branch + clean baseline |
|
|
23
23
|
| 4 | `develop-tdd` — red-green per task |
|
|
24
24
|
| 5 | `verify-work` — UAT + mechanical gates |
|
|
25
|
-
| 6 | `audit-code` —
|
|
25
|
+
| 6 | `audit-code` — **non-optional gate** (pass/fail; fail → loop back to step 4) |
|
|
26
26
|
| 7 | `commit-message` — Conventional Commits draft |
|
|
27
27
|
| 8 | `release-branch` — PR or solo land |
|
|
28
28
|
|
|
@@ -35,6 +35,15 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
35
35
|
5. After step verify passes, increment `epic_cycle.step` in `state.yaml` (or `bash scripts/bp-yaml-set.sh` if available).
|
|
36
36
|
6. On story complete, set `execution-status.yaml` story key to `done`; run `bash scripts/sync-status-from-epics.sh`.
|
|
37
37
|
|
|
38
|
+
### Step 6 — audit-code gate (non-optional)
|
|
39
|
+
|
|
40
|
+
After step 5 (verify-work) completes successfully, step 6 runs `audit-code` automatically in `--gate` mode:
|
|
41
|
+
|
|
42
|
+
1. **Run audit:** Invoke `audit-code --gate` on the complete diff for this story.
|
|
43
|
+
2. **Pass (exit 0):** All checklist sections pass → advance to step 7 (commit-message). Record `epic_cycle.audit_result: pass` in `state.yaml`.
|
|
44
|
+
3. **Fail (exit 1):** One or more checklist sections fail → **reset `epic_cycle.current_step` to `4`** (develop-tdd) and add the failing section IDs to `completed_steps` as `"1,2,3,4,5,6(fail: ...)"`. Record `epic_cycle.audit_result: fail` in `state.yaml`. Do NOT advance past step 6 until audit passes.
|
|
45
|
+
4. **Audit artifact:** Full audit report saved to `specs/verifications/AUDIT-<epic>-<story>.md` regardless of pass/fail, for reviewer traceability.
|
|
46
|
+
|
|
38
47
|
## Handoff
|
|
39
48
|
|
|
40
49
|
Write `handoff.next_skill` and `handoff.context` in `state.yaml` when pausing mid-epic.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Assert data shape consistency across system boundaries — live API responses against JSON Schema, key-set comparison across layers, data shape validation for migrations and exports. Catches silent data corruption before deploy."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Validate Contracts
|
|
7
|
+
|
|
8
|
+
> **HARD GATE** — Do NOT deploy or migrate data without running `validate-contracts` first. Silent data divergence between system boundaries causes the hardest-to-debug production bugs.
|
|
9
|
+
>
|
|
10
|
+
> **HARD GATE** — Contract files MUST be version-controlled alongside code. Outdated contracts are worse than no contracts. If a contract hasn't been reviewed in 30 days, flag it as stale.
|
|
11
|
+
|
|
12
|
+
Validate that data structures stay in sync across system boundaries — front-end vs
|
|
13
|
+
back-end, API responses vs expected schemas, config files vs code assumptions,
|
|
14
|
+
migration output vs target shape.
|
|
15
|
+
|
|
16
|
+
## Contract types
|
|
17
|
+
|
|
18
|
+
Three modes of validation:
|
|
19
|
+
|
|
20
|
+
| Mode | What it catches | When to use |
|
|
21
|
+
|------|----------------|-------------|
|
|
22
|
+
| **Schema** | API response shape mismatches (missing field, wrong type) | Before every deploy, after API changes |
|
|
23
|
+
| **Key-set** | Missing/unexpected keys across two data sources | Translation files, configs, enum definitions |
|
|
24
|
+
| **Shape** | Column type or format violations in data files | After migrations, before consuming exports |
|
|
25
|
+
|
|
26
|
+
## Contract file convention
|
|
27
|
+
|
|
28
|
+
All contract files live in `specs/contracts/` and use YAML:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
specs/contracts/
|
|
32
|
+
├── users.schema.yaml # API response schema
|
|
33
|
+
├── i18n-keys.yaml # Key-set comparison
|
|
34
|
+
├── migration-output.yaml # Data shape contract
|
|
35
|
+
└── README.md # Local conventions
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 1. API Response Contracts (`--schema`)
|
|
39
|
+
|
|
40
|
+
Define expected API response shapes and validate live endpoints against them:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
# specs/contracts/users.schema.yaml
|
|
44
|
+
endpoint: /api/users
|
|
45
|
+
method: GET
|
|
46
|
+
schema:
|
|
47
|
+
type: object
|
|
48
|
+
required: [id, name, email]
|
|
49
|
+
properties:
|
|
50
|
+
id: { type: number }
|
|
51
|
+
name: { type: string }
|
|
52
|
+
email: { type: string, format: email }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Usage:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
validate-contracts --schema specs/contracts/users.schema.yaml --url https://api.example.com/users
|
|
59
|
+
# → PASS: /api/users matches expected schema (3/3 fields, types ok)
|
|
60
|
+
# → FAIL: /api/users — field 'email' has type null (expected string)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Key-Set Contracts (`--key-set`)
|
|
64
|
+
|
|
65
|
+
Assert that two data sources share a consistent set of keys:
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
# specs/contracts/i18n-keys.yaml
|
|
69
|
+
sources:
|
|
70
|
+
reference: src/frontend/locales/en.json
|
|
71
|
+
target: src/backend/messages/en.json
|
|
72
|
+
mode: subset # all target keys must exist in reference
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Usage:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
validate-contracts --key-set specs/contracts/i18n-keys.yaml
|
|
79
|
+
# → missing: 2 keys in reference not found in target: ['settings.privacy', 'help.faq']
|
|
80
|
+
# → added: 1 key in target not in reference: ['deprecated.field']
|
|
81
|
+
# → exit 1 (divergence)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Data Shape Contracts (`--shape`)
|
|
85
|
+
|
|
86
|
+
Validate that a data file matches expected column types and constraints:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
# specs/contracts/migration-output.yaml
|
|
90
|
+
file: data/users-export.json
|
|
91
|
+
format: json
|
|
92
|
+
fields:
|
|
93
|
+
- name: user_id
|
|
94
|
+
type: number
|
|
95
|
+
required: true
|
|
96
|
+
- name: full_name
|
|
97
|
+
type: string
|
|
98
|
+
required: true
|
|
99
|
+
- name: created_at
|
|
100
|
+
type: string
|
|
101
|
+
format: date-time
|
|
102
|
+
required: false
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Usage:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
validate-contracts --shape specs/contracts/migration-output.yaml
|
|
109
|
+
# → PASS: 3/3 fields validated, 5000 rows OK
|
|
110
|
+
# → WARN: field 'full_name' has 12 null values (0.24%)
|
|
111
|
+
# → FAIL: field 'user_id' has 3 rows with type string (expected number)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Process
|
|
115
|
+
|
|
116
|
+
### 1. Define contract
|
|
117
|
+
|
|
118
|
+
Create a YAML file in `specs/contracts/` following the schema for the mode.
|
|
119
|
+
|
|
120
|
+
### 2. Run validation
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The runner auto-detects the contract type from the file content (presence of `schema:`,
|
|
127
|
+
`sources:`, or `file:` + `fields:` keys).
|
|
128
|
+
|
|
129
|
+
### 3. Read the report
|
|
130
|
+
|
|
131
|
+
Output is JSON Lines (one event per line) plus a human-readable summary:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
{"event":"pass","check":"users.schema","detail":"3/3 fields match types"}
|
|
135
|
+
{"event":"warn","check":"users.schema","detail":"field 'avatar' has format: uri (unexpected)"}
|
|
136
|
+
{"event":"fail","check":"i18n-keys","detail":"missing: 2 keys in target"}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Final summary:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
=== Validate Contracts Summary ===
|
|
143
|
+
Schema: 3/3 pass | Key-set: 1/1 fail | Shape: 2/2 pass
|
|
144
|
+
FAILED: 1 contract has divergence
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 4. Fix divergence
|
|
148
|
+
|
|
149
|
+
- **Missing keys** → add to target source
|
|
150
|
+
- **Type mismatches** → update schema or fix producer
|
|
151
|
+
- **Shape violations** → fix migration or consumer
|
|
152
|
+
|
|
153
|
+
### 5. Re-validate
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
157
|
+
# → All pass → ready to deploy
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Integration
|
|
161
|
+
|
|
162
|
+
- **Pre-deploy gate:** The `deploy` skill runs `validate-contracts` before smoke-test.
|
|
163
|
+
- **CI pipeline:** JSON Lines output is CI-friendly; pipe to `jq` for assertions.
|
|
164
|
+
- **Pre-migration:** Run `validate-contracts --shape` before consuming migration output.
|
|
165
|
+
|
|
166
|
+
## Configuration
|
|
167
|
+
|
|
168
|
+
| Variable | Default | Description |
|
|
169
|
+
|----------|---------|-------------|
|
|
170
|
+
| `CONTRACTS_DIR` | `specs/contracts/` | Directory containing contract YAML files |
|
|
171
|
+
| `VALIDATE_ALL` | `false` | If true, run all contracts in the directory |
|
|
172
|
+
| `STRICT_MODE` | `false` | Treat warnings as failures |
|
|
173
|
+
| `OUTPUT_FORMAT` | `text` | `text` or `json` |
|
|
174
|
+
|
|
175
|
+
## Verification
|
|
176
|
+
|
|
177
|
+
→ verify: `test -f validate-contracts/SKILL.md && grep -q 'name: validate-contracts' validate-contracts/SKILL.md && echo OK`
|
|
178
|
+
→ verify: `grep -qi 'specs/contracts\|JSON Schema\|key.set\|data.shape' validate-contracts/SKILL.md && echo OK`
|
|
179
|
+
→ verify: `grep -ci 'divergence\|missing key\|type mismatch\|diff\|conforms\|column' validate-contracts/SKILL.md | awk '{if($1>=3) print "OK"; else print "FAIL"}'`
|
|
180
|
+
→ verify: `grep -ci 'JSON Lines\|machine.parse\|CI\|deploy.*gate\|pre.deploy' validate-contracts/SKILL.md | awk '{if($1>=2) print "OK"; else print "FAIL"}'`
|
|
181
|
+
→ verify: `grep -q 'validate-contracts' SKILL-INDEX.md && echo OK`
|
|
@@ -17,6 +17,7 @@ Run this self-review before asking anyone else to look at the code. The goal is
|
|
|
17
17
|
|
|
18
18
|
- Default: full checklist
|
|
19
19
|
- --quick: Run only Supply Chain and Test Coverage. Use for changes under 50 LOC.
|
|
20
|
+
- --gate: Non-interactive mode for automated CI gating (used by build-epic step 6). Exit with non-zero status code (`exit 1`) on ANY checklist failure; `exit 0` only if ALL items pass. Produces a compact pass/fail summary to stderr. On failure, list every ✗ item with reason.
|
|
20
21
|
|
|
21
22
|
## Checklist
|
|
22
23
|
|
|
@@ -106,6 +107,19 @@ Report the checklist with ✓ / ✗ per item. For each ✗, describe what needs
|
|
|
106
107
|
If all items pass: suggest running `request-review` for an independent second opinion.
|
|
107
108
|
If any items fail: fix them before proceeding.
|
|
108
109
|
|
|
110
|
+
### Gate mode output (`--gate`)
|
|
111
|
+
|
|
112
|
+
In `--gate` mode, print one summary line per checklist section:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
PASS Supply Chain & Security
|
|
116
|
+
FAIL Provenance & Metadata (2 items)
|
|
117
|
+
PASS Law of Demeter
|
|
118
|
+
...
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Aggregate exit code: `0` if all sections PASS, `1` (non-zero) if any section FAILs. Write the full audit report to `specs/verifications/AUDIT-<epic>-<story>.md` as a permanent record.
|
|
122
|
+
|
|
109
123
|
## Handoff
|
|
110
124
|
|
|
111
125
|
Gate: READY -> next: commit-message
|
|
@@ -24,7 +24,7 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
24
24
|
| 3 | `kickoff-branch` — feature branch + clean baseline |
|
|
25
25
|
| 4 | `develop-tdd` — red-green per task |
|
|
26
26
|
| 5 | `verify-work` — UAT + mechanical gates |
|
|
27
|
-
| 6 | `audit-code` —
|
|
27
|
+
| 6 | `audit-code` — **non-optional gate** (pass/fail; fail → loop back to step 4) |
|
|
28
28
|
| 7 | `commit-message` — Conventional Commits draft |
|
|
29
29
|
| 8 | `release-branch` — PR or solo land |
|
|
30
30
|
|
|
@@ -37,6 +37,15 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
37
37
|
5. After step verify passes, increment `epic_cycle.step` in `state.yaml` (or `bash scripts/bp-yaml-set.sh` if available).
|
|
38
38
|
6. On story complete, set `execution-status.yaml` story key to `done`; run `bash scripts/sync-status-from-epics.sh`.
|
|
39
39
|
|
|
40
|
+
### Step 6 — audit-code gate (non-optional)
|
|
41
|
+
|
|
42
|
+
After step 5 (verify-work) completes successfully, step 6 runs `audit-code` automatically in `--gate` mode:
|
|
43
|
+
|
|
44
|
+
1. **Run audit:** Invoke `audit-code --gate` on the complete diff for this story.
|
|
45
|
+
2. **Pass (exit 0):** All checklist sections pass → advance to step 7 (commit-message). Record `epic_cycle.audit_result: pass` in `state.yaml`.
|
|
46
|
+
3. **Fail (exit 1):** One or more checklist sections fail → **reset `epic_cycle.current_step` to `4`** (develop-tdd) and add the failing section IDs to `completed_steps` as `"1,2,3,4,5,6(fail: ...)"`. Record `epic_cycle.audit_result: fail` in `state.yaml`. Do NOT advance past step 6 until audit passes.
|
|
47
|
+
4. **Audit artifact:** Full audit report saved to `specs/verifications/AUDIT-<epic>-<story>.md` regardless of pass/fail, for reviewer traceability.
|
|
48
|
+
|
|
40
49
|
## Handoff
|
|
41
50
|
|
|
42
51
|
Write `handoff.next_skill` and `handoff.context` in `state.yaml` when pausing mid-epic.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: validate-contracts
|
|
3
|
+
description: "\"Assert data shape consistency across system boundaries — live API responses against JSON Schema, key-set comparison across layers, data shape validation for migrations and exports. Catches silent data corruption before deploy.\""
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Validate Contracts
|
|
9
|
+
|
|
10
|
+
> **HARD GATE** — Do NOT deploy or migrate data without running `validate-contracts` first. Silent data divergence between system boundaries causes the hardest-to-debug production bugs.
|
|
11
|
+
>
|
|
12
|
+
> **HARD GATE** — Contract files MUST be version-controlled alongside code. Outdated contracts are worse than no contracts. If a contract hasn't been reviewed in 30 days, flag it as stale.
|
|
13
|
+
|
|
14
|
+
Validate that data structures stay in sync across system boundaries — front-end vs
|
|
15
|
+
back-end, API responses vs expected schemas, config files vs code assumptions,
|
|
16
|
+
migration output vs target shape.
|
|
17
|
+
|
|
18
|
+
## Contract types
|
|
19
|
+
|
|
20
|
+
Three modes of validation:
|
|
21
|
+
|
|
22
|
+
| Mode | What it catches | When to use |
|
|
23
|
+
|------|----------------|-------------|
|
|
24
|
+
| **Schema** | API response shape mismatches (missing field, wrong type) | Before every deploy, after API changes |
|
|
25
|
+
| **Key-set** | Missing/unexpected keys across two data sources | Translation files, configs, enum definitions |
|
|
26
|
+
| **Shape** | Column type or format violations in data files | After migrations, before consuming exports |
|
|
27
|
+
|
|
28
|
+
## Contract file convention
|
|
29
|
+
|
|
30
|
+
All contract files live in `specs/contracts/` and use YAML:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
specs/contracts/
|
|
34
|
+
├── users.schema.yaml # API response schema
|
|
35
|
+
├── i18n-keys.yaml # Key-set comparison
|
|
36
|
+
├── migration-output.yaml # Data shape contract
|
|
37
|
+
└── README.md # Local conventions
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 1. API Response Contracts (`--schema`)
|
|
41
|
+
|
|
42
|
+
Define expected API response shapes and validate live endpoints against them:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
# specs/contracts/users.schema.yaml
|
|
46
|
+
endpoint: /api/users
|
|
47
|
+
method: GET
|
|
48
|
+
schema:
|
|
49
|
+
type: object
|
|
50
|
+
required: [id, name, email]
|
|
51
|
+
properties:
|
|
52
|
+
id: { type: number }
|
|
53
|
+
name: { type: string }
|
|
54
|
+
email: { type: string, format: email }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Usage:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
validate-contracts --schema specs/contracts/users.schema.yaml --url https://api.example.com/users
|
|
61
|
+
# → PASS: /api/users matches expected schema (3/3 fields, types ok)
|
|
62
|
+
# → FAIL: /api/users — field 'email' has type null (expected string)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Key-Set Contracts (`--key-set`)
|
|
66
|
+
|
|
67
|
+
Assert that two data sources share a consistent set of keys:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# specs/contracts/i18n-keys.yaml
|
|
71
|
+
sources:
|
|
72
|
+
reference: src/frontend/locales/en.json
|
|
73
|
+
target: src/backend/messages/en.json
|
|
74
|
+
mode: subset # all target keys must exist in reference
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Usage:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
validate-contracts --key-set specs/contracts/i18n-keys.yaml
|
|
81
|
+
# → missing: 2 keys in reference not found in target: ['settings.privacy', 'help.faq']
|
|
82
|
+
# → added: 1 key in target not in reference: ['deprecated.field']
|
|
83
|
+
# → exit 1 (divergence)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Data Shape Contracts (`--shape`)
|
|
87
|
+
|
|
88
|
+
Validate that a data file matches expected column types and constraints:
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
# specs/contracts/migration-output.yaml
|
|
92
|
+
file: data/users-export.json
|
|
93
|
+
format: json
|
|
94
|
+
fields:
|
|
95
|
+
- name: user_id
|
|
96
|
+
type: number
|
|
97
|
+
required: true
|
|
98
|
+
- name: full_name
|
|
99
|
+
type: string
|
|
100
|
+
required: true
|
|
101
|
+
- name: created_at
|
|
102
|
+
type: string
|
|
103
|
+
format: date-time
|
|
104
|
+
required: false
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Usage:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
validate-contracts --shape specs/contracts/migration-output.yaml
|
|
111
|
+
# → PASS: 3/3 fields validated, 5000 rows OK
|
|
112
|
+
# → WARN: field 'full_name' has 12 null values (0.24%)
|
|
113
|
+
# → FAIL: field 'user_id' has 3 rows with type string (expected number)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Process
|
|
117
|
+
|
|
118
|
+
### 1. Define contract
|
|
119
|
+
|
|
120
|
+
Create a YAML file in `specs/contracts/` following the schema for the mode.
|
|
121
|
+
|
|
122
|
+
### 2. Run validation
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The runner auto-detects the contract type from the file content (presence of `schema:`,
|
|
129
|
+
`sources:`, or `file:` + `fields:` keys).
|
|
130
|
+
|
|
131
|
+
### 3. Read the report
|
|
132
|
+
|
|
133
|
+
Output is JSON Lines (one event per line) plus a human-readable summary:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
{"event":"pass","check":"users.schema","detail":"3/3 fields match types"}
|
|
137
|
+
{"event":"warn","check":"users.schema","detail":"field 'avatar' has format: uri (unexpected)"}
|
|
138
|
+
{"event":"fail","check":"i18n-keys","detail":"missing: 2 keys in target"}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Final summary:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
=== Validate Contracts Summary ===
|
|
145
|
+
Schema: 3/3 pass | Key-set: 1/1 fail | Shape: 2/2 pass
|
|
146
|
+
FAILED: 1 contract has divergence
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 4. Fix divergence
|
|
150
|
+
|
|
151
|
+
- **Missing keys** → add to target source
|
|
152
|
+
- **Type mismatches** → update schema or fix producer
|
|
153
|
+
- **Shape violations** → fix migration or consumer
|
|
154
|
+
|
|
155
|
+
### 5. Re-validate
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
159
|
+
# → All pass → ready to deploy
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Integration
|
|
163
|
+
|
|
164
|
+
- **Pre-deploy gate:** The `deploy` skill runs `validate-contracts` before smoke-test.
|
|
165
|
+
- **CI pipeline:** JSON Lines output is CI-friendly; pipe to `jq` for assertions.
|
|
166
|
+
- **Pre-migration:** Run `validate-contracts --shape` before consuming migration output.
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
| Variable | Default | Description |
|
|
171
|
+
|----------|---------|-------------|
|
|
172
|
+
| `CONTRACTS_DIR` | `specs/contracts/` | Directory containing contract YAML files |
|
|
173
|
+
| `VALIDATE_ALL` | `false` | If true, run all contracts in the directory |
|
|
174
|
+
| `STRICT_MODE` | `false` | Treat warnings as failures |
|
|
175
|
+
| `OUTPUT_FORMAT` | `text` | `text` or `json` |
|
|
176
|
+
|
|
177
|
+
## Verification
|
|
178
|
+
|
|
179
|
+
→ verify: `test -f validate-contracts/SKILL.md && grep -q 'name: validate-contracts' validate-contracts/SKILL.md && echo OK`
|
|
180
|
+
→ verify: `grep -qi 'specs/contracts\|JSON Schema\|key.set\|data.shape' validate-contracts/SKILL.md && echo OK`
|
|
181
|
+
→ verify: `grep -ci 'divergence\|missing key\|type mismatch\|diff\|conforms\|column' validate-contracts/SKILL.md | awk '{if($1>=3) print "OK"; else print "FAIL"}'`
|
|
182
|
+
→ verify: `grep -ci 'JSON Lines\|machine.parse\|CI\|deploy.*gate\|pre.deploy' validate-contracts/SKILL.md | awk '{if($1>=2) print "OK"; else print "FAIL"}'`
|
|
183
|
+
→ verify: `grep -q 'validate-contracts' SKILL-INDEX.md && echo OK`
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [2.14.0](https://github.com/danielvm-git/bigpowers/compare/v2.13.0...v2.14.0) (2026-06-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **e18s01:** audit-code as non-optional gate in build-epic step 6 ([48f08de](https://github.com/danielvm-git/bigpowers/commit/48f08de62952827966ace0ac9149cea882fa0ca5))
|
|
7
|
+
|
|
8
|
+
# [2.13.0](https://github.com/danielvm-git/bigpowers/compare/v2.12.1...v2.13.0) (2026-06-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **skills:** add validate-contracts — data contract validator ([ec32076](https://github.com/danielvm-git/bigpowers/commit/ec3207617b3d465f8e5223242124cd2366cc2103))
|
|
14
|
+
|
|
1
15
|
## [2.12.1](https://github.com/danielvm-git/bigpowers/compare/v2.12.0...v2.12.1) (2026-06-20)
|
|
2
16
|
|
|
3
17
|
|
package/SKILL-INDEX.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
> **DO NOT EDIT** — This file is auto-generated by `scripts/generate-skill-index.sh`.
|
|
4
4
|
> Edit `SKILL.md` source files or `skills-lock.json` instead. Run `bash scripts/sync-skills.sh` to regenerate.
|
|
5
5
|
|
|
6
|
-
**Generated:** 2026-06-
|
|
7
|
-
**Skills:**
|
|
6
|
+
**Generated:** 2026-06-21T21:27:17Z
|
|
7
|
+
**Skills:** 67
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
| Discover | 6 | `elaborate-spec, map-codebase, research-first, search-skills, survey-context, using-bigpowers` |
|
|
16
16
|
| Design | 7 | `deepen-architecture, define-language, define-success, design-interface, grill-me, grill-with-docs, model-domain` |
|
|
17
17
|
| Plan | 9 | `assess-impact, change-request, plan-refactor, plan-release, plan-work, run-planning, scope-work, seed-conventions, slice-tasks` |
|
|
18
|
-
| Build |
|
|
18
|
+
| Build | 17 | `align-grid, build-epic, craft-skill, deploy, develop-tdd, execute-plan, guard-git, hook-commits, kickoff-branch, orchestrate-project, publish-package, setup-environment, smoke-test, spike-prototype, validate-contracts, wire-ci, wire-observability` |
|
|
19
19
|
| Verify | 12 | `audit-code, diagnose-root, enforce-first, fix-bug, inspect-quality, investigate-bug, request-review, respond-review, run-evals, trace-requirement, validate-fix, verify-work` |
|
|
20
20
|
| Release | 2 | `commit-message, release-branch` |
|
|
21
21
|
| Sustain | 13 | `compose-workflow, delegate-task, dispatch-agents, edit-document, evolve-skill, migrate-spec, organize-workspace, reset-baseline, session-state, simulate-agents, stocktake-skills, terse-mode, write-document` |
|
|
22
|
-
| **TOTAL** | **
|
|
22
|
+
| **TOTAL** | **66** | |
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
@@ -63,37 +63,38 @@
|
|
|
63
63
|
| 34 | Build | `setup-environment` | Pre-install dependencies and configure tools before development work begins. Use | ✅ Active |
|
|
64
64
|
| 35 | Build | `smoke-test` | "Post-deploy health-check against a live URL. Validates HTTP status, response co | ✅ Active |
|
|
65
65
|
| 36 | Build | `spike-prototype` | Throw-away prototype for unknown problem spaces. Output is learning notes in spe | ✅ Active |
|
|
66
|
-
| 37 | Build | `
|
|
67
|
-
| 38 | Build | `wire-
|
|
68
|
-
| 39 |
|
|
69
|
-
| 40 | Verify | `
|
|
70
|
-
| 41 | Verify | `
|
|
71
|
-
| 42 | Verify | `
|
|
72
|
-
| 43 | Verify | `
|
|
73
|
-
| 44 | Verify | `
|
|
74
|
-
| 45 | Verify | `
|
|
75
|
-
| 46 | Verify | `
|
|
76
|
-
| 47 | Verify | `
|
|
77
|
-
| 48 | Verify | `
|
|
78
|
-
| 49 | Verify | `
|
|
79
|
-
| 50 | Verify | `
|
|
80
|
-
| 51 |
|
|
81
|
-
| 52 | Release | `
|
|
82
|
-
| 53 |
|
|
83
|
-
| 54 | Sustain | `
|
|
84
|
-
| 55 | Sustain | `
|
|
85
|
-
| 56 | Sustain | `
|
|
86
|
-
| 57 | Sustain | `
|
|
87
|
-
| 58 | Sustain | `
|
|
88
|
-
| 59 | Sustain | `
|
|
89
|
-
| 60 | Sustain | `
|
|
90
|
-
| 61 | Sustain | `
|
|
91
|
-
| 62 | Sustain | `
|
|
92
|
-
| 63 | Sustain | `
|
|
93
|
-
| 64 | Sustain | `
|
|
94
|
-
| 65 | Sustain | `
|
|
95
|
-
|
|
96
|
-
|
|
66
|
+
| 37 | Build | `validate-contracts` | "Assert data shape consistency across system boundaries — live API responses a | ✅ Active |
|
|
67
|
+
| 38 | Build | `wire-ci` | "CI pipeline setup with pre-built templates and local validation. Generates GitH | ✅ Active |
|
|
68
|
+
| 39 | Build | `wire-observability` | Add structured JSON logging, observability commands, and idempotent setup script | ✅ Active |
|
|
69
|
+
| 40 | Verify | `audit-code` | Self-review checklist for the coding agent to run before dispatching a reviewer. | ✅ Active |
|
|
70
|
+
| 41 | Verify | `diagnose-root` | Run 4-phase root cause analysis — reproduce, isolate, hypothesize, verify. Use | ✅ Active |
|
|
71
|
+
| 42 | Verify | `enforce-first` | Apply the F.I.R.S.T test quality rubric (Fast, Independent, Repeatable, Self-Val | ✅ Active |
|
|
72
|
+
| 43 | Verify | `fix-bug` | Bug fix orchestrator — active_flow fix_bug; reads specs/bugs/BUG-*.md; chains | ✅ Active |
|
|
73
|
+
| 44 | Verify | `inspect-quality` | Interactive QA session where user reports bugs or issues conversationally, and t | ✅ Active |
|
|
74
|
+
| 45 | Verify | `investigate-bug` | Investigate a bug or issue by exploring the codebase to find root cause, then wr | ✅ Active |
|
|
75
|
+
| 46 | Verify | `request-review` | Dispatch a fresh reviewer agent with a clean context to critique the code after | ✅ Active |
|
|
76
|
+
| 47 | Verify | `respond-review` | Act on a reviewer agent's feedback systematically — categorize findings, apply | ✅ Active |
|
|
77
|
+
| 48 | Verify | `run-evals` | Eval-Driven Development — define capability and regression evals before buildi | ✅ Active |
|
|
78
|
+
| 49 | Verify | `trace-requirement` | Link story IDs from specs/release-plan.yaml + epic capsule directories to the im | ✅ Active |
|
|
79
|
+
| 50 | Verify | `validate-fix` | Prove a fix works before declaring done — re-run the failing test, run the ful | ✅ Active |
|
|
80
|
+
| 51 | Verify | `verify-work` | Multi-phase UAT gate — cold-start smoke, build, typecheck, lint, tests, step-b | ✅ Active |
|
|
81
|
+
| 52 | Release | `commit-message` | Reviews working-tree changes, then drafts a Conventional Commits title/body and | ✅ Active |
|
|
82
|
+
| 53 | Release | `release-branch` | Make the merge/PR/keep/discard decision for a feature branch, verify coverage ga | ✅ Active |
|
|
83
|
+
| 54 | Sustain | `compose-workflow` | Chain multiple bigpowers skills into a custom workflow recipe saved in specs/. U | ✅ Active |
|
|
84
|
+
| 55 | Sustain | `delegate-task` | Delegate one complex task to a single subagent, review its work in two stages be | ✅ Active |
|
|
85
|
+
| 56 | Sustain | `dispatch-agents` | Dispatch multiple subagents in parallel on independent tasks. No waiting between | ✅ Active |
|
|
86
|
+
| 57 | Sustain | `edit-document` | Edit and improve documents by restructuring sections, improving clarity, and tig | ✅ Active |
|
|
87
|
+
| 58 | Sustain | `evolve-skill` | Benchmark-gated skill evolution — consume bigpowers-benchmark report, propose | ✅ Active |
|
|
88
|
+
| 59 | Sustain | `migrate-spec` | Detect GSD, spec-kit, or BMAD spec artifacts and transform them into bigpowers Y | ✅ Active |
|
|
89
|
+
| 60 | Sustain | `organize-workspace` | Scans the active workspace for disposable artifacts—logs, caches, stale build | ✅ Active |
|
|
90
|
+
| 61 | Sustain | `reset-baseline` | Restore the project to a known clean state between agent runs or experiments. Us | ✅ Active |
|
|
91
|
+
| 62 | Sustain | `session-state` | Track implementation decisions and progress in specs/state.yaml to prevent conte | ✅ Active |
|
|
92
|
+
| 63 | Sustain | `simulate-agents` | Run Mock User and Auditor agents against a feature in fresh contexts before huma | ✅ Active |
|
|
93
|
+
| 64 | Sustain | `stocktake-skills` | Sequential subagent batch audit of the bigpowers skill catalog — Quick Scan (c | ✅ Active |
|
|
94
|
+
| 65 | Sustain | `terse-mode` | Fallback ultra-compressed communication mode. Cuts token usage ~75% by dropping | ✅ Active |
|
|
95
|
+
| 66 | Sustain | `write-document` | Write, organize, and sync high-integrity technical documents using the BMAD meth | ✅ Active |
|
|
96
|
+
|
|
97
|
+
**Total: 66 active skills.**
|
|
97
98
|
|
|
98
99
|
---
|
|
99
100
|
|
package/audit-code/SKILL.md
CHANGED
|
@@ -16,6 +16,7 @@ Run this self-review before asking anyone else to look at the code. The goal is
|
|
|
16
16
|
|
|
17
17
|
- Default: full checklist
|
|
18
18
|
- --quick: Run only Supply Chain and Test Coverage. Use for changes under 50 LOC.
|
|
19
|
+
- --gate: Non-interactive mode for automated CI gating (used by build-epic step 6). Exit with non-zero status code (`exit 1`) on ANY checklist failure; `exit 0` only if ALL items pass. Produces a compact pass/fail summary to stderr. On failure, list every ✗ item with reason.
|
|
19
20
|
|
|
20
21
|
## Checklist
|
|
21
22
|
|
|
@@ -105,6 +106,19 @@ Report the checklist with ✓ / ✗ per item. For each ✗, describe what needs
|
|
|
105
106
|
If all items pass: suggest running `request-review` for an independent second opinion.
|
|
106
107
|
If any items fail: fix them before proceeding.
|
|
107
108
|
|
|
109
|
+
### Gate mode output (`--gate`)
|
|
110
|
+
|
|
111
|
+
In `--gate` mode, print one summary line per checklist section:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
PASS Supply Chain & Security
|
|
115
|
+
FAIL Provenance & Metadata (2 items)
|
|
116
|
+
PASS Law of Demeter
|
|
117
|
+
...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Aggregate exit code: `0` if all sections PASS, `1` (non-zero) if any section FAILs. Write the full audit report to `specs/verifications/AUDIT-<epic>-<story>.md` as a permanent record.
|
|
121
|
+
|
|
108
122
|
## Handoff
|
|
109
123
|
|
|
110
124
|
Gate: READY -> next: commit-message
|
package/build-epic/SKILL.md
CHANGED
|
@@ -23,7 +23,7 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
23
23
|
| 3 | `kickoff-branch` — feature branch + clean baseline |
|
|
24
24
|
| 4 | `develop-tdd` — red-green per task |
|
|
25
25
|
| 5 | `verify-work` — UAT + mechanical gates |
|
|
26
|
-
| 6 | `audit-code` —
|
|
26
|
+
| 6 | `audit-code` — **non-optional gate** (pass/fail; fail → loop back to step 4) |
|
|
27
27
|
| 7 | `commit-message` — Conventional Commits draft |
|
|
28
28
|
| 8 | `release-branch` — PR or solo land |
|
|
29
29
|
|
|
@@ -36,6 +36,15 @@ Orchestrates the **build** flow for a single epic: survey → plan tasks → kic
|
|
|
36
36
|
5. After step verify passes, increment `epic_cycle.step` in `state.yaml` (or `bash scripts/bp-yaml-set.sh` if available).
|
|
37
37
|
6. On story complete, set `execution-status.yaml` story key to `done`; run `bash scripts/sync-status-from-epics.sh`.
|
|
38
38
|
|
|
39
|
+
### Step 6 — audit-code gate (non-optional)
|
|
40
|
+
|
|
41
|
+
After step 5 (verify-work) completes successfully, step 6 runs `audit-code` automatically in `--gate` mode:
|
|
42
|
+
|
|
43
|
+
1. **Run audit:** Invoke `audit-code --gate` on the complete diff for this story.
|
|
44
|
+
2. **Pass (exit 0):** All checklist sections pass → advance to step 7 (commit-message). Record `epic_cycle.audit_result: pass` in `state.yaml`.
|
|
45
|
+
3. **Fail (exit 1):** One or more checklist sections fail → **reset `epic_cycle.current_step` to `4`** (develop-tdd) and add the failing section IDs to `completed_steps` as `"1,2,3,4,5,6(fail: ...)"`. Record `epic_cycle.audit_result: fail` in `state.yaml`. Do NOT advance past step 6 until audit passes.
|
|
46
|
+
4. **Audit artifact:** Full audit report saved to `specs/verifications/AUDIT-<epic>-<story>.md` regardless of pass/fail, for reviewer traceability.
|
|
47
|
+
|
|
39
48
|
## Handoff
|
|
40
49
|
|
|
41
50
|
Write `handoff.next_skill` and `handoff.context` in `state.yaml` when pausing mid-epic.
|
package/package.json
CHANGED
package/skills-lock.json
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"audit-code": {
|
|
15
15
|
"description": "Self-review checklist for the coding agent to run before dispatching a reviewer. Checks CONVENTIONS.md compliance, Boy Scout Rule, test coverage, types, and SOLID. Produces a pass/fail checklist. Use before request-review, before committing, or when user asks for a code quality check.",
|
|
16
|
-
"sha256": "
|
|
16
|
+
"sha256": "8192ebe6f66a9f91",
|
|
17
17
|
"path": "audit-code/SKILL.md"
|
|
18
18
|
},
|
|
19
19
|
"build-epic": {
|
|
20
20
|
"description": "Eight-step epic build cycle — reads state.yaml, execution-status.yaml, and one epic capsule; updates status via bp-yaml-set or direct edit. Resume mode runs one step per invocation. Use instead of ad-hoc execute-plan for release work.",
|
|
21
|
-
"sha256": "
|
|
21
|
+
"sha256": "ac7c8fc9740c4beb",
|
|
22
22
|
"path": "build-epic/SKILL.md"
|
|
23
23
|
},
|
|
24
24
|
"change-request": {
|
|
@@ -301,6 +301,11 @@
|
|
|
301
301
|
"sha256": "b150ea218b529f61",
|
|
302
302
|
"path": "using-bigpowers/SKILL.md"
|
|
303
303
|
},
|
|
304
|
+
"validate-contracts": {
|
|
305
|
+
"description": "\"Assert data shape consistency across system boundaries — live API responses against JSON Schema, key-set comparison across layers, data shape validation for migrations and exports. Catches silent data corruption before deploy.\"",
|
|
306
|
+
"sha256": "17653c7ac211c5d8",
|
|
307
|
+
"path": "validate-contracts/SKILL.md"
|
|
308
|
+
},
|
|
304
309
|
"validate-fix": {
|
|
305
310
|
"description": "Prove a fix works before declaring done — re-run the failing test, run the full suite, typecheck, lint, and harden against recurrence. Use after implementing a bug fix, when user says \"is this fixed?\", or before closing an investigation.",
|
|
306
311
|
"sha256": "80fc28e511a501dc",
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: validate-contracts
|
|
3
|
+
description: "Assert data shape consistency across system boundaries — live API responses against JSON Schema, key-set comparison across layers, data shape validation for migrations and exports. Catches silent data corruption before deploy."
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Validate Contracts
|
|
8
|
+
|
|
9
|
+
> **HARD GATE** — Do NOT deploy or migrate data without running `validate-contracts` first. Silent data divergence between system boundaries causes the hardest-to-debug production bugs.
|
|
10
|
+
>
|
|
11
|
+
> **HARD GATE** — Contract files MUST be version-controlled alongside code. Outdated contracts are worse than no contracts. If a contract hasn't been reviewed in 30 days, flag it as stale.
|
|
12
|
+
|
|
13
|
+
Validate that data structures stay in sync across system boundaries — front-end vs
|
|
14
|
+
back-end, API responses vs expected schemas, config files vs code assumptions,
|
|
15
|
+
migration output vs target shape.
|
|
16
|
+
|
|
17
|
+
## Contract types
|
|
18
|
+
|
|
19
|
+
Three modes of validation:
|
|
20
|
+
|
|
21
|
+
| Mode | What it catches | When to use |
|
|
22
|
+
|------|----------------|-------------|
|
|
23
|
+
| **Schema** | API response shape mismatches (missing field, wrong type) | Before every deploy, after API changes |
|
|
24
|
+
| **Key-set** | Missing/unexpected keys across two data sources | Translation files, configs, enum definitions |
|
|
25
|
+
| **Shape** | Column type or format violations in data files | After migrations, before consuming exports |
|
|
26
|
+
|
|
27
|
+
## Contract file convention
|
|
28
|
+
|
|
29
|
+
All contract files live in `specs/contracts/` and use YAML:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
specs/contracts/
|
|
33
|
+
├── users.schema.yaml # API response schema
|
|
34
|
+
├── i18n-keys.yaml # Key-set comparison
|
|
35
|
+
├── migration-output.yaml # Data shape contract
|
|
36
|
+
└── README.md # Local conventions
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 1. API Response Contracts (`--schema`)
|
|
40
|
+
|
|
41
|
+
Define expected API response shapes and validate live endpoints against them:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
# specs/contracts/users.schema.yaml
|
|
45
|
+
endpoint: /api/users
|
|
46
|
+
method: GET
|
|
47
|
+
schema:
|
|
48
|
+
type: object
|
|
49
|
+
required: [id, name, email]
|
|
50
|
+
properties:
|
|
51
|
+
id: { type: number }
|
|
52
|
+
name: { type: string }
|
|
53
|
+
email: { type: string, format: email }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Usage:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
validate-contracts --schema specs/contracts/users.schema.yaml --url https://api.example.com/users
|
|
60
|
+
# → PASS: /api/users matches expected schema (3/3 fields, types ok)
|
|
61
|
+
# → FAIL: /api/users — field 'email' has type null (expected string)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. Key-Set Contracts (`--key-set`)
|
|
65
|
+
|
|
66
|
+
Assert that two data sources share a consistent set of keys:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
# specs/contracts/i18n-keys.yaml
|
|
70
|
+
sources:
|
|
71
|
+
reference: src/frontend/locales/en.json
|
|
72
|
+
target: src/backend/messages/en.json
|
|
73
|
+
mode: subset # all target keys must exist in reference
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Usage:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
validate-contracts --key-set specs/contracts/i18n-keys.yaml
|
|
80
|
+
# → missing: 2 keys in reference not found in target: ['settings.privacy', 'help.faq']
|
|
81
|
+
# → added: 1 key in target not in reference: ['deprecated.field']
|
|
82
|
+
# → exit 1 (divergence)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 3. Data Shape Contracts (`--shape`)
|
|
86
|
+
|
|
87
|
+
Validate that a data file matches expected column types and constraints:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
# specs/contracts/migration-output.yaml
|
|
91
|
+
file: data/users-export.json
|
|
92
|
+
format: json
|
|
93
|
+
fields:
|
|
94
|
+
- name: user_id
|
|
95
|
+
type: number
|
|
96
|
+
required: true
|
|
97
|
+
- name: full_name
|
|
98
|
+
type: string
|
|
99
|
+
required: true
|
|
100
|
+
- name: created_at
|
|
101
|
+
type: string
|
|
102
|
+
format: date-time
|
|
103
|
+
required: false
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Usage:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
validate-contracts --shape specs/contracts/migration-output.yaml
|
|
110
|
+
# → PASS: 3/3 fields validated, 5000 rows OK
|
|
111
|
+
# → WARN: field 'full_name' has 12 null values (0.24%)
|
|
112
|
+
# → FAIL: field 'user_id' has 3 rows with type string (expected number)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Process
|
|
116
|
+
|
|
117
|
+
### 1. Define contract
|
|
118
|
+
|
|
119
|
+
Create a YAML file in `specs/contracts/` following the schema for the mode.
|
|
120
|
+
|
|
121
|
+
### 2. Run validation
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The runner auto-detects the contract type from the file content (presence of `schema:`,
|
|
128
|
+
`sources:`, or `file:` + `fields:` keys).
|
|
129
|
+
|
|
130
|
+
### 3. Read the report
|
|
131
|
+
|
|
132
|
+
Output is JSON Lines (one event per line) plus a human-readable summary:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
{"event":"pass","check":"users.schema","detail":"3/3 fields match types"}
|
|
136
|
+
{"event":"warn","check":"users.schema","detail":"field 'avatar' has format: uri (unexpected)"}
|
|
137
|
+
{"event":"fail","check":"i18n-keys","detail":"missing: 2 keys in target"}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Final summary:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
=== Validate Contracts Summary ===
|
|
144
|
+
Schema: 3/3 pass | Key-set: 1/1 fail | Shape: 2/2 pass
|
|
145
|
+
FAILED: 1 contract has divergence
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 4. Fix divergence
|
|
149
|
+
|
|
150
|
+
- **Missing keys** → add to target source
|
|
151
|
+
- **Type mismatches** → update schema or fix producer
|
|
152
|
+
- **Shape violations** → fix migration or consumer
|
|
153
|
+
|
|
154
|
+
### 5. Re-validate
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
bash scripts/validate-contracts.sh <contract-file>
|
|
158
|
+
# → All pass → ready to deploy
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Integration
|
|
162
|
+
|
|
163
|
+
- **Pre-deploy gate:** The `deploy` skill runs `validate-contracts` before smoke-test.
|
|
164
|
+
- **CI pipeline:** JSON Lines output is CI-friendly; pipe to `jq` for assertions.
|
|
165
|
+
- **Pre-migration:** Run `validate-contracts --shape` before consuming migration output.
|
|
166
|
+
|
|
167
|
+
## Configuration
|
|
168
|
+
|
|
169
|
+
| Variable | Default | Description |
|
|
170
|
+
|----------|---------|-------------|
|
|
171
|
+
| `CONTRACTS_DIR` | `specs/contracts/` | Directory containing contract YAML files |
|
|
172
|
+
| `VALIDATE_ALL` | `false` | If true, run all contracts in the directory |
|
|
173
|
+
| `STRICT_MODE` | `false` | Treat warnings as failures |
|
|
174
|
+
| `OUTPUT_FORMAT` | `text` | `text` or `json` |
|
|
175
|
+
|
|
176
|
+
## Verification
|
|
177
|
+
|
|
178
|
+
→ verify: `test -f validate-contracts/SKILL.md && grep -q 'name: validate-contracts' validate-contracts/SKILL.md && echo OK`
|
|
179
|
+
→ verify: `grep -qi 'specs/contracts\|JSON Schema\|key.set\|data.shape' validate-contracts/SKILL.md && echo OK`
|
|
180
|
+
→ verify: `grep -ci 'divergence\|missing key\|type mismatch\|diff\|conforms\|column' validate-contracts/SKILL.md | awk '{if($1>=3) print "OK"; else print "FAIL"}'`
|
|
181
|
+
→ verify: `grep -ci 'JSON Lines\|machine.parse\|CI\|deploy.*gate\|pre.deploy' validate-contracts/SKILL.md | awk '{if($1>=2) print "OK"; else print "FAIL"}'`
|
|
182
|
+
→ verify: `grep -q 'validate-contracts' SKILL-INDEX.md && echo OK`
|