@ecc-hgy/ae 0.4.0 → 0.6.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.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +168 -138
  3. package/bin/ae.js +2 -2
  4. package/package.json +43 -43
  5. package/skills/brainstorming/SKILL.md +133 -133
  6. package/skills/diagnose/SKILL.md +146 -146
  7. package/skills/diagnose/assets/issue-7-sections.md +35 -35
  8. package/skills/diagnose/scripts/hitl-loop.template.sh +41 -41
  9. package/skills/grill-me/SKILL.md +10 -10
  10. package/skills/handoff/SKILL.md +19 -19
  11. package/skills/improve-codebase-architecture/DEEPENING.md +37 -37
  12. package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -123
  13. package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -44
  14. package/skills/improve-codebase-architecture/LANGUAGE.md +53 -53
  15. package/skills/improve-codebase-architecture/SKILL.md +101 -101
  16. package/skills/karpathy-guidelines/SKILL.md +63 -63
  17. package/skills/powerautomate-email-to-sharepoint-excel/powerautomate-email-to-sharepoint-excel-skill.md +496 -0
  18. package/skills/review/SKILL.md +119 -119
  19. package/skills/tdd/SKILL.md +157 -157
  20. package/skills/tdd/deep-modules.md +33 -33
  21. package/skills/tdd/interface-design.md +31 -31
  22. package/skills/tdd/mocking.md +59 -59
  23. package/skills/tdd/refactoring.md +10 -10
  24. package/skills/tdd/tests.md +61 -61
  25. package/skills/to-issues/SKILL.md +79 -79
  26. package/skills/to-issues/todo-template.md +25 -25
  27. package/skills/to-prd/SKILL.md +108 -108
  28. package/skills/using-agentic-engineering/SKILL.md +62 -62
  29. package/skills/verification-before-completion/SKILL.md +153 -153
  30. package/skills/writing-plans/SKILL.md +115 -115
  31. package/skills/zoom-out/SKILL.md +7 -7
  32. package/src/cli.js +61 -61
  33. package/src/commands/init.js +137 -134
  34. package/src/commands/setup.js +162 -103
  35. package/src/platforms.js +132 -0
  36. package/src/skeleton.js +134 -99
  37. package/src/utils/copy.js +100 -100
  38. package/src/utils/paths.js +60 -60
  39. package/src/utils/report.js +30 -30
  40. package/templates/entries/AGENTS.md +2 -0
  41. package/templates/entries/CLAUDE.md +5 -5
  42. package/templates/entries/README.md +33 -31
  43. package/templates/entries/handoff.md +1 -1
  44. package/templates/entries/spec/ADR/AGENTS.md +30 -30
  45. package/templates/entries/spec/ADR/CLAUDE.md +5 -5
  46. package/templates/entries/spec/AGENTS.md +34 -34
  47. package/templates/entries/spec/CLAUDE.md +5 -5
  48. package/templates/entries/spec/INDEX.md +28 -28
  49. package/templates/entries/spec/README.md +23 -23
