@ecc-hgy/ae 0.5.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.
- package/LICENSE +21 -21
- package/README.md +168 -155
- package/bin/ae.js +2 -2
- package/package.json +43 -43
- package/skills/brainstorming/SKILL.md +133 -133
- package/skills/diagnose/SKILL.md +146 -146
- package/skills/diagnose/assets/issue-7-sections.md +35 -35
- package/skills/diagnose/scripts/hitl-loop.template.sh +41 -41
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/handoff/SKILL.md +19 -19
- package/skills/improve-codebase-architecture/DEEPENING.md +37 -37
- package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -123
- package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -44
- package/skills/improve-codebase-architecture/LANGUAGE.md +53 -53
- package/skills/improve-codebase-architecture/SKILL.md +101 -101
- package/skills/karpathy-guidelines/SKILL.md +63 -63
- package/skills/powerautomate-email-to-sharepoint-excel/powerautomate-email-to-sharepoint-excel-skill.md +496 -496
- package/skills/review/SKILL.md +119 -119
- package/skills/tdd/SKILL.md +157 -157
- package/skills/tdd/deep-modules.md +33 -33
- package/skills/tdd/interface-design.md +31 -31
- package/skills/tdd/mocking.md +59 -59
- package/skills/tdd/refactoring.md +10 -10
- package/skills/tdd/tests.md +61 -61
- package/skills/to-issues/SKILL.md +79 -79
- package/skills/to-issues/todo-template.md +25 -25
- package/skills/to-prd/SKILL.md +108 -108
- package/skills/using-agentic-engineering/SKILL.md +62 -62
- package/skills/verification-before-completion/SKILL.md +153 -153
- package/skills/writing-plans/SKILL.md +115 -115
- package/skills/zoom-out/SKILL.md +7 -7
- package/src/cli.js +61 -61
- package/src/commands/init.js +137 -137
- package/src/commands/setup.js +162 -162
- package/src/platforms.js +132 -132
- package/src/skeleton.js +134 -99
- package/src/utils/copy.js +100 -100
- package/src/utils/paths.js +60 -60
- package/src/utils/report.js +30 -30
- package/templates/entries/AGENTS.md +2 -0
- package/templates/entries/CLAUDE.md +5 -5
- package/templates/entries/README.md +33 -31
- package/templates/entries/handoff.md +1 -1
- package/templates/entries/spec/ADR/AGENTS.md +30 -30
- package/templates/entries/spec/ADR/CLAUDE.md +5 -5
- package/templates/entries/spec/AGENTS.md +34 -34
- package/templates/entries/spec/CLAUDE.md +5 -5
- package/templates/entries/spec/INDEX.md +28 -28
- package/templates/entries/spec/README.md +23 -23
package/skills/review/SKILL.md
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: review
|
|
3
|
-
description: Two-axis review (Standards / Spec) of the changes for a need that is about to close, followed by sedimentation routing - review findings flow into prd.md / design.md / spec/ADR/ / S2 candidates per `spec/AGENTS.md`. Used at S1 node B7.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Review
|
|
7
|
-
|
|
8
|
-
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
|
|
9
|
-
|
|
10
|
-
- **Standards** - does the code conform to this repo's documented coding standards?
|
|
11
|
-
- **Spec** - does the code faithfully implement the originating need?
|
|
12
|
-
|
|
13
|
-
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
|
|
14
|
-
|
|
15
|
-
## Entry (S1 node B7)
|
|
16
|
-
|
|
17
|
-
Invoke this skill when a need is about to close - typically after B6 user re-verification passes. Inputs:
|
|
18
|
-
|
|
19
|
-
- The owning need: `spec/needs/<need-name>/` (must contain `prd.md`, `design.md`, `todo.md`, and at least one `issues/*.md` if this close was preceded by a B-loop)
|
|
20
|
-
- The fixed point: the git commit at which work on this need started (merge-base with `main`, or the user's specified SHA)
|
|
21
|
-
- `spec/INDEX.md` (to confirm the need-name and to update afterward)
|
|
22
|
-
|
|
23
|
-
## Process
|
|
24
|
-
|
|
25
|
-
### 1. Pin the fixed point
|
|
26
|
-
|
|
27
|
-
Whatever the user said is the fixed point - a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. Don't be opinionated; pass it through. If they didn't specify one, ask: "Review against what - a branch, a commit, or `main`?" Don't proceed until you have it.
|
|
28
|
-
|
|
29
|
-
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
|
|
30
|
-
|
|
31
|
-
### 2. Identify the spec source
|
|
32
|
-
|
|
33
|
-
The spec is fixed by the need-name (resolved from the user's input, the active branch, or `spec/INDEX.md`'s `当前节点` column). Read these files in order:
|
|
34
|
-
|
|
35
|
-
1. `spec/needs/<need-name>/prd.md` - WHAT and WHY (acceptance criteria)
|
|
36
|
-
2. `spec/needs/<need-name>/design.md` - HOW (decisions and trade-offs)
|
|
37
|
-
3. `spec/needs/<need-name>/todo.md` - execution checklist (rolling)
|
|
38
|
-
4. `spec/needs/<need-name>/issues/*.md` - any B-loop issue files for this close
|
|
39
|
-
|
|
40
|
-
Do NOT search `docs/`, `specs/`, `.scratch/`, or commit-message issue references - the contract is: this project always uses `spec/needs/<need-name>/`. If `<need-name>` cannot be determined, STOP and ask the user.
|
|
41
|
-
|
|
42
|
-
### 3. Identify the standards sources
|
|
43
|
-
|
|
44
|
-
Anything in the repo that documents how code should be written. For this project's spec layout, the canonical sources are:
|
|
45
|
-
|
|
46
|
-
- `AGENTS.md`, `CLAUDE.md` (entry rules + R1 - mirrored content)
|
|
47
|
-
- `spec/README.md` (project map; rarely contains rules but read for context)
|
|
48
|
-
- `spec/INDEX.md` (need + ADR index; the `当前节点` and `related-needs` columns reveal cross-need coupling)
|
|
49
|
-
- `spec/ADR/*.md` (architectural decisions are standards; treat `status: accepted` as binding)
|
|
50
|
-
- `CONTRIBUTING.md` (if present at repo root)
|
|
51
|
-
- `.editorconfig`, `eslint.config.*`, `biome.json`, `prettier.config.*`, `tsconfig.json`, `ruff.toml`, etc. (machine-enforced - note them but don't re-check what tooling already checks)
|
|
52
|
-
- Any `STYLE.md`, `STANDARDS.md`, `STYLEGUIDE.md` at the repo root or under `spec/`
|
|
53
|
-
|
|
54
|
-
Do NOT look under `docs/adr/`, `CONTEXT.md`, or `CONTEXT-MAP.md` - this project uses `spec/ADR/` and the INDEX/README split instead.
|
|
55
|
-
|
|
56
|
-
Collect the list of files. The **Standards** sub-agent will read them.
|
|
57
|
-
|
|
58
|
-
### 4. Spawn both sub-agents in parallel
|
|
59
|
-
|
|
60
|
-
Send a single message with two `Agent` tool calls. Use the `general-purpose` subagent for both.
|
|
61
|
-
|
|
62
|
-
**Standards sub-agent prompt** - include:
|
|
63
|
-
|
|
64
|
-
- The full diff command and commit list.
|
|
65
|
-
- The list of standards-source files you found in step 3.
|
|
66
|
-
- The brief: "Read the standards docs. Then read the diff. Report - per file/hunk where relevant - every place the diff violates a documented standard. Cite the standard (file + the rule). Distinguish hard violations from judgement calls. Skip anything tooling enforces. Under 400 words."
|
|
67
|
-
|
|
68
|
-
**Spec sub-agent prompt** - include:
|
|
69
|
-
|
|
70
|
-
- The diff command and commit list.
|
|
71
|
-
- The path or fetched contents of the spec.
|
|
72
|
-
- The brief: "Read the spec. Then read the diff. Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
|
|
73
|
-
|
|
74
|
-
If the spec is missing, skip the Spec sub-agent and note this in the final report.
|
|
75
|
-
|
|
76
|
-
### 5. Aggregate
|
|
77
|
-
|
|
78
|
-
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings - the two axes are deliberately separate so the user can see them independently.
|
|
79
|
-
|
|
80
|
-
End with a one-line summary: total findings per axis, and the worst single issue (if any) flagged.
|
|
81
|
-
|
|
82
|
-
### 6. Sediment (sedimentation routing)
|
|
83
|
-
|
|
84
|
-
This step is what makes review a B7 skill and not a generic PR review. After Aggregate, walk through every finding from BOTH axes and route each one of four ways. Show the user a routing plan; only execute after approval.
|
|
85
|
-
|
|
86
|
-
| Finding type | Routing target | What to write |
|
|
87
|
-
|---|---|---|
|
|
88
|
-
| **Business rule** (spec said WHAT was wrong, or B-loop surfaced an unstated rule) | `spec/needs/<need-name>/prd.md` | Patch the relevant section; bump `last-aligned: <today>`; keep `status: active` |
|
|
89
|
-
| **Local technical decision** (affects ONLY this need) | `spec/needs/<need-name>/design.md` | Patch the relevant section; bump `last-aligned`; keep `status: active` |
|
|
90
|
-
| **Cross-need decision** (affects 2+ needs, or a project-wide invariant) | New `spec/ADR/NNNN-<title>.md` | New ADR with `status: proposed` (NOT accepted - user decides in a separate pass). In affected `design.md` files, add a reference and prune the local version of the decision. |
|
|
91
|
-
| **Reusable method / pattern** (not project-specific knowledge) | Handoff proposal (NOT this skill) | Add a single line under "S2 candidates" in `handoff.md` (or surface it for the next `handoff` skill run). Do NOT create a skill file here - promotion is user-confirmed at S2. |
|
|
92
|
-
|
|
93
|
-
After routing:
|
|
94
|
-
|
|
95
|
-
1. Update `spec/INDEX.md`:
|
|
96
|
-
- Set every `issues/*.md` referenced in this close to "已验收"
|
|
97
|
-
- If any `prd.md` / `design.md` was patched, leave `status: active` and refresh `last-aligned`
|
|
98
|
-
- If a new ADR was created, add a row under `## ADR` with `status: proposed`
|
|
99
|
-
- If unsure, run `ae index-rebuild`
|
|
100
|
-
2. Print a one-block summary to the user:
|
|
101
|
-
- Findings routed to prd / design / ADR / S2-candidates with counts
|
|
102
|
-
- Files modified (path list)
|
|
103
|
-
- Suggested next action: close the need (mark all relevant files appropriately) or open a fresh A1 alignment for the new ADR proposals
|
|
104
|
-
|
|
105
|
-
## Boundaries
|
|
106
|
-
|
|
107
|
-
- This skill READS the diff and need files, WRITES patches to `prd.md` / `design.md`, NEW files in `spec/ADR/`, and ONE INDEX update.
|
|
108
|
-
- It does NOT close or archive `prd.md` / `design.md` - `archived` is reserved for need-level lifecycle, not B7.
|
|
109
|
-
- It does NOT promote rules into reusable skills - S2 promotion is user-confirmed in a separate pass.
|
|
110
|
-
- It does NOT invoke `improve-codebase-architecture` directly - that skill is user-triggered; B7 findings can list it as a suggested follow-up but do not call it.
|
|
111
|
-
|
|
112
|
-
## Why two axes
|
|
113
|
-
|
|
114
|
-
A change can pass one axis and fail the other:
|
|
115
|
-
|
|
116
|
-
- Code that follows every standard but implements the wrong thing -> **Standards pass, Spec fail.**
|
|
117
|
-
- Code that does exactly what the issue asked but breaks the project's conventions -> **Spec pass, Standards fail.**
|
|
118
|
-
|
|
119
|
-
Reporting them separately stops one axis from masking the other.
|
|
1
|
+
---
|
|
2
|
+
name: review
|
|
3
|
+
description: Two-axis review (Standards / Spec) of the changes for a need that is about to close, followed by sedimentation routing - review findings flow into prd.md / design.md / spec/ADR/ / S2 candidates per `spec/AGENTS.md`. Used at S1 node B7.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Review
|
|
7
|
+
|
|
8
|
+
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
|
|
9
|
+
|
|
10
|
+
- **Standards** - does the code conform to this repo's documented coding standards?
|
|
11
|
+
- **Spec** - does the code faithfully implement the originating need?
|
|
12
|
+
|
|
13
|
+
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
|
|
14
|
+
|
|
15
|
+
## Entry (S1 node B7)
|
|
16
|
+
|
|
17
|
+
Invoke this skill when a need is about to close - typically after B6 user re-verification passes. Inputs:
|
|
18
|
+
|
|
19
|
+
- The owning need: `spec/needs/<need-name>/` (must contain `prd.md`, `design.md`, `todo.md`, and at least one `issues/*.md` if this close was preceded by a B-loop)
|
|
20
|
+
- The fixed point: the git commit at which work on this need started (merge-base with `main`, or the user's specified SHA)
|
|
21
|
+
- `spec/INDEX.md` (to confirm the need-name and to update afterward)
|
|
22
|
+
|
|
23
|
+
## Process
|
|
24
|
+
|
|
25
|
+
### 1. Pin the fixed point
|
|
26
|
+
|
|
27
|
+
Whatever the user said is the fixed point - a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. Don't be opinionated; pass it through. If they didn't specify one, ask: "Review against what - a branch, a commit, or `main`?" Don't proceed until you have it.
|
|
28
|
+
|
|
29
|
+
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
|
|
30
|
+
|
|
31
|
+
### 2. Identify the spec source
|
|
32
|
+
|
|
33
|
+
The spec is fixed by the need-name (resolved from the user's input, the active branch, or `spec/INDEX.md`'s `当前节点` column). Read these files in order:
|
|
34
|
+
|
|
35
|
+
1. `spec/needs/<need-name>/prd.md` - WHAT and WHY (acceptance criteria)
|
|
36
|
+
2. `spec/needs/<need-name>/design.md` - HOW (decisions and trade-offs)
|
|
37
|
+
3. `spec/needs/<need-name>/todo.md` - execution checklist (rolling)
|
|
38
|
+
4. `spec/needs/<need-name>/issues/*.md` - any B-loop issue files for this close
|
|
39
|
+
|
|
40
|
+
Do NOT search `docs/`, `specs/`, `.scratch/`, or commit-message issue references - the contract is: this project always uses `spec/needs/<need-name>/`. If `<need-name>` cannot be determined, STOP and ask the user.
|
|
41
|
+
|
|
42
|
+
### 3. Identify the standards sources
|
|
43
|
+
|
|
44
|
+
Anything in the repo that documents how code should be written. For this project's spec layout, the canonical sources are:
|
|
45
|
+
|
|
46
|
+
- `AGENTS.md`, `CLAUDE.md` (entry rules + R1 - mirrored content)
|
|
47
|
+
- `spec/README.md` (project map; rarely contains rules but read for context)
|
|
48
|
+
- `spec/INDEX.md` (need + ADR index; the `当前节点` and `related-needs` columns reveal cross-need coupling)
|
|
49
|
+
- `spec/ADR/*.md` (architectural decisions are standards; treat `status: accepted` as binding)
|
|
50
|
+
- `CONTRIBUTING.md` (if present at repo root)
|
|
51
|
+
- `.editorconfig`, `eslint.config.*`, `biome.json`, `prettier.config.*`, `tsconfig.json`, `ruff.toml`, etc. (machine-enforced - note them but don't re-check what tooling already checks)
|
|
52
|
+
- Any `STYLE.md`, `STANDARDS.md`, `STYLEGUIDE.md` at the repo root or under `spec/`
|
|
53
|
+
|
|
54
|
+
Do NOT look under `docs/adr/`, `CONTEXT.md`, or `CONTEXT-MAP.md` - this project uses `spec/ADR/` and the INDEX/README split instead.
|
|
55
|
+
|
|
56
|
+
Collect the list of files. The **Standards** sub-agent will read them.
|
|
57
|
+
|
|
58
|
+
### 4. Spawn both sub-agents in parallel
|
|
59
|
+
|
|
60
|
+
Send a single message with two `Agent` tool calls. Use the `general-purpose` subagent for both.
|
|
61
|
+
|
|
62
|
+
**Standards sub-agent prompt** - include:
|
|
63
|
+
|
|
64
|
+
- The full diff command and commit list.
|
|
65
|
+
- The list of standards-source files you found in step 3.
|
|
66
|
+
- The brief: "Read the standards docs. Then read the diff. Report - per file/hunk where relevant - every place the diff violates a documented standard. Cite the standard (file + the rule). Distinguish hard violations from judgement calls. Skip anything tooling enforces. Under 400 words."
|
|
67
|
+
|
|
68
|
+
**Spec sub-agent prompt** - include:
|
|
69
|
+
|
|
70
|
+
- The diff command and commit list.
|
|
71
|
+
- The path or fetched contents of the spec.
|
|
72
|
+
- The brief: "Read the spec. Then read the diff. Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
|
|
73
|
+
|
|
74
|
+
If the spec is missing, skip the Spec sub-agent and note this in the final report.
|
|
75
|
+
|
|
76
|
+
### 5. Aggregate
|
|
77
|
+
|
|
78
|
+
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings - the two axes are deliberately separate so the user can see them independently.
|
|
79
|
+
|
|
80
|
+
End with a one-line summary: total findings per axis, and the worst single issue (if any) flagged.
|
|
81
|
+
|
|
82
|
+
### 6. Sediment (sedimentation routing)
|
|
83
|
+
|
|
84
|
+
This step is what makes review a B7 skill and not a generic PR review. After Aggregate, walk through every finding from BOTH axes and route each one of four ways. Show the user a routing plan; only execute after approval.
|
|
85
|
+
|
|
86
|
+
| Finding type | Routing target | What to write |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| **Business rule** (spec said WHAT was wrong, or B-loop surfaced an unstated rule) | `spec/needs/<need-name>/prd.md` | Patch the relevant section; bump `last-aligned: <today>`; keep `status: active` |
|
|
89
|
+
| **Local technical decision** (affects ONLY this need) | `spec/needs/<need-name>/design.md` | Patch the relevant section; bump `last-aligned`; keep `status: active` |
|
|
90
|
+
| **Cross-need decision** (affects 2+ needs, or a project-wide invariant) | New `spec/ADR/NNNN-<title>.md` | New ADR with `status: proposed` (NOT accepted - user decides in a separate pass). In affected `design.md` files, add a reference and prune the local version of the decision. |
|
|
91
|
+
| **Reusable method / pattern** (not project-specific knowledge) | Handoff proposal (NOT this skill) | Add a single line under "S2 candidates" in `handoff.md` (or surface it for the next `handoff` skill run). Do NOT create a skill file here - promotion is user-confirmed at S2. |
|
|
92
|
+
|
|
93
|
+
After routing:
|
|
94
|
+
|
|
95
|
+
1. Update `spec/INDEX.md`:
|
|
96
|
+
- Set every `issues/*.md` referenced in this close to "已验收"
|
|
97
|
+
- If any `prd.md` / `design.md` was patched, leave `status: active` and refresh `last-aligned`
|
|
98
|
+
- If a new ADR was created, add a row under `## ADR` with `status: proposed`
|
|
99
|
+
- If unsure, run `ae index-rebuild`
|
|
100
|
+
2. Print a one-block summary to the user:
|
|
101
|
+
- Findings routed to prd / design / ADR / S2-candidates with counts
|
|
102
|
+
- Files modified (path list)
|
|
103
|
+
- Suggested next action: close the need (mark all relevant files appropriately) or open a fresh A1 alignment for the new ADR proposals
|
|
104
|
+
|
|
105
|
+
## Boundaries
|
|
106
|
+
|
|
107
|
+
- This skill READS the diff and need files, WRITES patches to `prd.md` / `design.md`, NEW files in `spec/ADR/`, and ONE INDEX update.
|
|
108
|
+
- It does NOT close or archive `prd.md` / `design.md` - `archived` is reserved for need-level lifecycle, not B7.
|
|
109
|
+
- It does NOT promote rules into reusable skills - S2 promotion is user-confirmed in a separate pass.
|
|
110
|
+
- It does NOT invoke `improve-codebase-architecture` directly - that skill is user-triggered; B7 findings can list it as a suggested follow-up but do not call it.
|
|
111
|
+
|
|
112
|
+
## Why two axes
|
|
113
|
+
|
|
114
|
+
A change can pass one axis and fail the other:
|
|
115
|
+
|
|
116
|
+
- Code that follows every standard but implements the wrong thing -> **Standards pass, Spec fail.**
|
|
117
|
+
- Code that does exactly what the issue asked but breaks the project's conventions -> **Spec pass, Standards fail.**
|
|
118
|
+
|
|
119
|
+
Reporting them separately stops one axis from masking the other.
|
package/skills/tdd/SKILL.md
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: tdd
|
|
3
|
-
description: Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Test-Driven Development
|
|
7
|
-
|
|
8
|
-
## Inputs (S1 nodes A5 / B5)
|
|
9
|
-
|
|
10
|
-
This skill operates on a single need. Read the following before starting any cycle:
|
|
11
|
-
|
|
12
|
-
- `spec/needs/<need-name>/design.md` - the HOW (modules, interfaces, key trade-offs); test names and the public interfaces under test SHOULD match its vocabulary
|
|
13
|
-
- `spec/needs/<need-name>/todo.md` - the rolling task list produced by A4 `to-issues`; pick the next unchecked `## 实施` item, top-down
|
|
14
|
-
- `spec/INDEX.md` - domain vocabulary; cross-need ADRs at `spec/ADR/`
|
|
15
|
-
|
|
16
|
-
## Hard Constraints
|
|
17
|
-
|
|
18
|
-
- **No scope smuggling.** Do NOT implement anything not present in `design.md`. If the current `todo.md` item requires behavior the design did not anticipate, STOP, go back to A3 (`writing-plans`) to patch `design.md`, then resume here.
|
|
19
|
-
- **One slice at a time.** Pick a single `- [ ]` item from `## 实施`, complete the full red -> green -> refactor cycle for it, mark it `- [x]`, then move to the next. Do not batch.
|
|
20
|
-
- **End-to-end verification is A6's job, not A5's.** This skill's exit criterion is "all `## 实施` items checked + tests green at the slice seam". Real-user-path verification happens in A6 `verification-before-completion`.
|
|
21
|
-
|
|
22
|
-
## Two Modes
|
|
23
|
-
|
|
24
|
-
| Mode | When | Output |
|
|
25
|
-
|------|------|--------|
|
|
26
|
-
| **A5 (development)** | Driven by `todo.md` after a fresh need passes A4 | Roll `todo.md` forward; mark items `- [x]` as each cycle completes |
|
|
27
|
-
| **B5 (fix)** | Driven by an existing `spec/needs/<need-name>/issues/<topic>.md` after B3 diagnose | Apply the fix per the root cause; `todo.md` is NOT touched (it was already fully checked when the bug surfaced). Append progress notes to the issue file's `## bug` section instead. |
|
|
28
|
-
|
|
29
|
-
## Philosophy
|
|
30
|
-
|
|
31
|
-
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
|
32
|
-
|
|
33
|
-
**Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
|
|
34
|
-
|
|
35
|
-
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
|
|
36
|
-
|
|
37
|
-
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
|
38
|
-
|
|
39
|
-
## Anti-Pattern: Horizontal Slices
|
|
40
|
-
|
|
41
|
-
**DO NOT write all tests first, then all implementation.** This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
|
|
42
|
-
|
|
43
|
-
This produces **crap tests**:
|
|
44
|
-
|
|
45
|
-
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
|
46
|
-
- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
|
|
47
|
-
- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
|
|
48
|
-
- You outrun your headlights, committing to test structure before understanding the implementation
|
|
49
|
-
|
|
50
|
-
**Correct approach**: Vertical slices via tracer bullets. One test -> one implementation -> repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
WRONG (horizontal):
|
|
54
|
-
RED: test1, test2, test3, test4, test5
|
|
55
|
-
GREEN: impl1, impl2, impl3, impl4, impl5
|
|
56
|
-
|
|
57
|
-
RIGHT (vertical):
|
|
58
|
-
RED->GREEN: test1->impl1
|
|
59
|
-
RED->GREEN: test2->impl2
|
|
60
|
-
RED->GREEN: test3->impl3
|
|
61
|
-
...
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Workflow
|
|
65
|
-
|
|
66
|
-
### 1. Planning
|
|
67
|
-
|
|
68
|
-
When exploring the codebase, use vocabulary from `spec/INDEX.md` and the current need's `design.md` so that test names and interface vocabulary match the project's language. Respect ADRs under `spec/ADR/`.
|
|
69
|
-
|
|
70
|
-
Before writing any code for the current slice:
|
|
71
|
-
|
|
72
|
-
- [ ] Read the `## 实施` item being implemented; confirm it traces to a section in `design.md`
|
|
73
|
-
- [ ] Confirm with user (or re-read `design.md`) what interface changes the slice requires
|
|
74
|
-
- [ ] Confirm which behaviors to test (prioritize per slice acceptance criteria)
|
|
75
|
-
- [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
|
|
76
|
-
- [ ] Design interfaces for [testability](interface-design.md)
|
|
77
|
-
- [ ] List the behaviors to test (not implementation steps)
|
|
78
|
-
- [ ] If `design.md` needs amendment (new behavior surfaced), STOP and go back to A3
|
|
79
|
-
|
|
80
|
-
Ask: "What should the public interface look like? Which behaviors are most important to test?"
|
|
81
|
-
|
|
82
|
-
**You can't test everything.** Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
|
|
83
|
-
|
|
84
|
-
### 2. Tracer Bullet
|
|
85
|
-
|
|
86
|
-
Write ONE test that confirms ONE thing about the system:
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
RED: Write test for first behavior -> test fails
|
|
90
|
-
GREEN: Write minimal code to pass -> test passes
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
This is your tracer bullet - proves the path works end-to-end.
|
|
94
|
-
|
|
95
|
-
### 3. Incremental Loop
|
|
96
|
-
|
|
97
|
-
For each remaining behavior:
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
RED: Write next test -> fails
|
|
101
|
-
GREEN: Minimal code to pass -> passes
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Rules:
|
|
105
|
-
|
|
106
|
-
- One test at a time
|
|
107
|
-
- Only enough code to pass current test
|
|
108
|
-
- Don't anticipate future tests
|
|
109
|
-
- Keep tests focused on observable behavior
|
|
110
|
-
|
|
111
|
-
### 4. Refactor
|
|
112
|
-
|
|
113
|
-
After all tests pass, look for [refactor candidates](refactoring.md):
|
|
114
|
-
|
|
115
|
-
- [ ] Extract duplication
|
|
116
|
-
- [ ] Deepen modules (move complexity behind simple interfaces)
|
|
117
|
-
- [ ] Apply SOLID principles where natural
|
|
118
|
-
- [ ] Consider what new code reveals about existing code
|
|
119
|
-
- [ ] Run tests after each refactor step
|
|
120
|
-
|
|
121
|
-
**Never refactor while RED.** Get to GREEN first.
|
|
122
|
-
|
|
123
|
-
## Checklist Per Cycle
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
[ ] Test describes behavior, not implementation
|
|
127
|
-
[ ] Test uses public interface only
|
|
128
|
-
[ ] Test would survive internal refactor
|
|
129
|
-
[ ] Code is minimal for this test
|
|
130
|
-
[ ] No speculative features added
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## After Each Slice (A5)
|
|
134
|
-
|
|
135
|
-
1. Tick the corresponding `- [ ]` -> `- [x]` in `spec/needs/<need-name>/todo.md`
|
|
136
|
-
2. Update `spec/INDEX.md`:
|
|
137
|
-
- Bump the `todo` column counter (e.g. `2/8` -> `3/8`)
|
|
138
|
-
- If all `## 实施` items are now checked, set `当前节点` to `A6 verify` (per `spec/AGENTS.md` INDEX rules)
|
|
139
|
-
- If unsure, run `ae index-rebuild`
|
|
140
|
-
3. Commit. Suggested message: `feat(<need-name>): T<n> <title>`.
|
|
141
|
-
|
|
142
|
-
## After All Slices Checked (A5 only)
|
|
143
|
-
|
|
144
|
-
Hand off to A6 `verification-before-completion` for end-to-end verification on the real user path. This skill's job ends when `todo.md` is fully checked AND slice-level tests are green.
|
|
145
|
-
|
|
146
|
-
## After Fix Lands (B5 only)
|
|
147
|
-
|
|
148
|
-
1. Do NOT modify `todo.md` (it was fully checked before the bug surfaced).
|
|
149
|
-
2. Append a short progress note under the issue file's `## bug` section (the 7-section format produced at B4). Quote the failing test name and the root-cause one-liner.
|
|
150
|
-
3. Commit. Suggested message: `fix(<need-name>): <root cause summary>`.
|
|
151
|
-
4. Hand off to B6 user re-verification.
|
|
152
|
-
|
|
153
|
-
## Boundaries
|
|
154
|
-
|
|
155
|
-
- This skill writes code and tests, plus updates `todo.md` (A5) or the issue file's `## bug` section (B5).
|
|
156
|
-
- It does NOT write `prd.md`, `design.md`, or new ADRs. Scope changes go back through A3.
|
|
157
|
-
- It does NOT perform end-to-end / user-path verification - that is A6.
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
description: Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development
|
|
7
|
+
|
|
8
|
+
## Inputs (S1 nodes A5 / B5)
|
|
9
|
+
|
|
10
|
+
This skill operates on a single need. Read the following before starting any cycle:
|
|
11
|
+
|
|
12
|
+
- `spec/needs/<need-name>/design.md` - the HOW (modules, interfaces, key trade-offs); test names and the public interfaces under test SHOULD match its vocabulary
|
|
13
|
+
- `spec/needs/<need-name>/todo.md` - the rolling task list produced by A4 `to-issues`; pick the next unchecked `## 实施` item, top-down
|
|
14
|
+
- `spec/INDEX.md` - domain vocabulary; cross-need ADRs at `spec/ADR/`
|
|
15
|
+
|
|
16
|
+
## Hard Constraints
|
|
17
|
+
|
|
18
|
+
- **No scope smuggling.** Do NOT implement anything not present in `design.md`. If the current `todo.md` item requires behavior the design did not anticipate, STOP, go back to A3 (`writing-plans`) to patch `design.md`, then resume here.
|
|
19
|
+
- **One slice at a time.** Pick a single `- [ ]` item from `## 实施`, complete the full red -> green -> refactor cycle for it, mark it `- [x]`, then move to the next. Do not batch.
|
|
20
|
+
- **End-to-end verification is A6's job, not A5's.** This skill's exit criterion is "all `## 实施` items checked + tests green at the slice seam". Real-user-path verification happens in A6 `verification-before-completion`.
|
|
21
|
+
|
|
22
|
+
## Two Modes
|
|
23
|
+
|
|
24
|
+
| Mode | When | Output |
|
|
25
|
+
|------|------|--------|
|
|
26
|
+
| **A5 (development)** | Driven by `todo.md` after a fresh need passes A4 | Roll `todo.md` forward; mark items `- [x]` as each cycle completes |
|
|
27
|
+
| **B5 (fix)** | Driven by an existing `spec/needs/<need-name>/issues/<topic>.md` after B3 diagnose | Apply the fix per the root cause; `todo.md` is NOT touched (it was already fully checked when the bug surfaced). Append progress notes to the issue file's `## bug` section instead. |
|
|
28
|
+
|
|
29
|
+
## Philosophy
|
|
30
|
+
|
|
31
|
+
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
|
32
|
+
|
|
33
|
+
**Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
|
|
34
|
+
|
|
35
|
+
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
|
|
36
|
+
|
|
37
|
+
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
|
38
|
+
|
|
39
|
+
## Anti-Pattern: Horizontal Slices
|
|
40
|
+
|
|
41
|
+
**DO NOT write all tests first, then all implementation.** This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
|
|
42
|
+
|
|
43
|
+
This produces **crap tests**:
|
|
44
|
+
|
|
45
|
+
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
|
46
|
+
- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
|
|
47
|
+
- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
|
|
48
|
+
- You outrun your headlights, committing to test structure before understanding the implementation
|
|
49
|
+
|
|
50
|
+
**Correct approach**: Vertical slices via tracer bullets. One test -> one implementation -> repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
WRONG (horizontal):
|
|
54
|
+
RED: test1, test2, test3, test4, test5
|
|
55
|
+
GREEN: impl1, impl2, impl3, impl4, impl5
|
|
56
|
+
|
|
57
|
+
RIGHT (vertical):
|
|
58
|
+
RED->GREEN: test1->impl1
|
|
59
|
+
RED->GREEN: test2->impl2
|
|
60
|
+
RED->GREEN: test3->impl3
|
|
61
|
+
...
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Workflow
|
|
65
|
+
|
|
66
|
+
### 1. Planning
|
|
67
|
+
|
|
68
|
+
When exploring the codebase, use vocabulary from `spec/INDEX.md` and the current need's `design.md` so that test names and interface vocabulary match the project's language. Respect ADRs under `spec/ADR/`.
|
|
69
|
+
|
|
70
|
+
Before writing any code for the current slice:
|
|
71
|
+
|
|
72
|
+
- [ ] Read the `## 实施` item being implemented; confirm it traces to a section in `design.md`
|
|
73
|
+
- [ ] Confirm with user (or re-read `design.md`) what interface changes the slice requires
|
|
74
|
+
- [ ] Confirm which behaviors to test (prioritize per slice acceptance criteria)
|
|
75
|
+
- [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
|
|
76
|
+
- [ ] Design interfaces for [testability](interface-design.md)
|
|
77
|
+
- [ ] List the behaviors to test (not implementation steps)
|
|
78
|
+
- [ ] If `design.md` needs amendment (new behavior surfaced), STOP and go back to A3
|
|
79
|
+
|
|
80
|
+
Ask: "What should the public interface look like? Which behaviors are most important to test?"
|
|
81
|
+
|
|
82
|
+
**You can't test everything.** Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
|
|
83
|
+
|
|
84
|
+
### 2. Tracer Bullet
|
|
85
|
+
|
|
86
|
+
Write ONE test that confirms ONE thing about the system:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
RED: Write test for first behavior -> test fails
|
|
90
|
+
GREEN: Write minimal code to pass -> test passes
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This is your tracer bullet - proves the path works end-to-end.
|
|
94
|
+
|
|
95
|
+
### 3. Incremental Loop
|
|
96
|
+
|
|
97
|
+
For each remaining behavior:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
RED: Write next test -> fails
|
|
101
|
+
GREEN: Minimal code to pass -> passes
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Rules:
|
|
105
|
+
|
|
106
|
+
- One test at a time
|
|
107
|
+
- Only enough code to pass current test
|
|
108
|
+
- Don't anticipate future tests
|
|
109
|
+
- Keep tests focused on observable behavior
|
|
110
|
+
|
|
111
|
+
### 4. Refactor
|
|
112
|
+
|
|
113
|
+
After all tests pass, look for [refactor candidates](refactoring.md):
|
|
114
|
+
|
|
115
|
+
- [ ] Extract duplication
|
|
116
|
+
- [ ] Deepen modules (move complexity behind simple interfaces)
|
|
117
|
+
- [ ] Apply SOLID principles where natural
|
|
118
|
+
- [ ] Consider what new code reveals about existing code
|
|
119
|
+
- [ ] Run tests after each refactor step
|
|
120
|
+
|
|
121
|
+
**Never refactor while RED.** Get to GREEN first.
|
|
122
|
+
|
|
123
|
+
## Checklist Per Cycle
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
[ ] Test describes behavior, not implementation
|
|
127
|
+
[ ] Test uses public interface only
|
|
128
|
+
[ ] Test would survive internal refactor
|
|
129
|
+
[ ] Code is minimal for this test
|
|
130
|
+
[ ] No speculative features added
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## After Each Slice (A5)
|
|
134
|
+
|
|
135
|
+
1. Tick the corresponding `- [ ]` -> `- [x]` in `spec/needs/<need-name>/todo.md`
|
|
136
|
+
2. Update `spec/INDEX.md`:
|
|
137
|
+
- Bump the `todo` column counter (e.g. `2/8` -> `3/8`)
|
|
138
|
+
- If all `## 实施` items are now checked, set `当前节点` to `A6 verify` (per `spec/AGENTS.md` INDEX rules)
|
|
139
|
+
- If unsure, run `ae index-rebuild`
|
|
140
|
+
3. Commit. Suggested message: `feat(<need-name>): T<n> <title>`.
|
|
141
|
+
|
|
142
|
+
## After All Slices Checked (A5 only)
|
|
143
|
+
|
|
144
|
+
Hand off to A6 `verification-before-completion` for end-to-end verification on the real user path. This skill's job ends when `todo.md` is fully checked AND slice-level tests are green.
|
|
145
|
+
|
|
146
|
+
## After Fix Lands (B5 only)
|
|
147
|
+
|
|
148
|
+
1. Do NOT modify `todo.md` (it was fully checked before the bug surfaced).
|
|
149
|
+
2. Append a short progress note under the issue file's `## bug` section (the 7-section format produced at B4). Quote the failing test name and the root-cause one-liner.
|
|
150
|
+
3. Commit. Suggested message: `fix(<need-name>): <root cause summary>`.
|
|
151
|
+
4. Hand off to B6 user re-verification.
|
|
152
|
+
|
|
153
|
+
## Boundaries
|
|
154
|
+
|
|
155
|
+
- This skill writes code and tests, plus updates `todo.md` (A5) or the issue file's `## bug` section (B5).
|
|
156
|
+
- It does NOT write `prd.md`, `design.md`, or new ADRs. Scope changes go back through A3.
|
|
157
|
+
- It does NOT perform end-to-end / user-path verification - that is A6.
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
# Deep Modules
|
|
2
|
-
|
|
3
|
-
From "A Philosophy of Software Design":
|
|
4
|
-
|
|
5
|
-
**Deep module** = small interface + lots of implementation
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
┌─────────────────────┐
|
|
9
|
-
│ Small Interface │ ← Few methods, simple params
|
|
10
|
-
├─────────────────────┤
|
|
11
|
-
│ │
|
|
12
|
-
│ │
|
|
13
|
-
│ Deep Implementation│ ← Complex logic hidden
|
|
14
|
-
│ │
|
|
15
|
-
│ │
|
|
16
|
-
└─────────────────────┘
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Shallow module** = large interface + little implementation (avoid)
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
┌─────────────────────────────────┐
|
|
23
|
-
│ Large Interface │ ← Many methods, complex params
|
|
24
|
-
├─────────────────────────────────┤
|
|
25
|
-
│ Thin Implementation │ ← Just passes through
|
|
26
|
-
└─────────────────────────────────┘
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
When designing interfaces, ask:
|
|
30
|
-
|
|
31
|
-
- Can I reduce the number of methods?
|
|
32
|
-
- Can I simplify the parameters?
|
|
33
|
-
- Can I hide more complexity inside?
|
|
1
|
+
# Deep Modules
|
|
2
|
+
|
|
3
|
+
From "A Philosophy of Software Design":
|
|
4
|
+
|
|
5
|
+
**Deep module** = small interface + lots of implementation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────┐
|
|
9
|
+
│ Small Interface │ ← Few methods, simple params
|
|
10
|
+
├─────────────────────┤
|
|
11
|
+
│ │
|
|
12
|
+
│ │
|
|
13
|
+
│ Deep Implementation│ ← Complex logic hidden
|
|
14
|
+
│ │
|
|
15
|
+
│ │
|
|
16
|
+
└─────────────────────┘
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Shallow module** = large interface + little implementation (avoid)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
┌─────────────────────────────────┐
|
|
23
|
+
│ Large Interface │ ← Many methods, complex params
|
|
24
|
+
├─────────────────────────────────┤
|
|
25
|
+
│ Thin Implementation │ ← Just passes through
|
|
26
|
+
└─────────────────────────────────┘
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
When designing interfaces, ask:
|
|
30
|
+
|
|
31
|
+
- Can I reduce the number of methods?
|
|
32
|
+
- Can I simplify the parameters?
|
|
33
|
+
- Can I hide more complexity inside?
|