@akjamie/agentic-sdlc 1.0.0 → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: asdlc-impl-review
3
- description: "Independent AI Implementation Review (Stage 6.5): evaluate an Impl PR for spec conformance, code quality, test fidelity, and production readiness before human lead approval. Accepts a GitHub PR URL or local CHANGE_ID."
3
+ description: "Independent AI Implementation Review (Stage 6.5): evaluate an Impl PR for spec conformance, code quality, test fidelity, and production readiness before human lead approval. Incorporates Anthropic code review principles (anti-thrashing convergence, 3-round cap, repo-level REVIEW.md contracts, introduced-vs-preexisting defect attribution, and risk tiering). Accepts a GitHub PR URL or local CHANGE_ID."
4
4
  aliases:
5
5
  - impl-review
6
6
  - code-review-asdlc
@@ -13,6 +13,16 @@ It posts its findings as a **markdown PR comment** via the GitHub API so the hum
13
13
 
14
14
  It applies the **Player ≠ Referee** principle: the reviewing agent MUST NOT be the agent that authored the implementation.
15
15
 
16
+ ### Core Philosophy: Protecting Human Time & Attention
17
+
18
+ Drawing from Anthropic's engineering practices for scaling AI code reviews, this reviewer enforces:
19
+ 1. **Convergence Protocol**: Review loops must converge, not thrash. Capped at **3 rounds** max; re-reviews inspect **incremental diffs only**.
20
+ 2. **Defect Attribution**: Clearly separates defects introduced by this PR (`[Blocker: Introduced]`) from pre-existing legacy issues (`[Tech Debt: Pre-existing]`). Pre-existing flaws **never block** the PR.
21
+ 3. **Repository Contract (`REVIEW.md`)**: Respects repository-defined domain rules, failure modes, and ignore paths from the trusted base branch over generic AI opinions.
22
+ 4. **Risk-Based Tiering**: Scrutiny scales with the change's risk profile (Tier 1 Docs/Style, Tier 2 Standard, Tier 3 Critical/Auth/Billing). Highest-risk file sets the PR tier.
23
+ 5. **Class-of-Bug Grouping**: Defect patterns are grouped into singular findings rather than fragmented into line-by-line spam.
24
+ 6. **Structural & Actionable Findings**: Every finding provides explicit Location, Defect, Impact, and Action Required for instant clarity to both AI agents and human leads.
25
+
16
26
  > [!IMPORTANT]
17
27
  > **Scope**: Reviews *implementation conformance and code quality* — spec adherence, test rigor, architecture, and production safety.
18
28
  > Requires `asdlc verify <CHANGE_ID>` to have passed (12 gates) before this review is meaningful.
