aw-ecc 1.4.23 → 1.4.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.cursor/INSTALL.md +9 -0
  3. package/.cursor/hooks/adapter.js +34 -3
  4. package/.cursor/hooks/aw-phase-definitions.js +11 -0
  5. package/.cursor/hooks/before-submit-prompt.sh +17 -0
  6. package/.cursor/hooks/session-start.sh +36 -0
  7. package/.cursor/hooks/shared/aw-phase-definitions.js +1 -19
  8. package/.cursor/hooks/shared/aw-phase-runner.js +38 -2
  9. package/.cursor/hooks/shared/user-prompt-submit.sh +40 -60
  10. package/.cursor/hooks.json +15 -15
  11. package/.cursor/rules/common-aw-routing.md +43 -0
  12. package/.cursor/skills/api-and-interface-design/SKILL.md +75 -0
  13. package/.cursor/skills/aw-brainstorm/SKILL.md +115 -0
  14. package/.cursor/skills/aw-build/SKILL.md +152 -0
  15. package/.cursor/skills/aw-build/evals/build-stage-cases.json +28 -0
  16. package/.cursor/skills/aw-debug/SKILL.md +49 -0
  17. package/.cursor/skills/aw-deploy/SKILL.md +101 -0
  18. package/.cursor/skills/aw-deploy/evals/deploy-stage-cases.json +32 -0
  19. package/.cursor/skills/aw-execute/SKILL.md +47 -0
  20. package/.cursor/skills/aw-execute/references/mode-code.md +47 -0
  21. package/.cursor/skills/aw-execute/references/mode-docs.md +28 -0
  22. package/.cursor/skills/aw-execute/references/mode-infra.md +44 -0
  23. package/.cursor/skills/aw-execute/references/mode-migration.md +58 -0
  24. package/.cursor/skills/aw-execute/references/worker-implementer.md +26 -0
  25. package/.cursor/skills/aw-execute/references/worker-parallel-worker.md +23 -0
  26. package/.cursor/skills/aw-execute/references/worker-quality-reviewer.md +23 -0
  27. package/.cursor/skills/aw-execute/references/worker-spec-reviewer.md +23 -0
  28. package/.cursor/skills/aw-execute/scripts/build-worker-bundle.js +229 -0
  29. package/.cursor/skills/aw-finish/SKILL.md +111 -0
  30. package/.cursor/skills/aw-investigate/SKILL.md +109 -0
  31. package/.cursor/skills/aw-plan/SKILL.md +368 -0
  32. package/.cursor/skills/aw-prepare/SKILL.md +118 -0
  33. package/.cursor/skills/aw-review/SKILL.md +118 -0
  34. package/.cursor/skills/aw-ship/SKILL.md +115 -0
  35. package/.cursor/skills/aw-spec/SKILL.md +104 -0
  36. package/.cursor/skills/aw-tasks/SKILL.md +138 -0
  37. package/.cursor/skills/aw-test/SKILL.md +118 -0
  38. package/.cursor/skills/aw-verify/SKILL.md +51 -0
  39. package/.cursor/skills/aw-yolo/SKILL.md +111 -0
  40. package/.cursor/skills/browser-testing-with-devtools/SKILL.md +81 -0
  41. package/.cursor/skills/ci-cd-and-automation/SKILL.md +71 -0
  42. package/.cursor/skills/code-simplification/SKILL.md +74 -0
  43. package/.cursor/skills/context-engineering/SKILL.md +74 -0
  44. package/.cursor/skills/deprecation-and-migration/SKILL.md +75 -0
  45. package/.cursor/skills/documentation-and-adrs/SKILL.md +75 -0
  46. package/.cursor/skills/frontend-ui-engineering/SKILL.md +68 -0
  47. package/.cursor/skills/git-workflow-and-versioning/SKILL.md +75 -0
  48. package/.cursor/skills/idea-refine/SKILL.md +84 -0
  49. package/.cursor/skills/incremental-implementation/SKILL.md +75 -0
  50. package/.cursor/skills/performance-optimization/SKILL.md +77 -0
  51. package/.cursor/skills/security-and-hardening/SKILL.md +70 -0
  52. package/.cursor/skills/using-aw-skills/SKILL.md +290 -0
  53. package/.cursor/skills/using-aw-skills/evals/skill-trigger-cases.tsv +25 -0
  54. package/.cursor/skills/using-aw-skills/evals/test-skill-triggers.sh +171 -0
  55. package/.cursor/skills/using-aw-skills/hooks/hooks.json +9 -0
  56. package/.cursor/skills/using-aw-skills/hooks/session-start.sh +67 -0
  57. package/.cursor/skills/using-platform-skills/SKILL.md +163 -0
  58. package/.cursor/skills/using-platform-skills/evals/platform-selection-cases.json +52 -0
  59. package/.opencode/package.json +1 -1
  60. package/package.json +5 -1
  61. package/scripts/cursor-aw-home/hooks.json +15 -15
  62. package/scripts/cursor-aw-hooks/adapter.js +34 -3
  63. package/scripts/cursor-aw-hooks/aw-phase-definitions.js +11 -0
  64. package/scripts/cursor-aw-hooks/before-submit-prompt.sh +17 -0
  65. package/scripts/cursor-aw-hooks/session-start.sh +36 -0
  66. package/scripts/hooks/session-start-rules-context.sh +8 -1
  67. package/scripts/hooks/shared/aw-phase-definitions.js +1 -19
  68. package/scripts/hooks/shared/aw-phase-runner.js +38 -2
  69. package/scripts/hooks/shared/user-prompt-submit.sh +40 -60
  70. package/scripts/lib/cursor-aw-hook-files.js +2 -0
  71. package/scripts/lib/cursor-hook-config.js +47 -15
  72. package/scripts/lib/install-executor.js +7 -0
  73. package/scripts/lib/install-targets/cursor-project.js +7 -0
