cclaw-cli 0.51.23 → 0.51.24

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.
@@ -23,7 +23,7 @@ export interface AgentDefinition {
23
23
  body: string;
24
24
  }
25
25
  /**
26
- * Canonical specialist roster (core-5) materialized under `.cclaw/agents/`.
26
+ * Canonical specialist roster materialized under `.cclaw/agents/`.
27
27
  *
28
28
  * Declared with `satisfies` so the array retains literal `name` types for
29
29
  * downstream type-level consumers (e.g. `AgentName`), while still being
@@ -39,6 +39,22 @@ export declare const CCLAW_AGENTS: readonly [{
39
39
  readonly activation: "mandatory";
40
40
  readonly relatedStages: ["brainstorm", "scope", "design", "spec", "plan"];
41
41
  readonly body: string;
42
+ }, {
43
+ readonly name: "product-manager";
44
+ readonly description: "PROACTIVE during brainstorm/scope when product value, persona/JTBD, success metric, or why-now framing is unclear. Use for product discovery, not implementation.";
45
+ readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
46
+ readonly model: "balanced";
47
+ readonly activation: "proactive";
48
+ readonly relatedStages: ["brainstorm", "scope"];
49
+ readonly body: string;
50
+ }, {
51
+ readonly name: "critic";
52
+ readonly description: "PROACTIVE during brainstorm/scope/design when premises, alternatives, cost, rollback, or hidden assumptions need adversarial pressure.";
53
+ readonly tools: ["Read", "Grep", "Glob", "WebSearch"];
54
+ readonly model: "balanced";
55
+ readonly activation: "proactive";
56
+ readonly relatedStages: ["brainstorm", "scope", "design"];
57
+ readonly body: string;
42
58
  }, {
43
59
  readonly name: "reviewer";
44
60
  readonly description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.";
@@ -87,7 +103,7 @@ export declare function agentMarkdown(agent: AgentDefinition): string;
87
103
  */
88
104
  export declare function agentRoutingTable(): string;
89
105
  /**
90
- * Cost tier routing for the core-5 agent roster.
106
+ * Cost tier routing for the specialist agent roster.
91
107
  */
92
108
  export declare function agentCostTierTable(): string;