@@ -1,133 +1,133 @@
1
- ---
2
- name: brainstorming
3
- description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation. Used at S1 node A1 for coarse alignment; pair with grill-me for fine-grained interface/field/parameter alignment; output is conversation alignment, NOT a written PRD (PRD writing is A2 to-prd)."
4
- ---
5
-
6
- # Brainstorming Ideas Into Designs
7
-
8
- Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
9
-
10
- Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.
11
-
12
- <HARD-GATE>
13
- Do NOT advance to A2 (`to-prd`), write any `prd.md`, scaffold any directories, or take any implementation action until the user has explicitly approved the alignment summary. This is the first of S1's two hard gates: requirement not aligned ⇒ no `prd.md`. Applies to EVERY need regardless of perceived simplicity.
14
- </HARD-GATE>
15
-
16
- ## Anti-Pattern: "This Is Too Simple To Need A Design"
17
-
18
- Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
19
-
20
- ## Checklist (S1 node A1)
21
-
22
- Complete in order:
23
-
24
- 1. **Explore project context** — read `spec/INDEX.md`, `spec/README.md`, and any existing `spec/needs/*/prd.md` to understand vocabulary and adjacent needs; check recent commits if useful
25
- 2. **Surface scope sizing** — if the request describes multiple independent subsystems, flag it (see "Working in existing codebases" below); each subsystem becomes its own need
26
- 3. **Ask clarifying questions** — one at a time; cover purpose, constraints, success criteria, what is NOT in scope
27
- 4. **If interface / field / parameter details surface** — switch to `grill-me` for that branch, then return here for the rest
28
- 5. **Propose 2-3 approaches** at requirement level (NOT technical) — with trade-offs and your recommendation
29
- 6. **Present alignment summary** — a short structured recap (problem / proposed solution / scope / out-of-scope / success criteria); get user approval
30
- 7. **Confirm hand-off to A2** — once approved, tell the user the next step is `to-prd` (which will write `spec/needs/<need-name>/prd.md`)
31
-
32
- ## Process Flow
33
-
34
- ```dot
35
- digraph brainstorming {
36
- "Explore project context" [shape=box];
37
- "Ask clarifying questions" [shape=box];
38
- "Interface/field/parameter detail?" [shape=diamond];
39
- "Switch to grill-me\n(return here after)" [shape=box];
40
- "Propose 2-3 approaches" [shape=box];
41
- "Present alignment summary" [shape=box];
42
- "User approves alignment?" [shape=diamond];
43
- "Hand off to A2 (to-prd)" [shape=doublecircle];
44
-
45
- "Explore project context" -> "Ask clarifying questions";
46
- "Ask clarifying questions" -> "Interface/field/parameter detail?";
47
- "Interface/field/parameter detail?" -> "Switch to grill-me\n(return here after)" [label="yes"];
48
- "Interface/field/parameter detail?" -> "Propose 2-3 approaches" [label="no"];
49
- "Switch to grill-me\n(return here after)" -> "Propose 2-3 approaches";
50
- "Propose 2-3 approaches" -> "Present alignment summary";
51
- "Present alignment summary" -> "User approves alignment?";
52
- "User approves alignment?" -> "Present alignment summary" [label="no, revise"];
53
- "User approves alignment?" -> "Hand off to A2 (to-prd)" [label="yes"];
54
- }
55
- ```
56
-
57
- **The terminal state is hand-off to A2 (`to-prd`), NOT directly to implementation.** Do NOT invoke `writing-plans`, `tdd`, or any other implementation skill from here. A2 produces the `prd.md`; A3 (`writing-plans`) consumes the `prd.md` to produce `design.md`. The boundary is strict.
58
-
59
- ## The Process
60
-
61
- **Understanding the idea:**
62
-
63
- - Check out the current project state first (files, docs, recent commits)
64
- - Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
65
- - If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
66
- - For appropriately-scoped projects, ask questions one at a time to refine the idea
67
- - Prefer multiple choice questions when possible, but open-ended is fine too
68
- - Only one question per message - if a topic needs more exploration, break it into multiple questions
69
- - Focus on understanding: purpose, constraints, success criteria
70
-
71
- **Exploring approaches:**
72
-
73
- - Propose 2-3 different approaches with trade-offs
74
- - Present options conversationally with your recommendation and reasoning
75
- - Lead with your recommended option and explain why
76
-
77
- **Presenting the design:**
78
-
79
- - Once you believe you understand what you're building, present the design
80
- - Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
81
- - Ask after each section whether it looks right so far
82
- - Cover: architecture, components, data flow, error handling, testing
83
- - Be ready to go back and clarify if something doesn't make sense
84
-
85
- **Design for isolation and clarity:**
86
-
87
- - Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
88
- - For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
89
- - Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
90
- - Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.
91
-
92
- **Working in existing codebases:**
93
-
94
- - Explore the current structure before proposing changes. Follow existing patterns.
95
- - Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
96
- - Don't propose unrelated refactoring. Stay focused on what serves the current goal.
97
-
98
- ## After Alignment
99
-
100
- **Alignment summary (in conversation only — do NOT write a file):**
101
-
102
- - Problem (from user's perspective)
103
- - Proposed solution (at requirement level, not technical)
104
- - In scope / Out of scope
105
- - Success criteria
106
- - Open questions (if any) — must be empty before the hard gate passes
107
-
108
- **Quick self-check before declaring alignment:**
109
-
110
- 1. **Placeholder scan:** Any "TBD" or vague success criteria? Sharpen them.
111
- 2. **Scope check:** Is this a single need, or does it need decomposition into multiple needs?
112
- 3. **Ambiguity check:** Could any requirement be interpreted two ways? Pick one explicitly.
113
-
114
- **User approval gate:**
115
-
116
- Present the alignment summary. Ask:
117
-
118
- > "Does this capture what you want? If yes, the next step is `to-prd` (A2), which will write `spec/needs/<need-name>/prd.md`. If anything is off, point me at it and I'll re-align."
119
-
120
- Wait for explicit approval. If the user requests changes, iterate. Do NOT advance to A2 until approved (HARD-GATE above).
121
-
122
- **Hand-off to A2:**
123
-
124
- Once approved, recommend `to-prd` as the next step. Do NOT invoke `writing-plans`, `tdd`, or any other skill. The strict chain is: A1 (brainstorming) → A2 (to-prd) → A3 (writing-plans) → A4 (to-issues) → A5 (tdd) → A6 (verification-before-completion).
125
-
126
- ## Key Principles
127
-
128
- - **One question at a time** - Don't overwhelm with multiple questions
129
- - **Multiple choice preferred** - Easier to answer than open-ended when possible
130
- - **YAGNI ruthlessly** - Remove unnecessary features from all designs
131
- - **Explore alternatives** - Always propose 2-3 approaches before settling
132
- - **Incremental validation** - Present design, get approval before moving on
133
- - **Be flexible** - Go back and clarify when something doesn't make sense
1
+ ---
2
+ name: brainstorming
3
+ description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation. Used at S1 node A1 for coarse alignment; pair with grill-me for fine-grained interface/field/parameter alignment; output is conversation alignment, NOT a written PRD (PRD writing is A2 to-prd)."
4
+ ---
5
+
6
+ # Brainstorming Ideas Into Designs
7
+
8
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
9
+
10
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.
11
+
12
+ <HARD-GATE>
13
+ Do NOT advance to A2 (`to-prd`), write any `prd.md`, scaffold any directories, or take any implementation action until the user has explicitly approved the alignment summary. This is the first of S1's two hard gates: requirement not aligned ⇒ no `prd.md`. Applies to EVERY need regardless of perceived simplicity.
14
+ </HARD-GATE>
15
+
16
+ ## Anti-Pattern: "This Is Too Simple To Need A Design"
17
+
18
+ Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
19
+
20
+ ## Checklist (S1 node A1)
21
+
22
+ Complete in order:
23
+
24
+ 1. **Explore project context** — read `spec/INDEX.md`, `spec/README.md`, and any existing `spec/needs/*/prd.md` to understand vocabulary and adjacent needs; check recent commits if useful
25
+ 2. **Surface scope sizing** — if the request describes multiple independent subsystems, flag it (see "Working in existing codebases" below); each subsystem becomes its own need
26
+ 3. **Ask clarifying questions** — one at a time; cover purpose, constraints, success criteria, what is NOT in scope
27
+ 4. **If interface / field / parameter details surface** — switch to `grill-me` for that branch, then return here for the rest
28
+ 5. **Propose 2-3 approaches** at requirement level (NOT technical) — with trade-offs and your recommendation
29
+ 6. **Present alignment summary** — a short structured recap (problem / proposed solution / scope / out-of-scope / success criteria); get user approval
30
+ 7. **Confirm hand-off to A2** — once approved, tell the user the next step is `to-prd` (which will write `spec/needs/<need-name>/prd.md`)
31
+
32
+ ## Process Flow
33
+
34
+ ```dot
35
+ digraph brainstorming {
36
+ "Explore project context" [shape=box];
37
+ "Ask clarifying questions" [shape=box];
38
+ "Interface/field/parameter detail?" [shape=diamond];
39
+ "Switch to grill-me\n(return here after)" [shape=box];
40
+ "Propose 2-3 approaches" [shape=box];
41
+ "Present alignment summary" [shape=box];
42
+ "User approves alignment?" [shape=diamond];
43
+ "Hand off to A2 (to-prd)" [shape=doublecircle];
44
+
45
+ "Explore project context" -> "Ask clarifying questions";
46
+ "Ask clarifying questions" -> "Interface/field/parameter detail?";
47
+ "Interface/field/parameter detail?" -> "Switch to grill-me\n(return here after)" [label="yes"];
48
+ "Interface/field/parameter detail?" -> "Propose 2-3 approaches" [label="no"];
49
+ "Switch to grill-me\n(return here after)" -> "Propose 2-3 approaches";
50
+ "Propose 2-3 approaches" -> "Present alignment summary";
51
+ "Present alignment summary" -> "User approves alignment?";
52
+ "User approves alignment?" -> "Present alignment summary" [label="no, revise"];
53
+ "User approves alignment?" -> "Hand off to A2 (to-prd)" [label="yes"];
54
+ }
55
+ ```
56
+
57
+ **The terminal state is hand-off to A2 (`to-prd`), NOT directly to implementation.** Do NOT invoke `writing-plans`, `tdd`, or any other implementation skill from here. A2 produces the `prd.md`; A3 (`writing-plans`) consumes the `prd.md` to produce `design.md`. The boundary is strict.
58
+
59
+ ## The Process
60
+
61
+ **Understanding the idea:**
62
+
63
+ - Check out the current project state first (files, docs, recent commits)
64
+ - Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
65
+ - If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
66
+ - For appropriately-scoped projects, ask questions one at a time to refine the idea
67
+ - Prefer multiple choice questions when possible, but open-ended is fine too
68
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
69
+ - Focus on understanding: purpose, constraints, success criteria
70
+
71
+ **Exploring approaches:**
72
+
73
+ - Propose 2-3 different approaches with trade-offs
74
+ - Present options conversationally with your recommendation and reasoning
75
+ - Lead with your recommended option and explain why
76
+
77
+ **Presenting the design:**
78
+
79
+ - Once you believe you understand what you're building, present the design
80
+ - Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
81
+ - Ask after each section whether it looks right so far
82
+ - Cover: architecture, components, data flow, error handling, testing
83
+ - Be ready to go back and clarify if something doesn't make sense
84
+
85
+ **Design for isolation and clarity:**
86
+
87
+ - Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
88
+ - For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
89
+ - Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
90
+ - Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.
91
+
92
+ **Working in existing codebases:**
93
+
94
+ - Explore the current structure before proposing changes. Follow existing patterns.
95
+ - Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
96
+ - Don't propose unrelated refactoring. Stay focused on what serves the current goal.
97
+
98
+ ## After Alignment
99
+
100
+ **Alignment summary (in conversation only — do NOT write a file):**
101
+
102
+ - Problem (from user's perspective)
103
+ - Proposed solution (at requirement level, not technical)
104
+ - In scope / Out of scope
105
+ - Success criteria
106
+ - Open questions (if any) — must be empty before the hard gate passes
107
+
108
+ **Quick self-check before declaring alignment:**
109
+
110
+ 1. **Placeholder scan:** Any "TBD" or vague success criteria? Sharpen them.
111
+ 2. **Scope check:** Is this a single need, or does it need decomposition into multiple needs?
112
+ 3. **Ambiguity check:** Could any requirement be interpreted two ways? Pick one explicitly.
113
+
114
+ **User approval gate:**
115
+
116
+ Present the alignment summary. Ask:
117
+
118
+ > "Does this capture what you want? If yes, the next step is `to-prd` (A2), which will write `spec/needs/<need-name>/prd.md`. If anything is off, point me at it and I'll re-align."
119
+
120
+ Wait for explicit approval. If the user requests changes, iterate. Do NOT advance to A2 until approved (HARD-GATE above).
121
+
122
+ **Hand-off to A2:**
123
+
124
+ Once approved, recommend `to-prd` as the next step. Do NOT invoke `writing-plans`, `tdd`, or any other skill. The strict chain is: A1 (brainstorming) → A2 (to-prd) → A3 (writing-plans) → A4 (to-issues) → A5 (tdd) → A6 (verification-before-completion).
125
+
126
+ ## Key Principles
127
+
128
+ - **One question at a time** - Don't overwhelm with multiple questions
129
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
130
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
131
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
132
+ - **Incremental validation** - Present design, get approval before moving on
133
+ - **Be flexible** - Go back and clarify when something doesn't make sense
@@ -1,146 +1,146 @@
1
- ---
2
- name: diagnose
3
- description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
4
- ---
5
-
6
- # Diagnose
7
-
8
- A discipline for hard bugs. Skip phases only when explicitly justified.
9
-
10
- ## Entry Gate (S1 node B3)
11
-
12
- This skill activates AFTER B2 expectation alignment has passed. Inputs:
13
-
14
- - A reproduction lead from B2 (what the user did, what they saw, what they expected)
15
- - The owning need: `spec/needs/<need-name>/{prd.md, design.md, todo.md}` (locate `<need-name>` by reading `spec/INDEX.md` or asking the user)
16
-
17
- If B2 has NOT been completed (the expected behavior is still ambiguous), STOP and run `grill-me` to re-align. Do NOT proceed to Phase 1 - diagnosing the wrong symptom is the most common B-loop failure.
18
-
19
- ## Exit Contract (hand-off to B4)
20
-
21
- After Phase 6, do NOT write the issue file inline - that is B4's job. Instead, hand off a structured summary so B4 can write `spec/needs/<need-name>/issues/<topic>.md` (`<topic>` is kebab-case) in one pass, using the 7-section format in [assets/issue-7-sections.md](assets/issue-7-sections.md).
22
-
23
- Sections this skill is expected to populate:
24
-
25
- 1. **问题描述** - from B2 + the loop's repro one-liner
26
- 2. **当前态** - observed symptom (Phase 2)
27
- 3. **期望态** - from B2
28
- 4. **分析与解决** - ranked hypotheses (Phase 3), instrumentation findings (Phase 4), root cause confirmed (Phase 5)
29
-
30
- Sections B5/B6 will roll forward later:
31
-
32
- 5. **to-issues** - follow-up tasks discovered during fix (added by B5 if any)
33
- 6. **bug** - fix progress notes (B5)
34
- 7. **验收** - user re-verification result (B6)
35
-
36
- When exploring the codebase, use vocabulary from `spec/INDEX.md` and the owning need's `prd.md` + `design.md` to get a clear mental model of the relevant modules. Check ADRs under `spec/ADR/` before forming hypotheses.
37
-
38
- ## Phase 1 — Build a feedback loop
39
-
40
- **This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
41
-
42
- Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
43
-
44
- ### Ways to construct one — try them in roughly this order
45
-
46
- 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
47
- 2. **Curl / HTTP script** against a running dev server.
48
- 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
49
- 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
50
- 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
51
- 6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
52
- 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
53
- 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
54
- 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
55
- 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
56
-
57
- Build the right feedback loop, and the bug is 90% fixed.
58
-
59
- ### Iterate on the loop itself
60
-
61
- Treat the loop as a product. Once you have _a_ loop, ask:
62
-
63
- - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
64
- - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
65
- - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
66
-
67
- A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
68
-
69
- ### Non-deterministic bugs
70
-
71
- The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
72
-
73
- ### When you genuinely cannot build a loop
74
-
75
- Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
76
-
77
- Do not proceed to Phase 2 until you have a loop you believe in.
78
-
79
- ## Phase 2 — Reproduce
80
-
81
- Run the loop. Watch the bug appear.
82
-
83
- Confirm:
84
-
85
- - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
86
- - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
87
- - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
88
-
89
- Do not proceed until you reproduce the bug.
90
-
91
- ## Phase 3 — Hypothesise
92
-
93
- Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
94
-
95
- Each hypothesis must be **falsifiable**: state the prediction it makes.
96
-
97
- > Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
98
-
99
- If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
100
-
101
- **Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
102
-
103
- ## Phase 4 — Instrument
104
-
105
- Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
106
-
107
- Tool preference:
108
-
109
- 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
110
- 2. **Targeted logs** at the boundaries that distinguish hypotheses.
111
- 3. Never "log everything and grep".
112
-
113
- **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
114
-
115
- **Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
116
-
117
- ## Phase 5 — Fix + regression test
118
-
119
- Write the regression test **before the fix** — but only if there is a **correct seam** for it.
120
-
121
- A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
122
-
123
- **If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
124
-
125
- If a correct seam exists:
126
-
127
- 1. Turn the minimised repro into a failing test at that seam.
128
- 2. Watch it fail.
129
- 3. Apply the fix.
130
- 4. Watch it pass.
131
- 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
132
-
133
- ## Phase 6 — Cleanup + post-mortem
134
-
135
- Required before declaring done:
136
-
137
- - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
138
- - [ ] Regression test passes (or absence of seam is documented)
139
- - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
140
- - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
141
- - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
142
- - [ ] Hand off to B4: emit the structured summary (sections 1-4 from the Exit Contract above) so B4 can write the issue file at `spec/needs/<need-name>/issues/<topic>.md`
143
-
144
- **Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
145
-
146
- Also hand this observation to B7 `review` for sedimentation routing first. B7 decides whether the lesson should become a `prd.md` rule, a `design.md` amendment, an ADR under `spec/ADR/`, a reusable S2 candidate, or a user-triggered `improve-codebase-architecture` follow-up. Do not invoke `improve-codebase-architecture` directly from B3; make the architectural-change recommendation and let B7/user decide whether to schedule it.
1
+ ---
2
+ name: diagnose
3
+ description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
4
+ ---
5
+
6
+ # Diagnose
7
+
8
+ A discipline for hard bugs. Skip phases only when explicitly justified.
9
+
10
+ ## Entry Gate (S1 node B3)
11
+
12
+ This skill activates AFTER B2 expectation alignment has passed. Inputs:
13
+
14
+ - A reproduction lead from B2 (what the user did, what they saw, what they expected)
15
+ - The owning need: `spec/needs/<need-name>/{prd.md, design.md, todo.md}` (locate `<need-name>` by reading `spec/INDEX.md` or asking the user)
16
+
17
+ If B2 has NOT been completed (the expected behavior is still ambiguous), STOP and run `grill-me` to re-align. Do NOT proceed to Phase 1 - diagnosing the wrong symptom is the most common B-loop failure.
18
+
19
+ ## Exit Contract (hand-off to B4)
20
+
21
+ After Phase 6, do NOT write the issue file inline - that is B4's job. Instead, hand off a structured summary so B4 can write `spec/needs/<need-name>/issues/<topic>.md` (`<topic>` is kebab-case) in one pass, using the 7-section format in [assets/issue-7-sections.md](assets/issue-7-sections.md).
22
+
23
+ Sections this skill is expected to populate:
24
+
25
+ 1. **问题描述** - from B2 + the loop's repro one-liner
26
+ 2. **当前态** - observed symptom (Phase 2)
27
+ 3. **期望态** - from B2
28
+ 4. **分析与解决** - ranked hypotheses (Phase 3), instrumentation findings (Phase 4), root cause confirmed (Phase 5)
29
+
30
+ Sections B5/B6 will roll forward later:
31
+
32
+ 5. **to-issues** - follow-up tasks discovered during fix (added by B5 if any)
33
+ 6. **bug** - fix progress notes (B5)
34
+ 7. **验收** - user re-verification result (B6)
35
+
36
+ When exploring the codebase, use vocabulary from `spec/INDEX.md` and the owning need's `prd.md` + `design.md` to get a clear mental model of the relevant modules. Check ADRs under `spec/ADR/` before forming hypotheses.
37
+
38
+ ## Phase 1 — Build a feedback loop
39
+
40
+ **This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
41
+
42
+ Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
43
+
44
+ ### Ways to construct one — try them in roughly this order
45
+
46
+ 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
47
+ 2. **Curl / HTTP script** against a running dev server.
48
+ 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
49
+ 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
50
+ 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
51
+ 6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
52
+ 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
53
+ 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
54
+ 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
55
+ 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
56
+
57
+ Build the right feedback loop, and the bug is 90% fixed.
58
+
59
+ ### Iterate on the loop itself
60
+
61
+ Treat the loop as a product. Once you have _a_ loop, ask:
62
+
63
+ - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
64
+ - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
65
+ - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
66
+
67
+ A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
68
+
69
+ ### Non-deterministic bugs
70
+
71
+ The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
72
+
73
+ ### When you genuinely cannot build a loop
74
+
75
+ Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
76
+
77
+ Do not proceed to Phase 2 until you have a loop you believe in.
78
+
79
+ ## Phase 2 — Reproduce
80
+
81
+ Run the loop. Watch the bug appear.
82
+
83
+ Confirm:
84
+
85
+ - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
86
+ - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
87
+ - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
88
+
89
+ Do not proceed until you reproduce the bug.
90
+
91
+ ## Phase 3 — Hypothesise
92
+
93
+ Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
94
+
95
+ Each hypothesis must be **falsifiable**: state the prediction it makes.
96
+
97
+ > Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
98
+
99
+ If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
100
+
101
+ **Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
102
+
103
+ ## Phase 4 — Instrument
104
+
105
+ Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
106
+
107
+ Tool preference:
108
+
109
+ 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
110
+ 2. **Targeted logs** at the boundaries that distinguish hypotheses.
111
+ 3. Never "log everything and grep".
112
+
113
+ **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
114
+
115
+ **Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
116
+
117
+ ## Phase 5 — Fix + regression test
118
+
119
+ Write the regression test **before the fix** — but only if there is a **correct seam** for it.
120
+
121
+ A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
122
+
123
+ **If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
124
+
125
+ If a correct seam exists:
126
+
127
+ 1. Turn the minimised repro into a failing test at that seam.
128
+ 2. Watch it fail.
129
+ 3. Apply the fix.
130
+ 4. Watch it pass.
131
+ 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
132
+
133
+ ## Phase 6 — Cleanup + post-mortem
134
+
135
+ Required before declaring done:
136
+
137
+ - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
138
+ - [ ] Regression test passes (or absence of seam is documented)
139
+ - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
140
+ - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
141
+ - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
142
+ - [ ] Hand off to B4: emit the structured summary (sections 1-4 from the Exit Contract above) so B4 can write the issue file at `spec/needs/<need-name>/issues/<topic>.md`
143
+
144
+ **Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
145
+
146
+ Also hand this observation to B7 `review` for sedimentation routing first. B7 decides whether the lesson should become a `prd.md` rule, a `design.md` amendment, an ADR under `spec/ADR/`, a reusable S2 candidate, or a user-triggered `improve-codebase-architecture` follow-up. Do not invoke `improve-codebase-architecture` directly from B3; make the architectural-change recommendation and let B7/user decide whether to schedule it.
@@ -1,35 +1,35 @@
1
- # Issue 7-Section Template
2
-
3
- Use this template at B4 to write `spec/needs/<need-name>/issues/<topic>.md`.
4
-
5
- ```markdown
6
- # <issue title>
7
-
8
- ## 问题描述
9
-
10
- <From B2 expectation alignment + B3 reproduction one-liner.>
11
-
12
- ## 当前态
13
-
14
- <Observed symptom, exact error/output/timing, reproduction confidence.>
15
-
16
- ## 期望态
17
-
18
- <Expected behavior aligned with the user at B2.>
19
-
20
- ## 分析与解决
21
-
22
- <Ranked hypotheses, instrumentation findings, confirmed root cause, and fix direction.>
23
-
24
- ## to-issues
25
-
26
- <Follow-up implementation tasks discovered during B5, if any. Leave empty at B4 if none.>
27
-
28
- ## bug
29
-
30
- <B5 fix progress notes: failing test, root-cause one-liner, fix commit/reference.>
31
-
32
- ## 验收
33
-
34
- <B6 user re-verification result.>
35
- ```
1
+ # Issue 7-Section Template
2
+
3
+ Use this template at B4 to write `spec/needs/<need-name>/issues/<topic>.md`.
4
+
5
+ ```markdown
6
+ # <issue title>
7
+
8
+ ## 问题描述
9
+
10
+ <From B2 expectation alignment + B3 reproduction one-liner.>
11
+
12
+ ## 当前态
13
+
14
+ <Observed symptom, exact error/output/timing, reproduction confidence.>
15
+
16
+ ## 期望态
17
+
18
+ <Expected behavior aligned with the user at B2.>
19
+
20
+ ## 分析与解决
21
+
22
+ <Ranked hypotheses, instrumentation findings, confirmed root cause, and fix direction.>
23
+
24
+ ## to-issues
25
+
26
+ <Follow-up implementation tasks discovered during B5, if any. Leave empty at B4 if none.>
27
+
28
+ ## bug
29
+
30
+ <B5 fix progress notes: failing test, root-cause one-liner, fix commit/reference.>
31
+
32
+ ## 验收
33
+
34
+ <B6 user re-verification result.>
35
+ ```