@@ -0,0 +1,58 @@
1
+ # Mode: Migration — Staged Rollout
2
+
3
+ ## Process
4
+
5
+ ### 1. Script
6
+
7
+ - Write the migration script. It MUST be **idempotent** — running it twice produces the same result.
8
+ - Use `up()` and `down()` functions (or equivalent) for forward and rollback.
9
+ - Include validation checks that confirm the migration was applied correctly.
10
+ - Test the migration against a copy of production data (or realistic test data).
11
+
12
+ ### 2. Rollback
13
+
14
+ - Every migration MUST have a rollback path.
15
+ - Write the rollback script before applying the migration.
16
+ - Test the rollback independently.
17
+ - Document the rollback procedure in the migration file header.
18
+
19
+ ### 3. Validate
20
+
21
+ - Run the migration in a test/staging environment first.
22
+ - Verify data integrity after migration.
23
+ - Check that dependent queries still work with the new schema.
24
+ - Confirm indexes are in place before queries execute.
25
+
26
+ ### 4. Commit
27
+
28
+ - Commit migration files with `migration:` or `feat:` prefix.
29
+ - Include the rollback script in the same commit.
30
+ - Document the migration in the PR description.
31
+
32
+ ## Rules
33
+
34
+ ### Indexes
35
+
36
+ - **Deploy indexes BEFORE** deploying schema or query changes that use them.
37
+ - Use `background: true` for index creation (or rely on MongoDB 4.2+ default).
38
+ - Add compound indexes for multi-field queries — avoid multiple single-field indexes.
39
+ - Scope all MongoDB queries by `locationId` (compound index required).
40
+
41
+ ### Fields
42
+
43
+ - New fields MUST have default values or be nullable — never break existing documents.
44
+ - Remove fields in two phases: (1) stop writing, (2) remove after migration window.
45
+ - Never rename fields in a single migration — add new, migrate data, remove old.
46
+
47
+ ### Secrets
48
+
49
+ - Never store secrets in migration scripts.
50
+ - Use environment variables or GCP Secret Manager for connection strings.
51
+ - Never log sensitive data during migration (PII, credentials, tokens).
52
+
53
+ ### Data Safety
54
+
55
+ - Back up the collection/table before running destructive migrations.
56
+ - Use transactions where available for multi-document updates.
57
+ - Set reasonable batch sizes for bulk operations — avoid OOM.
58
+ - Log progress for long-running migrations (every N records).
@@ -0,0 +1,26 @@
1
+ # Worker Role: Implementer
2
+
3
+ ## Objective
4
+
5
+ Own one bounded task unit from the approved AW execution inputs.
6
+ Change only the smallest correct file set for that unit.
7
+
8
+ ## Inputs
9
+
10
+ - approved feature inputs from `.aw_docs/features/<feature_slug>/`
11
+ - current task-unit bundle
12
+ - repo-local AW execution contract
13
+
14
+ ## Required Behavior
15
+
16
+ 1. confirm the task-unit goal and file scope
17
+ 2. capture the RED or failure-first signal when behavior changes
18
+ 3. implement the smallest correct GREEN change
19
+ 4. record handoff notes for spec and quality review
20
+ 5. stop when the task unit is complete or blocked
21
+
22
+ ## Hard Gates
23
+
24
+ - do not widen the write scope without naming why
25
+ - do not skip runnable tests silently
26
+ - do not mark the task done without concrete notes for the next review roles
@@ -0,0 +1,23 @@
1
+ # Worker Role: Parallel Worker
2
+
3
+ ## Objective
4
+
5
+ Execute one task unit that has already been marked `parallel_candidate` with a disjoint write scope.
6
+ The orchestrator should keep active parallel workers within the configured cap, which defaults to `3`.
7
+
8
+ ## Inputs
9
+
10
+ - current task-unit bundle
11
+ - declared disjoint write scope
12
+ - repo-local AW execution contract
13
+
14
+ ## Required Behavior
15
+
16
+ 1. stay inside the declared write scope
17
+ 2. keep notes concise so the merge-back step can reconcile outputs cleanly
18
+ 3. stop immediately if the work crosses into another worker's files
19
+
20
+ ## Hard Gates
21
+
22
+ - do not edit shared files outside the declared scope
23
+ - do not claim a task unit is parallel-safe if overlap was discovered during execution
@@ -0,0 +1,23 @@
1
+ # Worker Role: Quality Reviewer
2
+
3
+ ## Objective
4
+
5
+ Check maintainability, reliability, and stage readiness for one completed task unit.
6
+
7
+ ## Inputs
8
+
9
+ - implementer handoff notes
10
+ - spec review outcome
11
+ - current task-unit bundle
12
+
13
+ ## Required Behavior
14
+
15
+ 1. inspect the changed files and local validation notes
16
+ 2. flag maintainability or reliability issues that would block handoff
17
+ 3. state `pass`, `pass_with_notes`, or `fail`
18
+ 4. hand back the smallest concrete repair scope when failing
19
+
20
+ ## Hard Gates
21
+
22
+ - do not reopen planning
23
+ - do not wave through unresolved reliability or validation gaps
@@ -0,0 +1,23 @@
1
+ # Worker Role: Spec Reviewer
2
+
3
+ ## Objective
4
+
5
+ Check one completed task unit against the approved AW inputs before the stage can move forward.
6
+
7
+ ## Inputs
8
+
9
+ - approved feature inputs from `.aw_docs/features/<feature_slug>/`
10
+ - implementer handoff notes
11
+ - current task-unit bundle
12
+
13
+ ## Required Behavior
14
+
15
+ 1. compare the implementation against the approved task-unit goal
16
+ 2. flag scope drift or missed acceptance criteria
17
+ 3. state `pass`, `pass_with_notes`, or `fail`
18
+ 4. hand back the smallest concrete repair scope when failing
19
+
20
+ ## Hard Gates
21
+
22
+ - do not invent new product scope
23
+ - do not approve a task unit that skipped a required acceptance point
@@ -0,0 +1,229 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ function usage() {
8
+ console.error(
9
+ 'Usage: node skills/aw-execute/scripts/build-worker-bundle.js --feature <slug> --tasks-file <path> [--output <path>] [--allow-parallel] [--max-parallel-workers <n>]'
10
+ );
11
+ }
12
+
13
+ function parseArgs(argv) {
14
+ const args = {
15
+ allowParallel: false,
16
+ maxParallelWorkers: 3,
17
+ };
18
+
19
+ for (let index = 0; index < argv.length; index += 1) {
20
+ const current = argv[index];
21
+ if (current === '--allow-parallel') {
22
+ args.allowParallel = true;
23
+ continue;
24
+ }
25
+
26
+ if (!current.startsWith('--')) {
27
+ throw new Error(`Unexpected argument: ${current}`);
28
+ }
29
+
30
+ const next = argv[index + 1];
31
+ if (!next || next.startsWith('--')) {
32
+ throw new Error(`Missing value for ${current}`);
33
+ }
34
+
35
+ if (current === '--feature') {
36
+ args.featureSlug = next;
37
+ } else if (current === '--tasks-file') {
38
+ args.tasksFile = next;
39
+ } else if (current === '--output') {
40
+ args.output = next;
41
+ } else if (current === '--max-parallel-workers') {
42
+ const parsedValue = Number(next);
43
+ if (!Number.isInteger(parsedValue) || parsedValue < 1) {
44
+ throw new Error('--max-parallel-workers must be a positive integer');
45
+ }
46
+ args.maxParallelWorkers = parsedValue;
47
+ } else {
48
+ throw new Error(`Unknown argument: ${current}`);
49
+ }
50
+
51
+ index += 1;
52
+ }
53
+
54
+ if (!args.featureSlug || !args.tasksFile) {
55
+ usage();
56
+ throw new Error('--feature and --tasks-file are required');
57
+ }
58
+
59
+ return args;
60
+ }
61
+
62
+ function toPosixPath(value) {
63
+ return value.split(path.sep).join('/');
64
+ }
65
+
66
+ function parseTaskUnits(content) {
67
+ const units = [];
68
+
69
+ for (const line of content.split(/\r?\n/)) {
70
+ const match = line.match(/^\s*(?:- \[[ xX]\]|-|\*|\d+\.)\s+(.+?)\s*$/);
71
+ if (!match) {
72
+ continue;
73
+ }
74
+
75
+ const title = match[1].trim();
76
+ if (!title) {
77
+ continue;
78
+ }
79
+
80
+ units.push(title);
81
+ }
82
+
83
+ if (units.length === 0) {
84
+ throw new Error('No task units found in tasks file');
85
+ }
86
+
87
+ return units;
88
+ }
89
+
90
+ function buildRolePrompt({ roleGuide, featureSlug, taskUnitTitle, tasksFilePath, roleName }) {
91
+ return [
92
+ `Load role guide: ${roleGuide}`,
93
+ `Feature slug: ${featureSlug}`,
94
+ `Task unit: ${taskUnitTitle}`,
95
+ `Approved task source: ${tasksFilePath}`,
96
+ `Role: ${roleName}`,
97
+ 'Stay within the repo-local AW execute contract and keep the scope bounded.',
98
+ ].join('\n');
99
+ }
100
+
101
+ function buildBundle({ featureSlug, tasksFilePath, allowParallel, maxParallelWorkers, repoRoot }) {
102
+ const taskUnits = parseTaskUnits(fs.readFileSync(tasksFilePath, 'utf8'));
103
+ const referencePaths = {
104
+ implementer: 'skills/aw-execute/references/worker-implementer.md',
105
+ spec_reviewer: 'skills/aw-execute/references/worker-spec-reviewer.md',
106
+ quality_reviewer: 'skills/aw-execute/references/worker-quality-reviewer.md',
107
+ parallel_worker: 'skills/aw-execute/references/worker-parallel-worker.md',
108
+ };
109
+
110
+ const relativeTasksFile = toPosixPath(path.relative(repoRoot, tasksFilePath) || path.basename(tasksFilePath));
111
+ const bundle = {
112
+ schema_version: 'aw.execute.worker-bundle.v1',
113
+ feature_slug: featureSlug,
114
+ generated_at: new Date().toISOString(),
115
+ source_tasks_file: relativeTasksFile,
116
+ role_reference_paths: referencePaths,
117
+ task_units: taskUnits.map((title, index) => {
118
+ const taskUnitId = `task-${index + 1}`;
119
+ const parallelCandidate = allowParallel && taskUnits.length > 1;
120
+
121
+ const taskUnit = {
122
+ id: taskUnitId,
123
+ title,
124
+ parallel_candidate: parallelCandidate,
125
+ roles: {
126
+ implementer: {
127
+ reference_path: referencePaths.implementer,
128
+ prompt: buildRolePrompt({
129
+ roleGuide: referencePaths.implementer,
130
+ featureSlug,
131
+ taskUnitTitle: title,
132
+ tasksFilePath: relativeTasksFile,
133
+ roleName: 'implementer',
134
+ }),
135
+ },
136
+ spec_reviewer: {
137
+ reference_path: referencePaths.spec_reviewer,
138
+ prompt: buildRolePrompt({
139
+ roleGuide: referencePaths.spec_reviewer,
140
+ featureSlug,
141
+ taskUnitTitle: title,
142
+ tasksFilePath: relativeTasksFile,
143
+ roleName: 'spec_reviewer',
144
+ }),
145
+ },
146
+ quality_reviewer: {
147
+ reference_path: referencePaths.quality_reviewer,
148
+ prompt: buildRolePrompt({
149
+ roleGuide: referencePaths.quality_reviewer,
150
+ featureSlug,
151
+ taskUnitTitle: title,
152
+ tasksFilePath: relativeTasksFile,
153
+ roleName: 'quality_reviewer',
154
+ }),
155
+ },
156
+ },
157
+ };
158
+
159
+ if (parallelCandidate) {
160
+ taskUnit.roles.parallel_worker = {
161
+ reference_path: referencePaths.parallel_worker,
162
+ prompt: buildRolePrompt({
163
+ roleGuide: referencePaths.parallel_worker,
164
+ featureSlug,
165
+ taskUnitTitle: title,
166
+ tasksFilePath: relativeTasksFile,
167
+ roleName: 'parallel_worker',
168
+ }),
169
+ };
170
+ }
171
+
172
+ return taskUnit;
173
+ }),
174
+ orchestration_plan: allowParallel
175
+ ? {
176
+ sessionName: `aw-execute-${featureSlug}`,
177
+ repoRoot,
178
+ baseRef: 'HEAD',
179
+ max_parallel_workers: maxParallelWorkers,
180
+ seedPaths: [
181
+ 'skills/aw-execute/scripts/build-worker-bundle.js',
182
+ ...Object.values(referencePaths),
183
+ ],
184
+ launcherCommand: 'codex exec --skip-git-repo-check "$(cat {task_file_sh})"',
185
+ workers: taskUnits.map((title, index) => ({
186
+ name: `implementer-task-${index + 1}`,
187
+ task: buildRolePrompt({
188
+ roleGuide: referencePaths.parallel_worker,
189
+ featureSlug,
190
+ taskUnitTitle: title,
191
+ tasksFilePath: relativeTasksFile,
192
+ roleName: 'parallel_worker',
193
+ }),
194
+ })),
195
+ }
196
+ : null,
197
+ };
198
+
199
+ return bundle;
200
+ }
201
+
202
+ function main() {
203
+ try {
204
+ const args = parseArgs(process.argv.slice(2));
205
+ const repoRoot = process.cwd();
206
+ const tasksFilePath = path.resolve(repoRoot, args.tasksFile);
207
+ const outputPath = args.output ? path.resolve(repoRoot, args.output) : null;
208
+ const bundle = buildBundle({
209
+ featureSlug: args.featureSlug,
210
+ tasksFilePath,
211
+ allowParallel: args.allowParallel,
212
+ maxParallelWorkers: args.maxParallelWorkers,
213
+ repoRoot,
214
+ });
215
+
216
+ const payload = `${JSON.stringify(bundle, null, 2)}\n`;
217
+ if (outputPath) {
218
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
219
+ fs.writeFileSync(outputPath, payload, 'utf8');
220
+ } else {
221
+ process.stdout.write(payload);
222
+ }
223
+ } catch (error) {
224
+ console.error(error.message);
225
+ process.exit(1);
226
+ }
227
+ }
228
+
229
+ main();
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: aw-finish
3
+ description: Internal compatibility helper for completing a verified development branch with explicit merge, PR, keep, or discard choices and safe worktree cleanup.
4
+ trigger: Internal only. Invoked when verified branch work is done and the next step is a branch-completion decision rather than a staging deployment.
5
+ ---
6
+
7
+ # AW Finish
8
+
9
+ `aw-finish` is a legacy compatibility skill.
10
+ The canonical public release stage remains `/aw:deploy`, but this helper still owns the branch-completion decision flow when that workflow is needed internally.
11
+
12
+ ## Hard Gate
13
+
14
+ `aw-test` and `aw-review` must have passed before this skill runs, or the compatibility umbrella must have recorded an equivalent verified outcome.
15
+ If verification failed, route back to `aw-build`, `aw-test`, or `aw-review` instead of finishing.
16
+
17
+ ## Purpose
18
+
19
+ Use this skill to close out verified branch work safely:
20
+
21
+ - verify tests before offering completion choices
22
+ - present explicit branch-completion options
23
+ - execute the selected path
24
+ - clean up the worktree only when appropriate
25
+
26
+ If `.aw_docs/features/<feature_slug>/workspace.json` exists, use it as the source of truth for:
27
+
28
+ - the active branch and worktree path
29
+ - cleanup policy
30
+ - orchestration coordination directory
31
+ - the recommended `node scripts/orchestration-status.js ...` status command
32
+
33
+ Staging or production deployment requests should stay on `aw-deploy`.
34
+
35
+ ## Deprecation Timeline
36
+
37
+ This skill is still active internally even though `/aw:finish` is deprecated as a public entrypoint.
38
+ Keep `aw-finish` available until `/aw:deploy` fully absorbs branch-completion choices, workspace metadata reuse, and cleanup behavior.
39
+ Public deprecation must not be interpreted as immediate removal of the internal helper.
40
+
41
+ ## Completion Flow
42
+
43
+ 1. verify tests and validation signals still pass
44
+ 2. determine the base branch
45
+ 3. present exactly these choices:
46
+ - merge locally
47
+ - push and create PR
48
+ - keep as branch
49
+ - discard
50
+ 4. execute the selected path
51
+ 5. clean up the worktree when the selected path requires cleanup
52
+ 6. update or clear `workspace.json` to reflect the final cleanup decision
53
+
54
+ ## Required Options
55
+
56
+ ### Option 1: Merge Locally
57
+
58
+ - switch to base branch
59
+ - update from remote when appropriate
60
+ - merge the verified branch
61
+ - rerun the minimum correct verification
62
+ - remove the branch or worktree when safe
63
+ - clear `workspace.json` when cleanup completed successfully
64
+
65
+ ### Option 2: Push and Create PR
66
+
67
+ - push the branch
68
+ - create or update the PR with concise summary and test plan
69
+ - keep the worktree if the branch remains active
70
+ - preserve `workspace.json` for the active branch lifecycle
71
+
72
+ ### Option 3: Keep As-Is
73
+
74
+ - keep the branch and worktree intact
75
+ - report the branch name and next expected action
76
+ - keep `workspace.json` intact for follow-up work
77
+
78
+ ### Option 4: Discard
79
+
80
+ - require explicit confirmation
81
+ - delete the branch or worktree only after confirmation
82
+ - remove `workspace.json` only after cleanup succeeds
83
+
84
+ ## Worktree Cleanup Rule
85
+
86
+ Only clean up the worktree automatically for:
87
+
88
+ - merge-complete paths
89
+ - confirmed discard paths
90
+
91
+ Do not clean up the worktree for:
92
+
93
+ - keep-as-branch
94
+ - PR-open workflows where the branch is still in active use
95
+
96
+ ## Hard Gates
97
+
98
+ - do not offer completion choices until tests are rechecked
99
+ - do not discard work without explicit confirmation
100
+ - do not turn branch completion into deployment orchestration
101
+ - do not clean up an active PR worktree by accident
102
+
103
+ ## Final Output Shape
104
+
105
+ Always end with:
106
+
107
+ - `Verification Check`
108
+ - `Base Branch`
109
+ - `Completion Options`
110
+ - `Selected Path`
111
+ - `Cleanup Decision`
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: aw-investigate
3
+ description: Reproduce, localize, and confirm bugs, alerts, and regressions before broad fixes are attempted.
4
+ trigger: User requests bug investigation, alert triage, root-cause analysis, or a legacy fix request arrives without a trustworthy cause.
5
+ ---
6
+
7
+ # AW Investigate
8
+
9
+ ## Overview
10
+
11
+ `aw-investigate` is the public debugging and triage stage.
12
+ It turns vague failure into concrete evidence, a likely fault surface, and a clear next step.
13
+
14
+ ## When to Use
15
+
16
+ - root cause is unclear
17
+ - the request starts from an alert, failure, log, or regression report
18
+ - repeated fix attempts have already happened
19
+ - the right next step might be "gather more evidence," not "change code"
20
+
21
+ Do not use once the cause is already clear and implementation is ready.
22
+
23
+ ## Workflow
24
+
25
+ 1. Capture the failure signal.
26
+ Record the trigger, expected behavior, actual behavior, and current blast radius.
27
+ 2. Reproduce or isolate.
28
+ Use `aw-debug` and `../../references/debug-triage.md`.
29
+ For browser-visible issues, load `browser-testing-with-devtools`.
30
+ Prefer the smallest confirming probe over speculative patching.
31
+ 3. Load the right org-standard context.
32
+ Pull in relevant platform services, frontend, data, or infra playbooks.
33
+ For incident-style problems, load observability or log-analysis helpers as needed.
34
+ 4. Narrow the fault surface.
35
+ Identify the smallest plausible layer, file set, or dependency boundary.
36
+ 5. Decide the next stage.
37
+ If the cause is concrete enough, hand off to `aw-build` and name the exact starting slice or repair surface.
38
+ If the work still needs proof, stay in investigation and name the next probe explicitly instead of pausing with a vague "needs more digging" note.
39
+ 6. Persist the evidence.
40
+ Write `investigation.md` and update `state.json` with completed probes, open questions, and the recommended next command.
41
+
42
+ ## Completion Contract
43
+
44
+ Investigation is complete only when one of these is true:
45
+
46
+ - the likely fault surface is concrete enough for `aw-build`
47
+ - the next probe is explicit enough for another investigation pass to continue without rediscovery
48
+ - the work is blocked and the blocker is named clearly
49
+
50
+ Every investigation handoff must make these things obvious:
51
+
52
+ - what was reproduced
53
+ - which probes were completed
54
+ - what remains uncertain
55
+ - which exact next command or next probe should run next
56
+
57
+ ## Common Rationalizations
58
+
59
+ | Rationalization | Reality |
60
+ |---|---|
61
+ | "I already know the likely fix." | Likely is not the same as confirmed. |
62
+ | "The third patch will probably work." | Repeated speculative fixes are a debugging failure. |
63
+ | "I don't need logs or runtime evidence for this." | Alerts and regressions need concrete signals, not memory. |
64
+
65
+ ## Red Flags
66
+
67
+ - fix attempts outnumber confirming probes
68
+ - the failure is described only in prose, not evidence
69
+ - the blast radius is guessed instead of scoped
70
+ - the next action is "try another patch" instead of "run the next probe"
71
+
72
+ ## State File
73
+
74
+ `state.json` should record at least:
75
+
76
+ - `feature_slug`
77
+ - `stage: "investigate"`
78
+ - `mode`
79
+ - `status`
80
+ - written artifacts
81
+ - completed probes
82
+ - commands run
83
+ - likely fault surface
84
+ - open questions
85
+ - blockers
86
+ - recommended next commands
87
+
88
+ ## Verification
89
+
90
+ Before leaving investigate, confirm:
91
+
92
+ - [ ] reproduction or equivalent failure signal is captured
93
+ - [ ] expected vs actual behavior is explicit
94
+ - [ ] the likely fault surface is concrete enough to guide build
95
+ - [ ] the next stage is clear: build, more investigation, or blocked
96
+ - [ ] `investigation.md` and `state.json` are updated
97
+
98
+ ## Final Output Shape
99
+
100
+ Always end with:
101
+
102
+ - `Mode`
103
+ - `Reproduction`
104
+ - `Expected vs Actual`
105
+ - `Evidence`
106
+ - `Completed Probes`
107
+ - `Likely Fault Surface`
108
+ - `Open Questions`
109
+ - `Next`