93
109
  /**
@@ -39,7 +39,7 @@ function activationModeSummary() {
39
39
  };
40
40
  }
41
41
  /**
42
- * Canonical specialist roster (core-5) materialized under `.cclaw/agents/`.
42
+ * Canonical specialist roster materialized under `.cclaw/agents/`.
43
43
  *
44
44
  * Declared with `satisfies` so the array retains literal `name` types for
45
45
  * downstream type-level consumers (e.g. `AgentName`), while still being
@@ -59,14 +59,56 @@ export const CCLAW_AGENTS = [
59
59
  "You are an **implementation planning specialist** (staff engineer mindset).",
60
60
  "",
61
61
  "When invoked:",
62
- "1. Analyze scope and break it into concrete sub-problems.",
63
- "2. Map each sub-problem to existing modules and reusable code.",
64
- "3. Produce an ordered execution plan with dependencies and checks.",
65
- "4. Highlight risks and unknowns that need user decisions.",
62
+ "1. Map upstream decisions, scope boundaries, and explicit drift before planning.",
63
+ "2. Break the work into concrete sub-problems with dependencies and existing-module fit.",
64
+ "3. Enforce one-question discipline: ask only decision-changing questions, one at a time.",
65
+ "4. Produce an ordered execution plan with verification checks and handoff quality notes.",
66
+ "5. Highlight risks and unknowns that need user decisions.",
66
67
  "",
67
68
  "**Role boundary:** planning only. Do NOT write production code."
68
69
  ].join("\n")
69
70
  },
71
+ {
72
+ name: "product-manager",
73
+ description: "PROACTIVE during brainstorm/scope when product value, persona/JTBD, success metric, or why-now framing is unclear. Use for product discovery, not implementation.",
74
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
75
+ model: "balanced",
76
+ activation: "proactive",
77
+ relatedStages: ["brainstorm", "scope"],
78
+ body: [
79
+ "You are a **product discovery specialist**.",
80
+ "",
81
+ "Produce concise evidence for:",
82
+ "- persona / user and job to be done",
83
+ "- pain or trigger",
84
+ "- value hypothesis and success metric",
85
+ "- evidence or signal strength",
86
+ "- why now, do-nothing consequence, and non-goals",
87
+ "",
88
+ "For technical-maintenance work, translate this to operator/developer, failure mode, operational improvement, verification signal, do-nothing cost, and non-goals.",
89
+ "",
90
+ "**Role boundary:** frame value and problem fit. Do NOT choose implementation architecture."
91
+ ].join("\n")
92
+ },
93
+ {
94
+ name: "critic",
95
+ description: "PROACTIVE during brainstorm/scope/design when premises, alternatives, cost, rollback, or hidden assumptions need adversarial pressure.",
96
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
97
+ model: "balanced",
98
+ activation: "proactive",
99
+ relatedStages: ["brainstorm", "scope", "design"],
100
+ body: [
101
+ "You are an **adversarial critic** for product and engineering decisions.",
102
+ "",
103
+ "Your job:",
104
+ "1. Attack the premise and name what could make the current direction wrong.",
105
+ "2. Identify cheaper, smaller, or more reversible alternatives.",
106
+ "3. Surface hidden assumptions, do-nothing viability, and scope creep.",
107
+ "4. In design, require a shadow alternative, switch trigger, failure/rescue path, and verification evidence.",
108
+ "",
109
+ "Return confirmed risks, disproven concerns, and the smallest decision-changing recommendation."
110
+ ].join("\n")
111
+ },
70
112
  {
71
113
  name: "reviewer",
72
114
  description: "MANDATORY during review. MUST BE USED to run a two-pass audit: spec compliance first, then correctness/maintainability/performance/architecture.",
@@ -91,9 +133,11 @@ export const CCLAW_AGENTS = [
91
133
  "",
92
134
  "For each finding include:",
93
135
  "- Severity: `Critical` | `Important` | `Suggestion`",
94
- "- Location: `file:line`",
136
+ "- Location: `file:line`; if no line is possible, state the no-line reason",
95
137
  "- Problem and concrete recommendation",
96
138
  "",
139
+ "Also report files inspected, changed-file coverage, diagnostics run, dependency/version audit when relevant, and a no-finding attestation when no issues are found.",
140
+ "",
97
141
  "**Trust model:** never rely on implementer claims; verify by reading code."
98
142
  ].join("\n")
99
143
  },
@@ -118,7 +162,8 @@ export const CCLAW_AGENTS = [
118
162
  "- severity aligned to ship risk",
119
163
  "- CWE ID when possible (or UNKNOWN)",
120
164
  "- short proof-of-concept vector",
121
- "- concrete control-oriented fix"
165
+ "- concrete control-oriented fix",
166
+ "- `NO_CHANGE_ATTESTATION` or `NO_SECURITY_IMPACT` with inspected surfaces when no security finding exists"
122
167
  ].join("\n")
123
168
  },
124
169
  {
@@ -131,7 +176,7 @@ export const CCLAW_AGENTS = [
131
176
  body: [
132
177
  "You are a **test-driven development** specialist.",
133
178
  "",
134
- "**Iron law:** no production code without a failing test first.",
179
+ "**Iron law:** no production code without a failing test first during RED. In design, focus on testability and verification evidence without editing production code.",
135
180
  "",
136
181
  "Process:",
137
182
  "1. RED: write a failing test for the desired behavior.",
@@ -154,7 +199,8 @@ export const CCLAW_AGENTS = [
154
199
  "After code changes, verify and update only stale sections in:",
155
200
  "- README / setup / usage",
156
201
  "- API docs and examples",
157
- "- migration and operational notes",
202
+ "- migration, rollout, rollback, and operational notes",
203
+ "- public-surface change notes tied to actual changed files",
158
204
  "",
159
205
  "Preserve existing tone and structure; avoid rewrites for style alone."
160
206
  ].join("\n")
@@ -221,13 +267,13 @@ export function agentRoutingTable() {
221
267
  `;
222
268
  }
223
269
  /**
224
- * Cost tier routing for the core-5 agent roster.
270
+ * Cost tier routing for the specialist agent roster.
225
271
  */
226
272
  export function agentCostTierTable() {
227
273
  return `| Tier | Use for | Example agents |
228
274
  |---|---|---|
229
275
  | \`deep\` | one heavy planning pass per stage | planner |
230
- | \`balanced\` | review and TDD specialists with stronger reasoning depth | reviewer, security-reviewer, test-author |
276
+ | \`balanced\` | discovery, criticism, review, and TDD specialists with stronger reasoning depth | product-manager, critic, reviewer, security-reviewer, test-author |
231
277
  | \`fast\` | bounded maintenance updates with limited blast radius | doc-updater |
232
278
  `;
233
279
  }