@@ -53,49 +63,129 @@ stage('Implementation AI Review') {
53
63
 
54
64
  ## Workflow Sequence
55
65
 
56
- ### Step 1: Acquire PR Context
66
+ ### Step 1: Acquire PR Context & Discover Repo Contract
57
67
 
58
- Run the following commands to collect everything needed for review:
68
+ Run the following commands to collect PR metadata, history, and repo review contracts:
59
69
 
60
70
  ```bash
61
- # List changed files and metadata
62
- gh pr view $PR_NUMBER --repo $REPO --json title,body,baseRefName,headRefName,files
63
-
64
- # Read the full implementation diff
65
- gh pr diff $PR_NUMBER --repo $REPO
71
+ # 1. Fetch PR metadata and previous review comments
72
+ gh pr view $PR_NUMBER --repo $REPO --json title,body,baseRefName,headRefName,headRefOid,comments,files
73
+
74
+ # 2. Check for repository-level REVIEW.md contract from trusted base branch
75
+ # Checked in order: .asdlc/REVIEW.md -> openspec/REVIEW.md -> REVIEW.md
76
+ # IMPORTANT: Always read from origin/<baseRefName>, NEVER from PR HEAD,
77
+ # to prevent self-review bypasses (e.g., PR injecting path exclusions or rewriting failure definitions).
78
+ git show origin/<baseRefName>:.asdlc/REVIEW.md 2>/dev/null || \
79
+ git show origin/<baseRefName>:openspec/REVIEW.md 2>/dev/null || \
80
+ git show origin/<baseRefName>:REVIEW.md 2>/dev/null || true
66
81
  ```
67
82
 
68
- Extract from the PR body or branch:
69
- - `CHANGE_ID` from the `**Change ID**:` field or branch name
70
- - `specSha` from `.openspec.yaml` (read from the base branch or PR file list)
71
-
72
- Then read the approved spec to use as ground truth:
73
-
83
+ Extract from the PR body, comments, and repo contract:
84
+ - `CHANGE_ID` from the `**Change ID**:` field or branch name (`asdlc/impl/<CHANGE_ID>`)
85
+ - `specSha` from `.openspec.yaml` (read from base branch or PR files)
86
+ - `headRefOid`: Current commit SHA under review
87
+ - `reviewRound`: Count previous `## 🤖 AI Implementation Review` comments on this PR:
88
+ - If 0 previous comments → **Round 1 (Initial Review)**
89
+ - If 1 previous comment → **Round 2 (Re-review)**
90
+ - If 2 previous comments → **Round 3 (Final Automated Round)**
91
+ - If 3+ previous comments → **ESCALATED TO HUMAN** (Anti-thrashing limit reached: do NOT post another review comment; set CI status to failure pointing to previous escalation).
92
+ - `lastReviewedSha`: Extracted from the `> **Commit SHA**:` line of the most recent AI review comment.
93
+
94
+ #### Repository Review Contract (`REVIEW.md`)
95
+ If a `REVIEW.md` exists on the base branch, parse and enforce its declared specifications:
96
+ - **What failure looks like**: Domain-specific definitions of defect (e.g., "for billing: currency precision loss; for router: unhandled 404 fallback").
97
+ - **Path Exclusions / Ignores**: Exclude auto-generated files, lockfiles, or fixture dumps from review scrutiny.
98
+ - **Non-Negotiable Invariants**: Explicit architectural rules that supersede generic style preferences.
99
+
100
+ #### Risk-Based Tiering
101
+ Classify the PR into one of three risk tiers based on files changed (**highest-risk file sets the PR tier**):
102
+ - **Tier 1 (Low Risk)**: Documentation, comments, copy, purely additive test fixtures, styling/CSS.
103
+ *Protocol*: Single-pass lightweight check for factual accuracy, typos, and broken links. Skip the AC Conformance Matrix unless specific ACs were defined in the spec.
104
+ - **Tier 2 (Standard Risk)**: Standard application features, domain services, UI state, API endpoints.
105
+ *Protocol*: Full 5-dimension review, AC Conformance Matrix, test fidelity check.
106
+ - **Tier 3 (High Risk)**: Auth/security, payment/billing, cryptography, DB migrations, core CI/governance engine, or **any PR modifying `REVIEW.md` or governance files**.
107
+ *Protocol*: Rigorous scrutiny, failure-mode analysis, strict zero-tolerance for untested edge cases, mandatory human lead sign-off. Flag governance modification explicitly in the review body.
108
+
109
+ #### Read Approved Spec Ground Truth
74
110
  ```bash
75
111
  # Read the approved spec from the base branch
76
112
  git show origin/<baseRefName>:openspec/changes/<CHANGE_ID>/specs/<capability>/spec.md
77
113
  git show origin/<baseRefName>:openspec/changes/<CHANGE_ID>/tasks.md
114
+
115
+ # Execute Acceptance Tests in CI (Player != Referee gate)
116
+ asdlc test <CHANGE_ID> --json
78
117
  ```
79
118
 
80
119
  > [!NOTE]
81
120
  > Read the **spec first**, then the implementation diff. The spec is the ground truth; the code is the candidate.
121
+ > Enforce **Player ≠ Referee**: CI executes `asdlc test <CHANGE_ID> --json` independently rather than trusting claims in `tasks.md`.
82
122
 
83
123
  ---
84
124
 
85
- ### Step 2: Apply the Five Review Dimensions
125
+ ### Step 2: Determine Diff Scope & Anti-Thrashing Protocol
126
+
127
+ To prevent infinite review-author thrashing and fatigue:
128
+
129
+ #### A. Diff-Only Re-Review (Rounds 2 & 3)
130
+ - **Round 1**: Inspect the full PR diff:
131
+ ```bash
132
+ gh pr diff $PR_NUMBER --repo $REPO
133
+ ```
134
+ - **Round 2+**: Inspect **ONLY** the incremental diff since the last reviewed commit:
135
+ ```bash
136
+ # Ensure lastReviewedSha is available in shallow CI clones
137
+ git cat-file -e $lastReviewedSha^{commit} 2>/dev/null || \
138
+ git fetch origin $lastReviewedSha --depth=1 2>/dev/null || \
139
+ git fetch origin $baseRefName --depth=50 2>/dev/null || true
140
+
141
+ # Check for force-push / history rewrite:
142
+ # If lastReviewedSha is not an ancestor of headRefOid, reset to fresh Round 1 full diff
143
+ if ! git merge-base --is-ancestor $lastReviewedSha $headRefOid 2>/dev/null; then
144
+ echo "Force-push or rebase detected: commit history was rewritten. Resetting to full-diff review."
145
+ gh pr diff $PR_NUMBER --repo $REPO
146
+ else
147
+ git diff $lastReviewedSha...$headRefOid
148
+ fi
149
+ ```
150
+ *Never re-review unchanged baseline code or lines previously deemed acceptable.*
151
+
152
+ #### B. Thread Resolution & Accounting
153
+ On re-reviews (Rounds 2 & 3), audit each previously reported Blocker and Major finding using stable IDs (`R1-#1`, `R1-#2`, `R2-#1`):
154
+ - **✅ Resolved**: Explicitly verified as fixed in the incremental diff.
155
+ - **⚠️ Disputed / Justified**: Author provided clear architectural justification or documented trade-off in PR comments.
156
+ - **❌ Unresolved**: Finding remains unaddressed without justification.
157
+
158
+ #### C. Class-of-Bug Grouping
159
+ Do not post 10 separate line comments for the same recurring pattern (e.g., missing timeout on HTTP requests or unhandled nulls).
160
+ Roll them up into a single finding citing all affected locations:
161
+ > *"Class of Bug: Missing timeoutMs on outbound fetch calls in 4 handlers (`api/users.ts:42`, `api/billing.ts:88`, ...)"*
162
+
163
+ #### D. No-Repeat Suppression
164
+ Do not re-surface previously posted findings unless the author explicitly claimed to fix them in the current commit and failed.
165
+
166
+ #### E. 3-Round Convergence Cap
167
+ If Round 3 completes with unresolved blockers:
168
+ - Set verdict to `⚠️ ESCALATED_TO_HUMAN`.
169
+ - Do not trigger further automated loops.
170
+ - Provide a concise summary of the impasse for the human lead.
86
171
 
87
- Evaluate the full diff against all five dimensions. Mark each `PASS`, `CONCERN`, or `FAIL`.
172
+ ---
88
173
 
89
- #### D1 — Spec Conformance (AC-by-AC)
90
- For every `ACn:` in `specs/**/*.md`:
91
- - Does the implementation satisfy the exact acceptance criterion as written?
92
- - Is the behavior exercised in the mapped `(test: <path>)` test?
93
- - Are there any requirements in the spec with **no implementation coverage**?
94
- - Are there any implemented behaviors with **no corresponding AC** (scope creep)?
174
+ ### Step 3: Apply the Five Review Dimensions
95
175
 
96
- Flag scope creep as Major: it bypasses the governance gate and introduces untested surface area.
176
+ Evaluate the diff against all five dimensions, informed by `REVIEW.md` and spec ground truth. Mark each `PASS`, `CONCERN`, or `FAIL`.
177
+
178
+ #### D1 — Spec Conformance (AC-by-AC)
179
+ - **Acceptance Test Gate**: Did `asdlc test <CHANGE_ID>` pass with exit code 0? If any mapped test failed or is missing, mark as **🔴 Blocker: Introduced**.
180
+ - For every `ACn:` in `specs/**/*.md`:
181
+ - Does the implementation satisfy the exact acceptance criterion as written?
182
+ - Is the behavior exercised in the mapped `(test: <path>)` test?
183
+ - Are there any requirements in the spec with **no implementation coverage**?
184
+ - Are there any implemented behaviors with **no corresponding AC** (scope creep)?
185
+ - Flag scope creep as Major: it bypasses the governance gate and introduces untested surface area.
97
186
 
98
187
  #### D2 — Code Quality & Architecture
188
+ - **REVIEW.md Compliance**: Adheres to all repository-declared architectural invariants.
99
189
  - **Deep modules**: Does each new module expose a simple interface hiding a complex interior? Flag shallow wrappers that leak implementation detail.
100
190
  - **Single Responsibility**: Does each function / class do one thing? Flag functions mixing IO and business logic in the same body.
101
191
  - **Error propagation**: Are errors surfaced explicitly (typed error objects or Result types), not swallowed silently?
@@ -107,7 +197,7 @@ Flag scope creep as Major: it bypasses the governance gate and introduces untest
107
197
  - Are mocks **minimal and scoped**? A mock replacing an entire subsystem and always returning a happy-path fixture is a vacuous test.
108
198
  - Does each test exercise the **failure path** as well as the happy path?
109
199
  - Does `tasks.md` contain real test runner output for every `[x]` task (not just "✅ done")?
110
- - Are edge cases from the spec (e.g. rainy-day ranking, high-temp advisory, upstream-API-unavailable fallback) each exercised by a distinct test case?
200
+ - Are edge cases from the spec each exercised by a distinct test case?
111
201
 
112
202
  #### D4 — Production Readiness & Performance
113
203
  - **NFRs met**: If the spec declares a latency SLA, is there a test or benchmark that fails when the SLA is violated?
@@ -123,31 +213,20 @@ Flag scope creep as Major: it bypasses the governance gate and introduces untest
123
213
 
124
214
  ---
125
215
 
126
- ### Step 3: Build the AC Conformance Matrix
216
+ ### Step 4: Formulate Structural Findings with Defect Attribution
127
217
 
128
- For each `ACn:` in the approved spec, produce one row:
218
+ Every finding must follow a structured schema with explicit defect attribution so that findings are unambiguously actionable for both AI agents and human engineers:
129
219
 
130
- | AC | Spec Assertion | Implemented In | Test File | Status |
131
- | :--- | :--- | :--- | :--- | :--- |
132
- | AC1 | <assertion text> | src/<module>.ts | test/<feature>.test.ts | ✅ PASS / ❌ MISSING |
133
-
134
- Mark `❌ MISSING` for any AC whose implementation or test cannot be located in the diff.
135
-
136
- ---
137
-
138
- ### Step 4: Formulate Findings
139
-
140
- Classify each finding:
141
-
142
- - **🔴 Blocker** — AC not implemented, test always passes regardless of code, hard-coded secret, resource leak, spec-forbidden behavior present. Blocks merge.
143
- - **🟡 Major** — Scope creep (code not covered by any AC), vacuous mock, missing timeout on upstream HTTP call, PII in logs.
144
- - **🟢 Advisory** — Naming clarity, minor refactor opportunity, optional performance improvement.
220
+ - **🔴 [Blocker: Introduced]** — Broken AC, test cheating/vacuous mock, regression, hardcoded secret, or resource leak **introduced by this PR**. **Blocks merge.**
221
+ - **🟡 [Major: Introduced]** — Material defect introduced by this PR (scope creep, missing error handling, unhandled edge case). Requires resolution or author justification.
222
+ - **⚪ [Tech Debt: Pre-existing]** — Existing legacy codebase flaw or code smell observed in touched files but **not introduced by this PR**. **DOES NOT block merge.** Documented separately for backlog tracking.
223
+ - **🟢 [Advisory]** — Non-blocking suggestions for readability, naming clarity, or optional polish.
145
224
 
146
225
  ---
147
226
 
148
227
  ### Step 5: Post PR Comment
149
228
 
150
- Compose the review as markdown and post it as a PR comment using the GitHub API:
229
+ Compose the review markdown and post it as a PR comment using the GitHub API:
151
230
 
152
231
  ```bash
153
232
  gh pr comment $PR_NUMBER --repo $REPO --body "$(cat <<'EOF'
@@ -162,8 +241,11 @@ Format the comment body strictly as:
162
241
  ## 🤖 AI Implementation Review — `<CHANGE_ID>`
163
242
 
164
243
  > **Reviewer**: AI Independent Implementation Reviewer (`asdlc-impl-review`)
244
+ > **Commit SHA**: `<headRefOid>`
165
245
  > **Base spec SHA**: `<specSha>`
166
- > **Verdict**: ✅ APPROVE | 🔴 REQUEST_CHANGES
246
+ > **Risk Tier**: Tier 1 (Low) | Tier 2 (Standard) | Tier 3 (High)
247
+ > **Review Round**: Round 1 of 3 | Round 2 of 3 | Round 3 of 3 (Final)
248
+ > **Verdict**: ✅ APPROVE | 🔴 REQUEST_CHANGES | ⚠️ ESCALATED_TO_HUMAN
167
249
 
168
250
  ### Dimension Scores
169
251
 
@@ -176,21 +258,49 @@ Format the comment body strictly as:
176
258
  | D5 Security & Secret Hygiene | ✅ / ⚠️ / ❌ | <one-line summary> |
177
259
 
178
260
  ### AC Conformance Matrix
261
+ <!-- For Tier 1 changes with no spec ACs, replace table with: "*Tier 1 change — AC Conformance Matrix omitted.*" -->
179
262
 
180
263
  | AC | Spec Assertion | Implemented In | Test File | Status |
181
264
  | :--- | :--- | :--- | :--- | :--- |
182
265
  | AC1 | <assertion text> | src/<module>.ts | test/<feature>.test.ts | ✅ PASS |
183
266
 
184
- ### 🔴 Blocking Findings
185
- <!-- Omit section if none -->
186
- 1. **[Blocker]** `<file>:<line-range>` — AC<n>: <description of gap or violation>
187
-
188
- ### 🟡 Major Findings
267
+ <!-- On Rounds 2 and 3, include Thread Resolution Accounting -->
268
+ ### 🔄 Re-Review Accounting (Round <round>)
269
+ | Finding ID | Previous Finding Summary | Status | Resolution / Author Rationale |
270
+ | :---: | :--- | :---: | :--- |
271
+ | `R1-#1` | Missing 5000ms timeout in fetch | ✅ Resolved | Added `AbortSignal.timeout(5000)` in `src/http.ts:24` |
272
+ | `R1-#2` | Scope creep helper `parseAmount` | ⚠️ Justified | Author rationale: Shared utility required for currency normalization |
273
+
274
+ ### 🔴 Blocking Findings (Introduced)
275
+ <!-- Omit section if none. Use structural format for AI/Human clarity -->
276
+ - **ID**: `R<round>-#<num>`
277
+ - **Category**: `Spec Conformance` | `Code Quality` | `Test Fidelity` | `Production Readiness` | `Security`
278
+ - **Rule / AC**: `<ACn or REVIEW.md invariant or Dimension D1-D5>`
279
+ - **Location**: `<file>:<line-range>`
280
+ - **Defect**: `<concise statement of what is broken>`
281
+ - **Impact**: `<why this breaks correctness, security, or production>`
282
+ - **Action Required**: `<exact condition or code fix required to resolve>`
283
+
284
+ ### 🟡 Major Findings (Introduced)
189
285
  <!-- Omit section if none -->
190
- 1. **[Major]** <description>
286
+ - **ID**: `R<round>-#<num>`
287
+ - **Category**: `<category>`
288
+ - **Location**: `<file>:<line-range>`
289
+ - **Defect**: `<description>`
290
+ - **Impact**: `<impact>`
291
+ - **Action Required**: `<action required>`
292
+
293
+ ### ⚪ Tech Debt: Pre-existing Codebase Observations
294
+ <!-- Non-blocking; omit section if none -->
295
+ - **ID**: `DEBT-#<num>`
296
+ - **Location**: `<file>:<line-range>`
297
+ - **Defect**: `<description of pre-existing legacy issue, untouched by PR>`
298
+ - **Attribution**: Pre-existing code untouched by this PR diff.
299
+ - **Status**: Non-blocking. Logged for tech debt backlog.
191
300
 
192
301
  ### 🟢 Advisory Notes
193
302
  <!-- Omit section if none -->
303
+ 1. **[Advisory]** <description>
194
304
 
195
305
  ---
196
306
  *Human lead: review the findings above, then merge when satisfied. After merge, run `asdlc archive <CHANGE_ID>`.*
@@ -200,15 +310,16 @@ Format the comment body strictly as:
200
310
 
201
311
  ### Step 6: Set CI Status
202
312
 
203
- After posting the comment:
313
+ After posting the comment, set the commit status check:
204
314
 
205
315
  - **If APPROVE**: set CI check status to `success` (green). The PR is unblocked for lead approval and merge.
206
316
  - **If REQUEST_CHANGES**: set CI check status to `failure` (red). The PR is blocked until blockers are resolved.
317
+ - **If ESCALATED_TO_HUMAN**: set CI check status to `failure` (red) with description noting human arbitration is required.
207
318
 
208
319
  ```bash
209
320
  gh api repos/$REPO/statuses/$SHA \
210
321
  -f state="success|failure" \
211
322
  -f context="asdlc/impl-ai-review" \
212
- -f description="AI Impl Review: APPROVE|REQUEST_CHANGES" \
323
+ -f description="AI Impl Review: APPROVE | REQUEST_CHANGES | ESCALATED_TO_HUMAN" \
213
324
  -f target_url="$PR_URL"
214
325
  ```
@@ -18,9 +18,12 @@ The linter evaluates spec text with pure deterministic rules (no LLM jitter):
18
18
  - **`R3-scenario`**: Every requirement must have at least one `#### Scenario:`.
19
19
  - **`R4-when / R4-then / R4-given`**: Every scenario must follow BDD structure with **WHEN**, **THEN**, and **GIVEN**.
20
20
  - **`R5-ac`**: Every requirement must have an Acceptance Criteria block (`- [ ] AC1: ...`).
21
+ - **`R5-scenario-coverage`**: Every scenario under a requirement must have corresponding acceptance criteria (`scenarios.length <= acs.length`), preventing happy-path-only AC shortcuts when edge cases / alternative flows are specified in scenarios.
21
22
  - **`R6-ac-test`**: Every acceptance criterion must map to an explicit test file path (`(test: <path>)`).
22
23
  - **`R7-test-strategy`**: Must contain a non-empty `## Test Strategy` section.
23
24
  - **`R8-removed-reason`**: Any requirement under `## REMOVED Requirements` must document a `**Reason**`.
25
+ - **`design.md` Quality & Enforcement**: Mandatory whenever proposal or specs touch UI/frontend or external/3rd-party APIs. Fails if missing when UI or external APIs are present, or if it contains empty template placeholders.
26
+ - **Visual Acceptance Criteria (UI specs)**: UI requirements must include visual ACs covering responsive breakpoints (mobile, desktop) and interaction states (loading, empty, error), mapped to test files (`(test: <path>)`).
24
27
  - **Review Status**: If `review.md` is present, it must have `## Verdict: APPROVE` and zero blocking findings. (On pre-merge branches, `review.md` is pending human PR review and is automatically generated upon `asdlc approve`).
25
28
 
26
29
  ---
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: asdlc-new
3
- description: "Start a new spec-driven change: derives change slug from natural language requirement, grounds in knowledge graph (explore.md), runs batch-grill-me interview, and drafts initial proposal and spec deltas."
3
+ description: "Start a new spec-driven change: derives change slug from natural language requirement, grounds in knowledge graph (explore.md), runs batch-grill-me interview, and drafts initial proposal, technical design (design.md), and spec deltas."
4
4
  ---
5
5
 
6
6
  # /asdlc:new - Start Feature & Batch-Grill Author
7
7
 
8
- This skill executes **Stage 2 (New)** of the Agentic SDLC. It transforms a natural language requirement into an approved intent change package (`proposal.md`, `specs/**`, `review.md`).
8
+ This skill executes **Stage 2 (New)** of the Agentic SDLC. It transforms a natural language requirement into an approved intent change package (`proposal.md`, `specs/**`, and `design.md`).
9
9
 
10
10
  ---
11
11
 
@@ -15,19 +15,23 @@ This skill executes **Stage 2 (New)** of the Agentic SDLC. It transforms a natur
15
15
  When the user invokes `/asdlc:new "<requirement>"`:
16
16
 
17
17
  ```powershell
18
- asdlc new "<requirement>"
18
+ asdlc new "<requirement>" [--batch-grill] [--no-grill]
19
19
  ```
20
20
 
21
21
  The CLI:
22
22
  1. Derives a clean canonical slug (e.g. `jwt-authentication-payment-api` or content-hashed `change-<id>`).
23
23
  2. Creates `openspec/changes/<SLUG>/`.
24
24
  3. Runs Graphify queries using the extracted requirement terms to discover real codebase AST nodes and call chains.
25
- 4. Generates `explore.md` and seeds `clarifications.md`.
25
+ 4. Generates `explore.md` and seeds `clarifications.md` configured for the chosen grilling mode:
26
+ - **Default (conversational)**: Runs high-signal, recommendation-led `grill-me` (1 material decision at a time).
27
+ - **`--batch-grill`**: Evaluates the entire design tree and presents the active frontier in structured batches.
28
+ - **`--no-grill`**: Bypasses interactive grilling for self-evident fixes and pre-aligned tasks.
29
+ 5. **Technical Design Auto-Detection**: If the requirement touches UI/UX, frontend, APIs, services, databases, or architecture (or if `--design` is passed), seeds `design.md` with enterprise-grade technical design scaffolding.
26
30
 
27
31
  > [!IMPORTANT]
28
32
  > **NO PAUSE / CONTINUOUS EXECUTION**: Do NOT stop after `asdlc new` to ask the author "Should I start grilling?".
29
- > You MUST proceed immediately to Step 2 and Step 3 (**batch-grill-me** interview) in the same turn!
30
- > Only after `clarifications.md` has all questions settled may you draft `proposal.md` and `specs/**`.
33
+ > You MUST proceed immediately to Step 2 and Step 3 in the same turn!
34
+ > Only after `clarifications.md` has all questions settled may you draft `proposal.md`, `design.md`, and `specs/**`.
31
35
 
32
36
  ### Step 2: Ground Yourself in Codebase & External Context (Strict Order)
33
37
  Follow this strict discovery sequence:
@@ -35,21 +39,41 @@ Follow this strict discovery sequence:
35
39
  - Read `openspec/changes/<SLUG>/explore.md`.
36
40
  - Note the **Architectural Hubs (god nodes)** that this change touches.
37
41
  - Review existing functions, types, and exported symbols. Never guess: ground internal assumptions in real paths from `explore.md`.
38
- 2. **Targeted External Search (Secondary & Conditional)**:
39
- - If the requirement references 3rd-party APIs, vendor SDKs, protocols, or external library specs:
40
- Execute a targeted web/doc search for authoritative facts (if `web_search: allow` in `.sdlc/policy.yaml`).
41
- - **Non-blocking failure tolerance**: If external search fails (offline, rate limited, network timeout), **DO NOT BLOCK**. Emit `[WARN] External search failed: <reason>; proceeding with local context`, record unverified assumptions in `clarifications.md`, and proceed immediately.
42
-
43
- ### Step 3: Run the `batch-grill-me` Interview
44
- Before authoring any spec markdown, run the **`batch-grill-me`** protocol:
45
- 1. Evaluate the entire open decision frontier for this feature.
46
- 2. Present all architectural forks and boundary questions in **one structured batch**:
47
- - Number each question (`Q1`, `Q2`, `Q3`...).
48
- - Provide concrete options (A / B / C).
49
- - Supply a fact-backed **Recommended Default** grounded in codebase evidence.
50
- 3. Invite the author to batch-approve (`"Approve all recommendations"`) or provide selective overrides.
42
+ 2. **Policy Guard & Targeted External Search (Enabled by Default)**:
43
+ - **Enterprise Egress Policy Guard**: Check `.sdlc/policy.yaml` before executing any external web or API doc search.
44
+ - **Default is ENABLED (`allow`)**: External web search is enabled by default. If `web_search` is omitted, unspecified, or set to `allow` in `.sdlc/policy.yaml`, search is permitted and encouraged for grounding 3rd-party APIs, vendor SDKs, and specs.
45
+ - **Strict Egress Deny**: Search is blocked **ONLY if `.sdlc/policy.yaml` explicitly sets `web_search: deny`** (for air-gapped / offline enterprise environments).
46
+ In that case, emit:
47
+ `[POLICY] External search disabled by .sdlc/policy.yaml (web_search: deny); proceeding with local context only.`
48
+ Tag any external API assumptions in `clarifications.md` and `design.md` with `[UNVERIFIED: policy_denied]`.
49
+ - **Authoritative Fact Lookup** (when search is allowed / default):
50
+ If the requirement references 3rd-party APIs, vendor SDKs, protocols, or external library specs (e.g. Amap, Weather APIs, Maps, Payment Gateways):
51
+ Execute a targeted web/doc search to look up authoritative endpoints, rate limits, request/response formats, error codes, and caching best practices.
52
+ - **Non-blocking failure tolerance**: If external search fails (offline, rate limited, sandbox network restriction, DNS failure, timeout), **DO NOT BLOCK**.
53
+ Output:
54
+ `[WARN] External search failed or offline: <reason>. Continuing with defined steps.`
55
+ Tag any unverified external API assumptions, endpoints, schemas, or rate limits in `clarifications.md` and `design.md` with `[UNVERIFIED: <reason>]`.
56
+ These will be explicitly surfaced on the PR review by CI/D7 for mandatory human confirmation before merge.
57
+
58
+ ### Step 3: Run the Grilling Phase (Mode-Aware)
59
+ Before authoring any spec markdown, settle all open architectural questions into `clarifications.md`:
60
+
61
+ 1. **If Mode is `interactive` (Default `grill-me`)**:
62
+ - Run conversational, recommendation-led grilling (skill: `grilling`).
63
+ - **Anti-Fatigue Guardrails**:
64
+ - *Codebase-first*: Never ask questions that can be answered by reading the code or AST.
65
+ - *Material forks only*: Ask only about real architectural trade-offs (e.g. storage options, error policies, backwards compatibility); decide implementation micro-details yourself.
66
+ - *Lead with recommendations*: Frame each question with a concrete recommended default and rationale (e.g. "Recommend Option A because... Agree, or prefer Option B?").
67
+ - *Early Exit*: Immediately halt questioning if the author says "proceed", "use defaults", or when open forks hit zero.
68
+
69
+ 2. **If Mode is `batch` (`--batch-grill` passed)**:
70
+ - Run `batch-grill-me` protocol: evaluate the active decision frontier and present all independent trade-offs in one structured numbered batch with recommended options.
71
+ - Author approves all or adjusts specific choices.
72
+
73
+ 3. **If Mode is `none` (`--no-grill` passed)**:
74
+ - Ground assumptions in AST / codebase facts, record context-inferred decisions in `clarifications.md`, leave open questions as none, and proceed directly to Step 4.
75
+
51
76
  4. Record every agreed answer in `openspec/changes/<SLUG>/clarifications.md` under `## Settled decisions`.
52
- 5. If overrides unblock child questions, run Batch Round 2; otherwise close the interview.
53
77
 
54
78
  ### Step 4: Author Approved Intent Artifacts
55
79
  Once `## Open questions` in `clarifications.md` is empty, author the change documents:
@@ -57,18 +81,45 @@ Once `## Open questions` in `clarifications.md` is empty, author the change docu
57
81
  1. **`proposal.md`**:
58
82
  - Sections: `## Why`, `## What Changes`, `## Capabilities`, `## Impact`, `## Out of Scope`, `## Dependencies & Assumptions`.
59
83
  - 1-2 pages maximum. Focus on **WHY**, not code implementation details.
60
- 2. **`specs/<capability>/spec.md`**:
84
+
85
+ 2. **`design.md` (Technical Design Document - Mandatory for UI & Complex Systems)**:
86
+ - When a change touches UI/frontend, external APIs, databases, or services, author `design.md` to define **HOW**:
87
+ - **Architecture & Component Interaction**:
88
+ - Embed clean, self-contained Mermaid flowcharts, sequence diagrams, or state transitions directly in `design.md`. Keep diagrams focused on component boundaries, responsibilities, and request/response lifecycles.
89
+ - **Interface Contracts & Schemas (`api-design` recommended)**:
90
+ - Follow the `api-design` skill for RESTful conventions (plural nouns, kebab-case, hierarchical nesting, zero verbs in URLs).
91
+ - Specify exact TypeScript interfaces or JSON schemas for request/response payloads.
92
+ - Standardize on structured error envelopes (Stripe-style `{ error: { code, message, details } }` or RFC 7807 problem details `{ type, title, status, detail, instance }`). Never return `200 OK` with an error body.
93
+ - Define explicit pagination strategy: cursor-based (`cursor`, `limit`, `has_more`) or offset-based.
94
+ - **External API Integration & Resilience**:
95
+ - Endpoints, authentication, rate limits (`X-RateLimit-*`), client-level in-memory/TTL caching (never recreate clients per request).
96
+ - Mutating endpoints must specify `Idempotency-Key` header with deduplication cache.
97
+ - Error taxonomy, fallback degradation, and exponential backoff retry with jitter.
98
+ - **Security & Operational NFRs (Optional / When Applicable)**: Document authentication, boundary validation, secret lifecycles, and performance budgets/quotas when the architecture demands them.
99
+ - **UI/UX Design Specifications (`frontend-design` & Vercel Guidelines)**:
100
+ - **Anti-AI Slop Mandate**: Zero tolerance for cliché glowing cards, arbitrary gradient text highlights, uniform pill buttons, or monotonous card grids.
101
+ - **Design Direction & Subject Grounding**: Real subject matter, vernacular, and domain tone (e.g., high-density analytical dashboard vs consumer app). Link to mockup, brand tokens, or benchmark URL.
102
+ - **Concrete Palettes & Typography**: 4–6 deliberate Hex color tokens (`--color-primary`, `--color-background`, `--color-surface`, etc.) and distinct font pairings (heading + body) with WCAG AA/AAA contrast.
103
+ - **Hero Treatment & Layout**: Opening hero element, responsive breakpoints (Mobile <= 640px, Tablet 641-1024px, Desktop > 1024px).
104
+ - **5 Mandatory States**: Default, Hover/Focus (150-200ms ease, `:focus-visible`), Loading Skeleton (never blank screens), Empty State with prompt, Error Banner with retry.
105
+
106
+ 3. **`specs/<capability>/spec.md`**:
61
107
  - `## Purpose`: Clear capability statement (50+ chars).
62
108
  - `## ADDED Requirements`:
63
109
  - Every requirement: `### Requirement: <name>` using **SHALL** or **MUST**.
64
110
  - Every requirement has `#### Scenario: <name>` with **GIVEN / WHEN / THEN**.
65
111
  - Every requirement has an `**Acceptance criteria**` block:
66
112
  `- [ ] AC1: <concrete testable assertion> (test: <path/to/test>)`
113
+ - **UI Testability**: For any UI capability, include visual Acceptance Criteria for responsive breakpoints and key interaction states (empty, loading, error), mapped to component/E2E test targets (e.g. Playwright / snapshot tests).
67
114
  - `## Constraints & NFRs`: Verifiable performance/security statements.
68
115
  - `## Out of Scope` and `## Test Strategy`.
69
- 3. **`review.md`**:
70
- - Run an independent review pass and stamp `## Verdict: APPROVE`.
116
+
117
+ 4. **Review Provenance (Player $\ne$ Referee)**:
118
+ - The authoring agent MUST NOT approve its own spec.
119
+ - Do NOT stamp `review.md` with self-approval.
120
+ - Independent AI review (`asdlc:spec-review`) is executed automatically on the Spec PR by CI.
121
+ - Formal approval is given by the human lead via PR merge or `asdlc approve <SLUG>`.
71
122
 
72
123
  ### Step 5: Transition to Lint
73
124
  Once artifacts are written, guide the developer:
74
- > "Artifacts drafted! Now run `/asdlc:lint <SLUG>` to verify BDD scenarios and acceptance criteria before opening the spec PR."
125
+ > "Artifacts drafted! Now run `/asdlc:lint <SLUG>` to verify BDD scenarios, technical design, and acceptance criteria before opening the spec PR."
@@ -106,6 +106,13 @@ Evaluate every requirement in the diff against all six dimensions. Mark each `PA
106
106
  - Is user-supplied input validated before use?
107
107
  - If the change stores user data, is PII lifecycle (retention, deletion) documented?
108
108
 
109
+ #### D7 — Technical Design & UI/API Soundness
110
+ - **Design Ground Truth**: When UI is involved, does `design.md` cite an authoritative ground truth reference (mockup, Figma URL, design system URL, or existing brand CSS)? Flag as **Major** if tokens appear hallucinated without reference or justification.
111
+ - **Visual Testability**: When UI is involved, does the spec contain Visual Acceptance Criteria covering responsive breakpoints (mobile, tablet, desktop) and interaction states (loading, empty, error, active), mapped to test files (e.g. Playwright / visual snapshot tests)? Flag as **Blocker** if UI specs lack visual ACs or test mappings.
112
+ - **Unverified Assumptions**: Are there any `[UNVERIFIED: <reason>]` tags present in `clarifications.md`, `design.md`, or the specs? D7 MUST extract every `[UNVERIFIED]` tag. If an AC depends on an unverified endpoint, quota, or rate limit without a verified fallback, flag as **Major** and require explicit human TL sign-off.
113
+ - **API & Client Lifecycle**: When 3rd-party/external APIs are integrated, does the technical design enforce client reuse (singleton / connection pooling, never recreate per request), in-memory TTL caching for geocoding/lookup endpoints, rate-limit awareness, and degraded fallbacks? Flag as **Blocker** if clients are instantiated per request or lack caching/retry policies.
114
+ - **Interface & DTO Contracts**: Are request/response schemas, DTOs, and domain models rigorously typed (e.g. TypeScript interfaces) with validation boundaries?
115
+
109
116
  ---
110
117
 
111
118
  ### Step 3: Build the Requirement → AC → Test Traceability Matrix
@@ -118,8 +125,8 @@ For each `### Requirement:` found in the diff, produce one row covering all its
118
125
 
119
126
  Classify each finding:
120
127
 
121
- - **🔴 Blocker** — Contradictory ACs, untestable assertion, missing normative language, security risk. Blocks `asdlc approve`.
122
- - **🟡 Major** — Ambiguous scenario, unhandled edge case, missing degradation path. Should be resolved before approval.
128
+ - **🔴 Blocker** — Contradictory ACs, untestable assertion, missing normative language, missing visual ACs for UI, missing singleton/caching for external APIs, security risk. Blocks `asdlc approve`.
129
+ - **🟡 Major** — Ambiguous scenario, unhandled edge case, unverified assumption on external API (`[UNVERIFIED]`), missing design ground truth reference. Should be resolved or acknowledged before approval.
123
130
  - **🟢 Advisory** — Clarity or style improvements. Does not block.
124
131
 
125
132
  ---
@@ -153,6 +160,7 @@ Format the comment body strictly as:
153
160
  | D4 Contract impact | ✅ / ⚠️ / ❌ | <one-line summary> |
154
161
  | D5 Testability | ✅ / ⚠️ / ❌ | <one-line summary> |
155
162
  | D6 Security & Privacy | ✅ / ⚠️ / ❌ | <one-line summary> |
163
+ | D7 Technical Design & UI/API Soundness | ✅ / ⚠️ / ❌ | <one-line summary> |
156
164
 
157
165
  ### Requirement → AC → Test Traceability
158
166
 
@@ -160,6 +168,10 @@ Format the comment body strictly as:
160
168
  | :--- | :--- | :--- | :--- |
161
169
  | <Requirement name> | AC1, AC2 | test/<feature>.test.ts | ✅ VERIFIED |
162
170
 
171
+ ### ⚠️ Unverified Assumptions Requiring TL Acknowledgment
172
+ <!-- List any [UNVERIFIED: ...] tags found across clarifications.md, design.md, and specs. Omit section if none. -->
173
+ - `[UNVERIFIED: <reason>]` — <context / affected requirement>
174
+
163
175
  ### 🔴 Blocking Findings
164
176
  <!-- Omit section if none -->
165
177
  1. **[Blocker]** `<Requirement: Name>` — AC<n>: <description of contradiction or missing assertion>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: batch-grill-me
3
- description: "A relentless design-tree interview that asks every frontier question at once, round by round, with recommended defaults and non-blocking fact discovery."
3
+ description: "A relentless design-tree interview that evaluates the active frontier and asks questions in structured batches with recommended defaults and non-blocking fact discovery. Invoked via asdlc new --batch-grill or /batch-grill-me."
4
4
  aliases:
5
5
  - grilling
6
6
  - grill-me
@@ -8,7 +8,7 @@ aliases:
8
8
 
9
9
  # Batch Grilling — Relentless Design-Tree Interview (`batch-grill-me`)
10
10
 
11
- This skill drives the **Grilling phase** (Stage 2) of the Agentic SDLC. It operates between `asdlc new "<requirement>"` and spec authoring (`proposal.md` / `specs/**`). It can also be invoked standalone via `/batch-grill-me` or `/grill-me` for any architectural design.
11
+ This skill drives the **Grilling phase** (Stage 2) of the Agentic SDLC when invoked in batch mode (via `asdlc new "<requirement>" --batch-grill` or `/batch-grill-me`). For interactive 1-by-1 dialogue, use `/grill-me`.
12
12
 
13
13
  Interview the author relentlessly until you reach a shared understanding. Map the requirement as a **design tree**: every decision branches into the decisions that hang off it.
14
14
 
@@ -24,11 +24,16 @@ Interview the author relentlessly until you reach a shared understanding. Map th
24
24
 
25
25
  - Never ask child or grandchild questions whose parent decision is still open in the current round.
26
26
  - If Question C1 asks *"Should we support internationalization (en + zh)?"*, you **CANNOT** ask *"Which fields should be translated?"* or *"What format should the message catalog use?"* in the same round! Those depend on C1 being answered.
27
- - Asking child questions prematurely forces you to guess at parent answers, which leads directly to pseudo-questions and fake choices. Hold them for Round 2.
27
+ - Asking child questions prematurely forces you to guess at parent answers, which leads directly to pseudo-questions and fake choices. Hold them for later rounds.
28
28
 
29
29
  3. **Dynamic Tree Reshaping.**
30
30
  Each round the author answers reshapes the tree — settled decisions push the frontier outward and unblock questions that depended on them. Recompute the frontier and ask the next round.
31
31
 
32
+ 4. **Early Exit / Fast-Forward Protocol**:
33
+ If the author says:
34
+ - *"Approve all recommendations"* / *"Proceed with defaults"* / *"LGTM"*
35
+ The agent must **immediately halt questioning**, resolve any remaining open decisions using its stated engineering recommendations, write them into `clarifications.md`, and proceed directly to drafting `proposal.md` and `specs/**`.
36
+
32
37
  ---
33
38
 
34
39
  ## 2. Fact-Finding vs. Human Decisions
@@ -113,7 +118,7 @@ Active Frontier: <N> independent decisions ready for resolution.
113
118
 
114
119
  ---
115
120
 
116
- 💡 *To proceed efficiently, reply **"Approve all recommendations"**, or specify adjustments (e.g. `Q1: B, Q2: accept`).*
121
+ 💡 *To proceed efficiently, reply **"Approve all recommendations"**, specify adjustments (e.g. `Q1: B, Q2: accept`), or type "proceed with defaults".*
117
122
  ```
118
123
 
119
124
  ---
@@ -123,8 +128,7 @@ Active Frontier: <N> independent decisions ready for resolution.
123
128
  The session is done when the **frontier is empty**:
124
129
  1. Every branch of the design tree has been visited.
125
130
  2. Nothing is left silently assumed.
126
- 3. **Do not act until the author confirms you have reached a shared understanding** (e.g. by approving recommendations or answering all questions).
127
- 4. Record all settled decisions in `openspec/changes/<SLUG>/clarifications.md`:
131
+ 3. Record all settled decisions in `openspec/changes/<SLUG>/clarifications.md`:
128
132
  ```markdown
129
133
  ## Settled decisions
130
134
 
@@ -133,4 +137,4 @@ The session is done when the **frontier is empty**:
133
137
  - **<Decision 2 Title>**: <Chosen Option>
134
138
  - *Rationale*: <Why this was chosen>
135
139
  ```
136
- 5. Only after `clarifications.md` is settled may you transition to authoring `proposal.md` and `specs/**`.
140
+ 4. Only after `clarifications.md` is settled may you transition to authoring `proposal.md` and `specs/**`.