@@ -237,7 +283,7 @@ export function agentCostTierTable() {
237
283
  export function agentsAgentsMdBlock() {
238
284
  return `### Agent Specialists
239
285
 
240
- cclaw materializes **5 core specialist agents** under \`.cclaw/agents/\`.
286
+ cclaw materializes specialist agents under \`.cclaw/agents/\`, including planner, product-manager, critic, reviewer, security-reviewer, test-author, and doc-updater.
241
287
 
242
288
  ${agentRoutingTable()}
243
289
 
@@ -257,7 +303,7 @@ ${(() => {
257
303
  const mode = activationModeSummary();
258
304
  return `- **Mandatory:** ${mode.mandatory}.
259
305
  - **Proactive:** ${mode.proactive}.
260
- - **On-demand:** none in the core-5 roster; research playbooks are in-thread procedures.`;
306
+ - **On-demand:** none in the specialist roster; research playbooks are in-thread procedures.`;
261
307
  })()}
262
308
 
263
309
  ### Cost-aware routing
@@ -4,11 +4,19 @@ const STAGE_EXAMPLES = {
4
4
  - **Project state:** Monorepo with CI pipeline using custom release scripts. Release checks are scattered across shell scripts with no shared validation logic.
5
5
  - **Relevant existing code/patterns:** \`scripts/pre-publish.sh\` does metadata checks. \`src/release/\` has partial validation helpers.
6
6
 
7
- ## Problem
7
+ ## Problem Decision Record
8
8
 
9
- - **What we're solving:** release checks are fragile and inconsistent between CI and local runs. Invalid metadata sometimes reaches npm publish.
10
- - **Success criteria:** invalid release preconditions are caught before publish with explicit operator feedback, in both CI and local workflows.
11
- - **Constraints:** no new runtime dependencies; must work within existing CI pipeline structure.
9
+ - **Depth:** standard
10
+ - **Frame type:** technical-maintenance
11
+
12
+ ### Technical-maintenance framing
13
+
14
+ - **Affected operator/developer:** release operator and package maintainer.
15
+ - **Current failure mode:** release checks are fragile and inconsistent between CI and local runs; invalid metadata sometimes reaches npm publish.
16
+ - **Expected operational improvement:** invalid release preconditions are caught before publish with explicit operator feedback in CI and local workflows.
17
+ - **Verification signal:** shared release validation tests and CI release-check command fail on invalid metadata.
18
+ - **Do-nothing cost:** continued publish risk and duplicated local/CI fixes.
19
+ - **Non-goals:** no new runtime dependencies; no release-framework rewrite.
12
20
 
13
21
  ## Clarifying Questions
14
22
 
@@ -667,7 +675,7 @@ function exampleSummaryBullets(stage) {
667
675
  // sample in STAGE_EXAMPLES gains or loses a top-level section.
668
676
  const STAGE_EXAMPLE_SECTION_HEADINGS = {
669
677
  brainstorm: [
670
- "Problem framing (problem, success, constraints)",
678
+ "Problem Decision Record (product or technical-maintenance framing)",
671
679
  "Candidate approaches with trade-offs",
672
680
  "Recommended direction + open questions",
673
681
  "Clarification log and decision record"
@@ -4,6 +4,8 @@ import { parse } from "yaml";
4
4
  import { RUNTIME_ROOT } from "../constants.js";
5
5
  const SEED_FILE_NAME_PATTERN = /^SEED-(\d{4}-\d{2}-\d{2})-([a-z0-9]+(?:-[a-z0-9]+)*)(?:-(\d+))?\.md$/u;
6
6
  const DEFAULT_MAX_MATCHES = 3;
7
+ const MAX_SEED_MATCHES = 10;
8
+ const MIN_TOKEN_OVERLAP = 2;
7
9
  function isRecord(value) {
8
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
9
11
  }
@@ -189,18 +191,81 @@ export async function readSeedShelf(projectRoot) {
189
191
  entries.sort((a, b) => b.fileName.localeCompare(a.fileName));
190
192
  return entries;
191
193
  }
192
- export function seedMatchesPrompt(seed, prompt) {
193
- const normalizedPrompt = prompt.toLowerCase().trim();
194
- if (normalizedPrompt.length === 0)
195
- return false;
196
- if (seed.triggerWhen.length === 0)
194
+ function normalizeMatchText(value) {
195
+ return value.toLowerCase().trim().replace(/\s+/gu, " ");
196
+ }
197
+ function tokenizeSeedText(value) {
198
+ if (!value)
199
+ return [];
200
+ return value
201
+ .toLowerCase()
202
+ .split(/[^a-z0-9]+/u)
203
+ .map((token) => token.trim())
204
+ .filter((token) => token.length >= 3);
205
+ }
206
+ function uniqueTokens(values) {
207
+ return new Set(values);
208
+ }
209
+ function exactTriggerMatch(seed, normalizedPrompt) {
210
+ if (normalizedPrompt.length === 0 || seed.triggerWhen.length === 0)
197
211
  return false;
198
- return seed.triggerWhen.some((trigger) => normalizedPrompt.includes(trigger.toLowerCase()));
212
+ return seed.triggerWhen.some((trigger) => {
213
+ const normalizedTrigger = normalizeMatchText(trigger);
214
+ return normalizedTrigger.length > 0 && normalizedPrompt.includes(normalizedTrigger);
215
+ });
216
+ }
217
+ function seedContentTokens(seed) {
218
+ return uniqueTokens([
219
+ ...tokenizeSeedText(seed.title),
220
+ ...tokenizeSeedText(seed.summary),
221
+ ...tokenizeSeedText(seed.hypothesis),
222
+ ...tokenizeSeedText(seed.action)
223
+ ]);
224
+ }
225
+ function tokenOverlap(seed, promptTokens) {
226
+ if (promptTokens.size === 0)
227
+ return 0;
228
+ const contentTokens = seedContentTokens(seed);
229
+ let overlap = 0;
230
+ for (const token of promptTokens) {
231
+ if (contentTokens.has(token))
232
+ overlap += 1;
233
+ }
234
+ return overlap;
235
+ }
236
+ export function seedMatchesPrompt(seed, prompt) {
237
+ const normalizedPrompt = normalizeMatchText(prompt);
238
+ if (exactTriggerMatch(seed, normalizedPrompt))
239
+ return true;
240
+ return tokenOverlap(seed, uniqueTokens(tokenizeSeedText(prompt))) >= MIN_TOKEN_OVERLAP;
199
241
  }
200
242
  export async function findMatchingSeeds(projectRoot, prompt, maxMatches = DEFAULT_MAX_MATCHES) {
201
243
  const seeds = await readSeedShelf(projectRoot);
202
- const matches = seeds.filter((seed) => seedMatchesPrompt(seed, prompt));
203
- return matches.slice(0, Math.max(1, maxMatches));
244
+ const normalizedPrompt = normalizeMatchText(prompt);
245
+ if (normalizedPrompt.length === 0)
246
+ return [];
247
+ const promptTokens = uniqueTokens(tokenizeSeedText(prompt));
248
+ const cappedMax = typeof maxMatches === "number" && Number.isFinite(maxMatches) && maxMatches > 0
249
+ ? Math.min(MAX_SEED_MATCHES, Math.max(1, Math.floor(maxMatches)))
250
+ : DEFAULT_MAX_MATCHES;
251
+ const ranked = seeds
252
+ .map((seed, index) => {
253
+ const exact = exactTriggerMatch(seed, normalizedPrompt);
254
+ const overlap = tokenOverlap(seed, promptTokens);
255
+ return { seed, index, exact, overlap };
256
+ })
257
+ .filter((row) => row.exact || row.overlap >= MIN_TOKEN_OVERLAP);
258
+ ranked.sort((a, b) => {
259
+ if (a.exact !== b.exact)
260
+ return a.exact ? -1 : 1;
261
+ if (b.overlap !== a.overlap)
262
+ return b.overlap - a.overlap;
263
+ const recency = b.seed.createdOn.localeCompare(a.seed.createdOn);
264
+ if (recency !== 0)
265
+ return recency;
266
+ return a.index - b.index;
267
+ });
268
+ return ranked.slice(0, cappedMax).map((row) => row.seed);
204
269
  }
205
270
  export function renderSeedTemplate(input) {
206
271
  const triggerWhen = [...input.triggerWhen].map((item) => item.trim()).filter((item) => item.length > 0);
@@ -242,27 +242,29 @@ const REQUIRED_GATE_IDS = {
242
242
  const REQUIRED_ARTIFACT_SECTIONS = {
243
243
  brainstorm: [
244
244
  "Context",
245
- "Problem",
245
+ "Problem Decision Record",
246
246
  "Approach Tier",
247
247
  "Approaches",
248
248
  "Approach Reaction",
249
249
  "Selected Direction"
250
250
  ],
251
- scope: ["Scope Mode", "In Scope / Out of Scope", "Completion Dashboard", "Scope Summary"],
251
+ scope: ["Scope Contract", "Scope Mode", "In Scope / Out of Scope", "Completion Dashboard", "Scope Summary"],
252
252
  design: [
253
253
  "Research Fleet Synthesis",
254
+ "Engineering Lock",
254
255
  "Architecture Boundaries",
255
256
  "Architecture Diagram",
256
257
  "Failure Mode Table",
257
258
  "Security & Threat Model",
258
259
  "Observability & Debuggability",
259
260
  "Deployment & Rollout",
261
+ "Spec Handoff",
260
262
  "Completion Dashboard"
261
263
  ],
262
264
  spec: ["Acceptance Criteria", "Edge Cases", "Assumptions Before Finalization", "Acceptance Mapping", "Approval"],
263
265
  plan: ["Task List", "Dependency Batches", "Acceptance Mapping", "Execution Posture", "WAIT_FOR_CONFIRM"],
264
266
  tdd: ["Test Discovery", "System-Wide Impact Check", "RED Evidence", "GREEN Evidence", "REFACTOR Notes", "Traceability", "Verification Ladder"],
265
- review: ["Layer 1 Verdict", "Review Findings Contract", "Severity Summary", "Final Verdict"],
267
+ review: ["Review Evidence Scope", "Changed-File Coverage", "Layer 1 Verdict", "Review Findings Contract", "Severity Summary", "Final Verdict"],
266
268
  ship: ["Preflight Results", "Release Notes", "Rollback Plan", "Finalization"]
267
269
  };
268
270
  function resolveRequiredGateIds(stage, track) {
@@ -357,10 +359,24 @@ const STAGE_SCHEMA_MAP = {
357
359
  };
358
360
  const STAGE_AUTO_SUBAGENT_DISPATCH = {
359
361
  brainstorm: [
362
+ {
363
+ agent: "product-manager",
364
+ mode: "proactive",
365
+ when: "When product value, persona/JTBD, success metric, or why-now framing is ambiguous.",
366
+ purpose: "Pressure-test problem/value fit and produce product-discovery evidence for the Problem Decision Record.",
367
+ requiresUserGate: false
368
+ },
369
+ {
370
+ agent: "critic",
371
+ mode: "proactive",
372
+ when: "When the premise may be wrong, cheaper alternatives exist, or the do-nothing path could be acceptable.",
373
+ purpose: "Attack assumptions and surface non-goals before direction approval.",
374
+ requiresUserGate: false
375
+ },
360
376
  {
361
377
  agent: "planner",
362
378
  mode: "proactive",
363
- when: "When request is ambiguous, multi-surface, or spans multiple modules.",
379
+ when: "When request is ambiguous, multi-surface, or staged feasibility is unclear.",
364
380
  purpose: "Map scope and alternatives before direction lock.",
365
381
  requiresUserGate: false
366
382
  }
@@ -373,6 +389,20 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
373
389
  when: "Always during scope shaping.",
374
390
  purpose: "Challenge premise, map alternatives, and produce explicit in/out contract.",
375
391
  requiresUserGate: false
392
+ },
393
+ {
394
+ agent: "critic",
395
+ mode: "proactive",
396
+ when: "When selecting SELECTIVE EXPANSION, SCOPE EXPANSION, or SCOPE REDUCTION, or when boundaries feel soft.",
397
+ purpose: "Test whether the selected scope mode is too timid, too broad, or hiding a smaller useful slice.",
398
+ requiresUserGate: false
399
+ },
400
+ {
401
+ agent: "product-manager",
402
+ mode: "proactive",
403
+ when: "When scope choices change user value, success metrics, or product positioning.",
404
+ purpose: "Keep accepted/deferred reference ideas tied to user value and measurable success.",
405
+ requiresUserGate: false
376
406
  }
377
407
  ],
378
408
  design: [
@@ -381,15 +411,29 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
381
411
  mode: "mandatory",
382
412
  requiredAtTier: "standard",
383
413
  when: "Always during design lock.",
384
- purpose: "Stress architecture boundaries and dependency graph.",
414
+ purpose: "Stress architecture boundaries, dependency graph, critical path, and spec handoff.",
415
+ requiresUserGate: false
416
+ },
417
+ {
418
+ agent: "critic",
419
+ mode: "proactive",
420
+ when: "When architecture alternatives, coupling, cost, or rollback risk remain debatable.",
421
+ purpose: "Produce a shadow alternative, switch trigger, and cheaper-path challenge for the engineering lock.",
385
422
  requiresUserGate: false
386
423
  },
387
424
  {
388
425
  agent: "security-reviewer",
389
426
  mode: "proactive",
390
- when: "When trust boundaries, auth, secrets, or external inputs are involved.",
427
+ when: "When trust boundaries, auth, secrets, sensitive data, or external inputs are involved.",
391
428
  purpose: "Catch design-level security risks before implementation.",
392
429
  requiresUserGate: false
430
+ },
431
+ {
432
+ agent: "test-author",
433
+ mode: "proactive",
434
+ when: "When testability, failure/rescue behavior, or verification evidence is unclear.",
435
+ purpose: "Check that the design can produce concrete RED/GREEN/REFACTOR and rollout verification evidence.",
436
+ requiresUserGate: false
393
437
  }
394
438
  ],
395
439
  spec: [
@@ -7,11 +7,11 @@ export const BRAINSTORM = {
7
7
  complexityTier: "standard",
8
8
  skillFolder: "brainstorming",
9
9
  skillName: "brainstorming",
10
- skillDescription: "Design-first stage. Explore context, understand intent through collaborative dialogue, propose distinct approaches, and lock an approved direction before scope/design work.",
10
+ skillDescription: "Problem-discovery stage. Build a concise Problem Decision Record, choose lite/standard/deep depth, compare distinct directions, and hand approved decisions to scope.",
11
11
  philosophy: {
12
12
  hardGate: "Do NOT invoke implementation skills, write code, scaffold projects, or mutate product behavior until a concrete direction is approved by the user.",
13
13
  ironLaw: "NO ARTIFACT IS COMPLETE WITHOUT AN EXPLICITLY APPROVED DIRECTION — SILENCE IS NOT APPROVAL.",
14
- purpose: "Turn an initial idea into an approved design direction through natural collaborative dialogue understanding the problem before proposing solutions.",
14
+ purpose: "Turn an initial idea into an approved problem frame and direction, using product or technical-maintenance discovery before proposing solutions.",
15
15
  whenToUse: [
16
16
  "Starting a new feature or behavior change",
17
17
  "Requirements are ambiguous or trade-offs are unclear",
@@ -37,22 +37,24 @@ export const BRAINSTORM = {
37
37
  executionModel: {
38
38
  checklist: [
39
39
  "**Explore project context** — inspect existing files/docs/recent activity before asking what to build; capture matching files/patterns/seeds in `Context > Discovered context` so downstream stages don't redo discovery.",
40
- "**Classify depth and scope** — pick Lightweight / Standard / Deep; decompose independent subsystems before deeper work.",
40
+ "**Classify stage depth** — choose `lite` for clear low-risk tasks, `standard` for normal product/engineering changes, or `deep` for ambiguity, architecture, external dependency, security/data risk, or explicit think-bigger requests.",
41
+ "**Write the Problem Decision Record** — product work captures persona/JTBD/pain/value/evidence/success/why-now/do-nothing/non-goals; technical-maintenance work captures affected operator/developer, failure mode, operational improvement, verification signal, do-nothing cost, and non-goals.",
41
42
  "**Premise check (one pass)** — answer the three gstack-style questions in the artifact body: *Right problem? Direct path? What if we do nothing?* Take a position; do not hedge.",
42
- "**Reframe with How Might We** — write a single `How Might We …?` line that names the user, the desired outcome, and the constraint. This is the altitude check before approaches.",
43
- "**Sharpening questions (3-5)** — capture decision-changing question/answer pairs in the `Sharpening Questions` table with the actual decision impact; only non-critical preference/default assumptions may continue. STOP and ask on scope, architecture, security, data loss, public API, migration, auth/pricing, or user-approval uncertainty.",
43
+ "**Reframe with How Might We** — write a single `How Might We …?` line that names the user/operator, the desired outcome, and the constraint. This is the altitude check before approaches.",
44
+ "**Sharpening question discipline** — ask one decision-changing question at a time. Do not default to 3-5 batched questions; record only questions that changed the direction or a critical stop decision.",
44
45
  "**Use compact discovery for simple apps** — for concrete low-risk asks (todo app, landing page, local widget), do one context pass, compare one baseline and one challenger, then ask for one explicit approval; do not drag the user through a full workshop.",
45
- "**Short-circuit concrete asks** — for unambiguous implementation-only requests, write a compact brainstorm stub (context, problem, approved intent, constraints, assumptions) and ask for one explicit approval.",
46
+ "**Early-exit concrete asks** — for unambiguous implementation-only requests, write a compact Problem Decision Record plus short-circuit handoff (context, approved intent, constraints, assumptions, next-stage risks) and ask for one explicit approval.",
46
47
  "**Ask only decision-changing questions** — one at a time; if answers would not change approach and are non-critical preference/default assumptions, state the assumption and continue; STOP on scope, architecture, security, data loss, public API, migration, auth/pricing, or user approval uncertainty.",
47
48
  "**Compare 2-3 distinct approaches with stable Role/Upside columns** — Role values are `baseline` | `challenger` | `wild-card`; Upside is `low` | `modest` | `high` | `higher`; include real trade-offs and reuse notes; include exactly one challenger with explicit `high` or `higher` upside.",
48
49
  "**Collect reaction before recommending** — ask which option feels closest and what concern remains, then recommend based on that reaction.",
49
50
  "**Write the `Not Doing` list** — name 3-5 things this brainstorm explicitly is not committing to (vs. deferred). This protects scope from silent enlargement and the next stage from rework.",
50
51
  "**Self-review before user approval** — re-read the artifact and patch contradictions, weak trade-offs, placeholders, ambiguity, and weak handoff language. Record the result in `Self-Review Notes` using the calibrated review format: `- Status: Approved` (or `Issues Found`), `- Patches applied:` with inline note or sub-bullets, `- Remaining concerns:` with inline note or sub-bullets. Use `Patches applied: None` and `Remaining concerns: None` when there is nothing to record.",
51
52
  "**Request explicit approval** — state exactly what direction is being approved; do not advance without approval and artifact review.",
52
- "**Handoff** — only after approval, complete the stage and point to `/cc-next`."
53
+ "**Handoff** — only after approval, hand scope: upstream decisions used, explicit drift, confidence level, unresolved questions, next-stage risk hints, and non-goals."
53
54
  ],
54
55
  interactionProtocol: [
55
56
  "Start from observed project context; if the idea is vague, first narrow the project type with **one** structured question, then keep going.",
57
+ "Select depth explicitly: `lite`, `standard`, or `deep`; keep lite concise, but escalate when risk/ambiguity changes decisions.",
56
58
  "Lead with the premise check (right problem / direct path / what if nothing) and the `How Might We` reframing before approaches; both go in the artifact, not just the chat.",
57
59
  "Ask at most one question per turn, only when decision-changing; if using a structured question tool, send exactly one question object, not a multi-question form.",
58
60
  "Only non-critical preference/default assumptions may continue inline. STOP and ask when uncertainty affects scope, architecture, security, data loss, public API, migration, auth/pricing, or user approval.",
@@ -78,14 +80,16 @@ export const BRAINSTORM = {
78
80
  requiredEvidence: [
79
81
  "Artifact written to `.cclaw/artifacts/01-brainstorm-<slug>.md`.",
80
82
  "Project context was explored (files, docs, or recent activity referenced).",
81
- "Clarifying questions and their answers are captured.",
83
+ "Problem Decision Record includes product framing or technical-maintenance framing.",
84
+ "Clarifying questions are one-at-a-time and captured only when they change a decision or stop condition.",
82
85
  "2-3 approaches with trade-offs are recorded, including one higher-upside challenger option.",
83
86
  "User reaction to approaches is captured before final recommendation.",
84
87
  "Final recommendation explicitly reflects user reaction.",
85
88
  "Selected Direction includes the handoff to the track-aware next stage: scope on standard, spec on medium when scope/design are skipped.",
86
89
  "When a promising option is parked, a seed file is created under `.cclaw/seeds/` and referenced in the artifact.",
87
90
  "Approved direction and approval marker are present.",
88
- "Assumptions and open questions are captured (or explicitly marked as none)."
91
+ "Assumptions and open questions are captured (or explicitly marked as none).",
92
+ "Scope handoff includes upstream decisions used, explicit drift, confidence, unresolved questions, next-stage risk hints, and non-goals."
89
93
  ],
90
94
  inputs: ["problem statement", "constraints", "success criteria"],
91
95
  requiredContext: [
@@ -124,16 +128,16 @@ export const BRAINSTORM = {
124
128
  },
125
129
  artifactValidation: [
126
130
  { section: "Context", required: true, validationRule: "Must reference project state and relevant existing code or patterns. A `Discovered context` subsection (or list) is recommended for downstream traceability." },
127
- { section: "Problem", required: true, validationRule: "Must define what we're solving, success criteria, and constraints." },
131
+ { section: "Problem Decision Record", required: true, validationRule: "Must include either product framing fields (persona/JTBD/pain/value/evidence/success/why-now/do-nothing/non-goals) or technical-maintenance fields (operator/developer, failure mode, operational improvement, verification signal, do-nothing cost, non-goals)." },
128
132
  { section: "Premise Check", required: false, validationRule: "Recommended: explicit answers to `Right problem?`, `Direct path?`, `What if we do nothing?` — take a position, do not hedge." },
129
133
  { section: "How Might We", required: false, validationRule: "Recommended: a single `How Might We …?` line naming the user, the outcome, and the binding constraint." },
130
- { section: "Sharpening Questions", required: false, validationRule: "Recommended: 3-5 question/answer pairs with explicit `Decision impact` so downstream stages see what each answer changed." },
134
+ { section: "Sharpening Questions", required: false, validationRule: "Recommended only when needed: one decision-changing question per turn with explicit `Decision impact`; compact tasks may record `None - early exit` with rationale." },
131
135
  { section: "Clarifying Questions", required: false, validationRule: "Must capture question, answer, and decision impact for each clarifying question." },
132
- { section: "Approach Tier", required: true, validationRule: "Must classify depth as Lightweight/Standard/Deep and explain why." },
136
+ { section: "Approach Tier", required: true, validationRule: "Must classify depth as lite/standard/deep and explain the risk/uncertainty signal." },
133
137
  { section: "Short-Circuit Decision", required: false, validationRule: "Must include Status/Why/Scope handoff lines when short-circuit is discussed; compact stubs are valid for concrete asks." },
134
138
  { section: "Approaches", required: true, validationRule: "Must compare 2-3 distinct options with real trade-offs. Use the canonical `Role` column with `baseline` | `challenger` | `wild-card` and the `Upside` column with `low` | `modest` | `high` | `higher`; include exactly one challenger row with `high` or `higher` upside." },
135
139
  { section: "Approach Reaction", required: true, validationRule: "Must appear before Selected Direction and summarize user reaction before recommendation, including `Closest option`, `Concerns`, and what changed after reaction." },
136
- { section: "Selected Direction", required: true, validationRule: "Must include the selected approach, an explicit approval marker, rationale traceable to the prior Approach Reaction, and a track-aware next-stage handoff." },
140
+ { section: "Selected Direction", required: true, validationRule: "Must include the selected approach, explicit approval marker, rationale traceable to Approach Reaction, and scope handoff with decisions, drift, confidence, unresolved questions, risk hints, and non-goals." },
137
141
  { section: "Not Doing", required: false, validationRule: "Recommended: 3-5 explicitly non-committed items (distinct from deferred). Protects scope from silent enlargement and the next stage from rework." },
138
142
  { section: "Design", required: false, validationRule: "Must cover architecture, key components, and data flow scaled to complexity." },
139
143
  { section: "Visual Companion", required: false, validationRule: "If architecture/data-flow complexity is medium+, include compact ASCII/Mermaid diagram or explicitly justify omission." },
@@ -142,7 +146,7 @@ export const BRAINSTORM = {
142
146
  ],
143
147
  trivialOverrideSections: [
144
148
  "Context",
145
- "Problem",
149
+ "Problem Decision Record",
146
150
  "Approach Tier",
147
151
  "Short-Circuit Decision",
148
152
  "Selected Direction"
@@ -150,7 +154,8 @@ export const BRAINSTORM = {
150
154
  },
151
155
  reviewLens: {
152
156
  outputs: [
153
- "approved design direction",
157
+ "Problem Decision Record",
158
+ "approved direction",
154
159
  "alternatives with trade-offs",
155
160
  "brainstorm artifact"
156
161
  ],