moicle 3.0.1 → 3.0.3
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/README.md +9 -3
- package/assets/architecture/_shared/read-project-first.md +30 -0
- package/assets/skills/challenge/SKILL.md +70 -35
- package/assets/skills/cleanup/SKILL.md +121 -0
- package/assets/skills/docs/sync/SKILL.md +14 -13
- package/assets/skills/feature/build/SKILL.md +29 -23
- package/assets/skills/feature/track/SKILL.md +60 -18
- package/assets/skills/fix/bug/SKILL.md +7 -7
- package/assets/skills/fix/incident/SKILL.md +4 -5
- package/assets/skills/research/explore/SKILL.md +20 -20
- package/assets/skills/review/code/SKILL.md +35 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ A toolkit to bootstrap and accelerate project development with Claude Code throu
|
|
|
16
16
|
|
|
17
17
|
- **16 AI Agents** - 6 developer agents + 10 utility agents
|
|
18
18
|
- **4 Commands** - Wizards for bootstrap, brainstorm, documentation, and marketing
|
|
19
|
-
- **
|
|
19
|
+
- **11 Skills** - Mode-based, auto-triggered workflows for the full SDLC (feature, bug, review, research, docs, marketing) plus standalone `/challenge` (self-critique) and `/cleanup` (dead-code/duplicate)
|
|
20
20
|
- **9 Architecture References** - DDD + Hexagonal + stack-specific patterns
|
|
21
21
|
|
|
22
22
|
|
|
@@ -124,9 +124,9 @@ moicle install --target cursor --project
|
|
|
124
124
|
| `/brainstorm` | Brainstorm ideas with 6 frameworks |
|
|
125
125
|
| `/doc` | Scan project and generate documentation |
|
|
126
126
|
|
|
127
|
-
### Skills (
|
|
127
|
+
### Skills (11)
|
|
128
128
|
|
|
129
|
-
Skills are grouped by a `<group>-` prefix. Type `/<group>-` then `Tab` in Claude Code to see all skills in a group. Each skill bundles several related workflows into **modes** chosen at the top of the file — pick a mode (or let Claude pick it from your natural-language phrasing).
|
|
129
|
+
Skills are grouped by a `<group>-` prefix. Type `/<group>-` then `Tab` in Claude Code to see all skills in a group. Each skill bundles several related workflows into **modes** chosen at the top of the file — pick a mode (or let Claude pick it from your natural-language phrasing). Two skills — `/challenge` and `/cleanup` — are intentionally standalone (no group prefix).
|
|
130
130
|
|
|
131
131
|
**`/feature-*` — Build & Change**
|
|
132
132
|
|
|
@@ -173,6 +173,12 @@ Skills are grouped by a `<group>-` prefix. Type `/<group>-` then `Tab` in Claude
|
|
|
173
173
|
|-------|-------|-------------|
|
|
174
174
|
| `/challenge` | — | A quick skeptical re-examination of what you just did (or selected code): simpler? duplicated? optimal? edge cases? — reports honest findings without self-congratulating. Lighter than `/review-code` SELF. |
|
|
175
175
|
|
|
176
|
+
**`/cleanup` — Dead Code & Duplicate** (standalone, no group)
|
|
177
|
+
|
|
178
|
+
| Skill | Modes | When to use |
|
|
179
|
+
|-------|-------|-------------|
|
|
180
|
+
| `/cleanup` | DEAD-CODE · DUPLICATE | Safely remove dead code / consolidate duplicates. Detects with stack tools, **verifies each hit with grep**, then classifies DELETE (true dead) vs KEEP (reusable utils/scopes/helpers — asks when unsure). Removes per-group with build+test each. |
|
|
181
|
+
|
|
176
182
|
### Skill decision matrix
|
|
177
183
|
|
|
178
184
|
When more than one skill / mode could fit, use this matrix:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Read the project first — architecture doc is only a fallback
|
|
2
|
+
|
|
3
|
+
> **Match the project, not the textbook.** The pattern this repo *already uses* is the source of truth — for planning, coding, reviewing, and generating docs. Follow it, whatever it is (CRUD, MVC, feature-folder, service+repo, layered, script, DDD/hexagonal, or legacy with its own quirks).
|
|
4
|
+
|
|
5
|
+
## 1. Learn how THIS project actually works
|
|
6
|
+
|
|
7
|
+
Before planning or writing anything:
|
|
8
|
+
|
|
9
|
+
1. **Read 1–2 existing modules/features closest to the task, end-to-end.** They tell you the real conventions: folder layout, naming, where business logic lives, where tests go, how things get wired/registered.
|
|
10
|
+
2. **Follow that grain.** Your new code should look like it was written by the same team — same structure, same names, same test style.
|
|
11
|
+
3. **Detect the stack** via `_shared/stack-detection.md` — but only to grab the concrete **build / test / lint commands** and stack idioms, not to decide the architecture.
|
|
12
|
+
|
|
13
|
+
## 2. When architecture docs apply (fallback only)
|
|
14
|
+
|
|
15
|
+
Open `~/.claude/architecture/*` (`ddd-architecture.md`, `clean-architecture.md`, `hexagonal-architecture.md`, the stack docs) **only** when one of these is true:
|
|
16
|
+
|
|
17
|
+
- **(a)** the project **already uses** that pattern (you saw it in step 1), OR
|
|
18
|
+
- **(b)** the task **explicitly asks** to refactor/migrate toward it, OR
|
|
19
|
+
- **(c)** the project is **greenfield** with no pattern to copy yet (then the doc is your default), OR
|
|
20
|
+
- **(d)** you just need the **commands/conventions** for the stack.
|
|
21
|
+
|
|
22
|
+
## 3. Do NOT impose DDD
|
|
23
|
+
|
|
24
|
+
Do **not** force DDD/Clean-Arch constructs — entities, value objects, ports, usecases, aggregates, event dispatchers, layer boundaries — onto a project that isn't built that way. That is overengineering: it produces code, plans, reviews, and docs that look foreign to the repo and confuse the team.
|
|
25
|
+
|
|
26
|
+
- **Planning/building:** mirror the reference module you read, not a layer diagram.
|
|
27
|
+
- **Reviewing:** score consistency with the *codebase's own* architecture, not with a textbook. A CRUD/MVC repo is not "broken architecture" — it just isn't DDD.
|
|
28
|
+
- **Docs:** describe the structure you actually scanned, never a domain/layer skeleton the code doesn't have.
|
|
29
|
+
|
|
30
|
+
DDD is a target to *opt into*, never a default to assume.
|
|
@@ -1,57 +1,92 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: challenge
|
|
3
|
-
description:
|
|
3
|
+
description: Pause before committing to the current solution. Challenge your own reasoning, assumptions, and design. Look for a better approach before proceeding.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Challenge
|
|
6
|
+
# Challenge
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
You are no longer defending the current solution.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Become its strongest critic.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Assume there may be a simpler, safer, or more correct approach.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
2. **The change you just made** — otherwise, critique the code you produced or edited most recently in this session (check the working diff if unsure).
|
|
14
|
+
Your goal is not to find flaws at all costs.
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
Your goal is to determine whether the current direction is truly the best one.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Re-evaluate
|
|
21
|
+
|
|
22
|
+
Ask yourself:
|
|
23
|
+
|
|
24
|
+
### Did I understand the problem correctly?
|
|
25
|
+
|
|
26
|
+
- Am I solving the actual problem?
|
|
27
|
+
- Did I silently assume requirements?
|
|
28
|
+
- Did I optimize for something the user never asked for?
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Is there a simpler solution?
|
|
33
|
+
|
|
34
|
+
- Can I delete code instead of adding code?
|
|
35
|
+
- Can an existing abstraction be reused?
|
|
36
|
+
- Am I introducing flexibility that isn't needed?
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Am I overengineering?
|
|
41
|
+
|
|
42
|
+
- Extra layers?
|
|
43
|
+
- Extra configuration?
|
|
44
|
+
- Generic framework for a single use case?
|
|
45
|
+
- Future-proofing without evidence?
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### What would I do if starting from scratch?
|
|
50
|
+
|
|
51
|
+
Ignore the current implementation.
|
|
52
|
+
|
|
53
|
+
Would I build it the same way?
|
|
54
|
+
|
|
55
|
+
If not, why?
|
|
56
|
+
|
|
57
|
+
---
|
|
20
58
|
|
|
21
|
-
|
|
59
|
+
### What's the weakest assumption?
|
|
22
60
|
|
|
23
|
-
|
|
61
|
+
Identify the assumption most likely to be wrong.
|
|
24
62
|
|
|
25
|
-
|
|
63
|
+
Explain how it could fail.
|
|
26
64
|
|
|
27
|
-
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### Explore one alternative
|
|
68
|
+
|
|
69
|
+
Briefly describe one different approach.
|
|
70
|
+
|
|
71
|
+
Do not choose it automatically.
|
|
72
|
+
|
|
73
|
+
State its main tradeoff.
|
|
74
|
+
|
|
75
|
+
---
|
|
28
76
|
|
|
29
|
-
|
|
30
|
-
|------|-----|
|
|
31
|
-
| **Simpler** | Is there a shorter / more direct way? Am I solving a problem I don't have? Any premature abstraction, needless layer, config, or generality? |
|
|
32
|
-
| **Duplication (DRY)** | Is this logic already implemented elsewhere in the codebase? Did I repeat a block that should be one helper? (Search before claiming "no dup".) |
|
|
33
|
-
| **Optimal** | Redundant work, N+1, re-fetch, re-compute in a loop, unnecessary allocation? Is the data structure the right one? |
|
|
34
|
-
| **Correctness edges** | Null / empty / boundary / large input / concurrent access / partial failure — which path did I not handle? |
|
|
35
|
-
| **Error handling** | Any swallowed error (empty catch, ignored return)? Failures must surface clearly and be logged, not muffled. |
|
|
36
|
-
| **Naming & footprint** | Misleading names? Did I rename/move things I didn't need to? Is any file getting too big / doing too much? |
|
|
37
|
-
| **Tests** | Is the risky path actually covered, or just the happy one? |
|
|
77
|
+
## Decision
|
|
38
78
|
|
|
39
|
-
|
|
79
|
+
Finish with one of:
|
|
40
80
|
|
|
41
|
-
Keep
|
|
81
|
+
### Keep current approach
|
|
42
82
|
|
|
43
|
-
|
|
44
|
-
⚠️ <one-line problem> · <file:line>
|
|
45
|
-
→ <concrete fix>
|
|
46
|
-
```
|
|
83
|
+
Explain *why* the alternatives are not better.
|
|
47
84
|
|
|
48
|
-
|
|
85
|
+
or
|
|
49
86
|
|
|
50
|
-
|
|
51
|
-
- **Genuinely nothing** → "Đã soi <các lens> trên <scope>, không thấy vấn đề thực sự. Điểm cần lưu ý nếu mở rộng sau: <1 dòng, nếu có>." State what you searched so the "clean" verdict is earned, not assumed.
|
|
87
|
+
### Better direction found
|
|
52
88
|
|
|
53
|
-
|
|
89
|
+
Explain what should change and why.
|
|
54
90
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- ❌ Actually implementing the fixes now → this skill *proposes*; apply only after the user says go.
|
|
91
|
+
Never change the code automatically.
|
|
92
|
+
Never fabricate issues.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cleanup
|
|
3
|
+
description: Safely remove dead code and consolidate duplicates. Two modes — DEAD-CODE (remove unreachable/unused code) and DUPLICATE (merge copy-paste into one canonical). Detect with stack-appropriate tools, VERIFY every hit with grep, then classify DELETE (true dead) vs KEEP (reusable utilities/helpers/scopes — never delete on a tool signal alone). Stack-aware. Use when the user says "cleanup", "clean up codebase", "dead code", "remove dead code", "remove unused code", "find unused code", "unused code", "declutter", "tech debt", "duplicate code", "consolidate duplicates", "copy-paste code".
|
|
4
|
+
args: "[MODE]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Cleanup Workflow
|
|
8
|
+
|
|
9
|
+
Remove rot **without deleting things worth keeping**. Tools only propose candidates — grep and judgment decide what actually goes. The classic failure is trusting a dead-code tool blindly and deleting reusable helpers, which turns a "cleanup" into a rejected mess.
|
|
10
|
+
|
|
11
|
+
## Pick your mode
|
|
12
|
+
|
|
13
|
+
| Situation | Mode | Jump to |
|
|
14
|
+
|-----------|------|---------|
|
|
15
|
+
| Remove unreachable / unused code | **DEAD-CODE** | [Mode DEAD-CODE](#mode-dead-code) |
|
|
16
|
+
| Consolidate copy-paste into one canonical | **DUPLICATE** | [Mode DUPLICATE](#mode-duplicate) |
|
|
17
|
+
|
|
18
|
+
Run either, or both in sequence. If scope is unclear, ask one line: *"Whole repo or just `<module>`? Delete directly, or report for review first?"* then proceed.
|
|
19
|
+
|
|
20
|
+
- ❌ Reformatting / renaming / restructuring working code → use `@refactor`.
|
|
21
|
+
- ❌ Reviewing a branch/PR for quality → use `/review-code`.
|
|
22
|
+
- ❌ A bug surfaced during cleanup → use `/fix-bug`.
|
|
23
|
+
|
|
24
|
+
## ⛔ Rule #1 — Keep reusable, delete only true dead (both modes)
|
|
25
|
+
|
|
26
|
+
> A tool reporting "unused / unreachable" is **not enough** to delete. Classify every candidate:
|
|
27
|
+
|
|
28
|
+
| | **DELETE** (true dead) | **KEEP** (reusable — ask if unsure) |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| What | Leftover of a removed feature · orphaned unit after a refactor · a real duplicate · an unreachable business flow | Generic utility / formatter / parser / query-scope helper · value-object accessors · intended public API surface · "might need it later" generic code |
|
|
31
|
+
| Tell | Tied to one specific dead feature/flow; deleting it, nobody rebuilds it | General-purpose helper not tied to any feature; deleting it means rewriting it later |
|
|
32
|
+
| Action | Delete | **Keep.** If unsure, list it and ask the user — do not auto-delete |
|
|
33
|
+
|
|
34
|
+
When torn between the two columns, **default to KEEP and ask**. A leftover helper is cheaper than deleting something the team meant to use.
|
|
35
|
+
|
|
36
|
+
## Read stack first (both modes)
|
|
37
|
+
|
|
38
|
+
Detect the stack via `~/.claude/architecture/_shared/stack-detection.md`, then use the matching tools. These only produce *candidates*; install if missing (tell the user).
|
|
39
|
+
|
|
40
|
+
| Stack | Dead code | Duplicate | Unused deps |
|
|
41
|
+
|---|---|---|---|
|
|
42
|
+
| **Go** | `deadcode -test ./...` (whole-program) + `staticcheck -checks U1000 ./...` (unexported/const/type/field) | `dupl` | `go mod tidy` (diff) |
|
|
43
|
+
| **TS/JS** | `knip` · `ts-prune` | `jscpd` | `depcheck` · `knip` |
|
|
44
|
+
| **Python** | `vulture` | `pylint --enable=duplicate-code` | `deptry` |
|
|
45
|
+
| **Dart/Flutter** | `dart analyze` | `dart_code_metrics` | `dart pub deps` |
|
|
46
|
+
| **Any** | — | — | LSP "no references" / editor find-usages |
|
|
47
|
+
|
|
48
|
+
> ⚠️ **Multiple entry points** (API + worker + cron/CLI): make **all** of them roots for the whole-program analysis. Otherwise code used only by one entry point is reported dead by mistake.
|
|
49
|
+
|
|
50
|
+
<a id="mode-dead-code"></a>
|
|
51
|
+
## Mode DEAD-CODE
|
|
52
|
+
|
|
53
|
+
### 1. Detect
|
|
54
|
+
Run the stack's dead-code tools to get the candidate list.
|
|
55
|
+
|
|
56
|
+
### 2. Verify each candidate with grep — don't trust the tool
|
|
57
|
+
Confirm **zero real references** before touching anything. Tools miss these cases:
|
|
58
|
+
|
|
59
|
+
- **Same name in different packages/modules** — a naive count matches the wrong symbol. Confirm the exact definition (path + namespace).
|
|
60
|
+
- **Interface / polymorphism** — several same-named constructors/handlers are separate *implementations of one contract* (one per adapter/driver). That is **not duplication — never merge them**; merging breaks the abstraction.
|
|
61
|
+
- **Reflection / registered-by-name** — event listeners, queue/cron tasks registered by string, ORM callbacks, test-suite methods. Whole-program tools can't see these → false "dead".
|
|
62
|
+
- **Test-only usage** — a helper only tests call: decide by policy (usually keep while tests use it).
|
|
63
|
+
|
|
64
|
+
### 3. Classify
|
|
65
|
+
Sort each verified candidate into **DELETE · KEEP · ASK · BACKLOG** (BACKLOG = dead but touches security/business semantics → don't decide alone; write it to a doc for the user).
|
|
66
|
+
|
|
67
|
+
### 4. Remove safely
|
|
68
|
+
1. **One commit per group** (by layer or by file); message states *what* and *why it's dead*.
|
|
69
|
+
2. After each group, clean orphaned imports, then **build + test + lint must stay green**.
|
|
70
|
+
3. Re-run the dead-code tool: removed symbols are gone, and **no new dead code appeared** (if deleting A orphaned B, handle B or stop and reassess).
|
|
71
|
+
4. **Check for orphaned flows**: if you removed a producer, is a listener/handler left dangling? If you removed an enqueue helper, does a scheduler still enqueue that task another way? Confirm the real flow still lives.
|
|
72
|
+
|
|
73
|
+
### 5. (Optional) Prevent regrowth
|
|
74
|
+
Propose wiring the unused-code check into the project's existing lint/CI so dead code can't silently regrow. Keep any intentional-keep items (BACKLOG) **informational**, not a hard gate.
|
|
75
|
+
|
|
76
|
+
<a id="mode-duplicate"></a>
|
|
77
|
+
## Mode DUPLICATE
|
|
78
|
+
|
|
79
|
+
### 1. Detect
|
|
80
|
+
Run the duplicate detector to find copy-paste blocks.
|
|
81
|
+
|
|
82
|
+
### 2. Confirm it's a REAL duplicate
|
|
83
|
+
Diff the two versions. It's only a duplicate if the **logic and behavior are identical**.
|
|
84
|
+
|
|
85
|
+
> **Never merge when semantics differ** — e.g. `""→nil` vs `""→pointer-to-empty`, `"1.000"` vs `"1,000"` formatting, two different normalization algorithms. Merging changes behavior = a bug. Write it to backlog instead of merging blindly.
|
|
86
|
+
|
|
87
|
+
### 3. Choose one canonical
|
|
88
|
+
Pick the correct home for the shared version, respecting the project's existing import/dependency direction (a helper used by lower-level code must live where that code can import it). Do **not** create a god `utils` package.
|
|
89
|
+
|
|
90
|
+
### 4. Redirect and remove
|
|
91
|
+
Point all call sites at the canonical, delete the extra copies, then build + test green.
|
|
92
|
+
|
|
93
|
+
## Output
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
## Cleanup: <mode> — <scope>
|
|
97
|
+
|
|
98
|
+
### Delete (verified 0 refs)
|
|
99
|
+
- <file:symbol> — <why dead: leftover / orphan / true duplicate>
|
|
100
|
+
|
|
101
|
+
### Keep (reusable — untouched)
|
|
102
|
+
- <file:symbol> — <why kept>
|
|
103
|
+
|
|
104
|
+
### Ask
|
|
105
|
+
- <file:symbol> — dead, but <reason for doubt>
|
|
106
|
+
|
|
107
|
+
### Backlog (dead, touches security/business)
|
|
108
|
+
- <file:symbol> — <decision needed>
|
|
109
|
+
|
|
110
|
+
### Verify: build ✅ · test ✅ · tool before→after: N → M
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If deleting: one commit per group; do **not** commit / push / open a PR unless the user asks.
|
|
114
|
+
|
|
115
|
+
## Boundaries
|
|
116
|
+
|
|
117
|
+
- ❌ Do not delete a reusable helper/scope/utility just because a tool flags it unused → **KEEP or ASK**.
|
|
118
|
+
- ❌ Do not merge functions with different semantics, and do not merge same-name interface implementations.
|
|
119
|
+
- ❌ Do not drop DB tables/columns/migrations during cleanup — that needs a separate explicit confirmation.
|
|
120
|
+
- ❌ Do not commit/push/open a PR unless the user explicitly asks.
|
|
121
|
+
- ✅ When in doubt, default to KEEP and ask.
|
|
@@ -18,9 +18,9 @@ One skill, two depths: hand-author a single doc, or batch-generate a whole docs
|
|
|
18
18
|
- ❌ Just need API reference from OpenAPI → use `/feature-build` (API mode), Phase 4
|
|
19
19
|
- ❌ Understand the codebase, not document it → use `/research-explore` (ONBOARDING)
|
|
20
20
|
|
|
21
|
-
## Read
|
|
21
|
+
## Read the project first (both modes)
|
|
22
22
|
|
|
23
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md`.
|
|
23
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md`. Then see `~/.claude/architecture/_shared/read-project-first.md`: **docs must describe the architecture the code ACTUALLY has** — derive structure, layers, and flows by scanning the code, never from a DDD template. Read `ddd-architecture.md` only if the project is genuinely DDD.
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
---
|
|
@@ -63,7 +63,7 @@ For each doc define: **Purpose** (what problem it solves), **Audience** (new con
|
|
|
63
63
|
|
|
64
64
|
**API.md** — auth method + credentials · base URL per env · per endpoint (method, path, request, response, errors, example) · pagination (one block) · error format (one block) · rate limits, versioning
|
|
65
65
|
|
|
66
|
-
**ARCHITECTURE.md** — one mermaid
|
|
66
|
+
**ARCHITECTURE.md** — one mermaid diagram of the REAL structure · list of the main parts (modules / features / packages) with 1-line responsibility · how they communicate (events / calls / imports — if applicable) · key tech decisions with rationale · link to `~/.claude/architecture/<stack>.md` (only if the project follows it)
|
|
67
67
|
|
|
68
68
|
**CONTRIBUTING.md** — local dev setup (≤5 steps) · branch + commit conventions · PR flow + review expectations · test commands + coverage · where to ask for help
|
|
69
69
|
|
|
@@ -110,15 +110,16 @@ Create a resource. Idempotent via `Idempotency-Key` header.
|
|
|
110
110
|
# Architecture
|
|
111
111
|
## Overview
|
|
112
112
|
{1-2 paragraphs: what this system does, key constraints}
|
|
113
|
-
##
|
|
113
|
+
## Structure
|
|
114
|
+
{Diagram of the project's ACTUAL structure — layers if it's layered, a module/feature graph otherwise. The example below is layered; replace it with what you scanned.}
|
|
114
115
|
```mermaid
|
|
115
116
|
graph TD
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
A[entry / routes] --> B[business logic]
|
|
118
|
+
B --> C[data access]
|
|
118
119
|
```
|
|
119
|
-
|
|
120
|
-
##
|
|
121
|
-
|
|
|
120
|
+
Link to `~/.claude/architecture/<stack>.md` only if the project follows that pattern.
|
|
121
|
+
## Main parts
|
|
122
|
+
| Module / feature / package | Responsibility |
|
|
122
123
|
```
|
|
123
124
|
|
|
124
125
|
**CONTRIBUTING.md** opener
|
|
@@ -218,8 +219,8 @@ docs/
|
|
|
218
219
|
### File rules
|
|
219
220
|
- **`docs/README.md`** — index only (≤30 lines): one-line description, link to each sub-doc, last-updated timestamp.
|
|
220
221
|
- **`docs/business.md`** — for non-engineers. NO API endpoints, NO code blocks, NO file paths. Cover: what problem this solves, who uses it, key user journeys (named like a PRD), success metrics. Plain language.
|
|
221
|
-
- **`docs/architecture.md`** — for engineers.
|
|
222
|
-
- **`docs/use-cases/<name>.md`** — one per flow: trigger (who, what), preconditions, sequence diagram (mermaid `sequenceDiagram
|
|
222
|
+
- **`docs/architecture.md`** — for engineers. Diagram of the real structure (mermaid), the main parts, how they communicate (if applicable), tech decisions with rationale, link to `~/.claude/architecture/<stack>.md` (only if the project follows it).
|
|
223
|
+
- **`docs/use-cases/<name>.md`** — one per flow: trigger (who, what), preconditions, sequence diagram (mermaid `sequenceDiagram` following the steps the code ACTUALLY takes — e.g. MVC: actor → controller → model → DB → response; DDD: actor → handler → usecase → infra → response), postconditions / side effects, errors (HTTP code + meaning).
|
|
223
224
|
- **`docs/api.md`** — only if external API exists. Auth, base URL, error format, pagination → then endpoint table. Deep ref → link to OpenAPI spec.
|
|
224
225
|
- **`docs/runbook.md`** — for ops/on-call: local dev (≤5 commands), deploy steps, common failures + recovery, monitoring dashboards + log queries.
|
|
225
226
|
|
|
@@ -234,7 +235,7 @@ Sequence diagrams for use cases · class diagrams only when ER is non-obvious ·
|
|
|
234
235
|
For each iteration:
|
|
235
236
|
- **3.1 Structure** — all target files exist · README links resolve · no duplicate content
|
|
236
237
|
- **3.2 Business** — plain language (no `API`/`JSON`/`class`/file paths) · covers all top-level journeys
|
|
237
|
-
- **3.3 Architecture** —
|
|
238
|
+
- **3.3 Architecture** — diagram matches the code's real structure · every main part (module / feature) has a table row
|
|
238
239
|
- **3.4 Use cases** — one file per identified use case · each has trigger/preconditions/sequence/postconditions/errors · diagrams render
|
|
239
240
|
- **3.5 Consistency** — same terminology everywhere · no nonexistent file paths / endpoints referenced
|
|
240
241
|
|
|
@@ -276,7 +277,7 @@ For each iteration:
|
|
|
276
277
|
|
|
277
278
|
| Phase | Agent | Purpose |
|
|
278
279
|
|-------|-------|---------|
|
|
279
|
-
| SCAN | `@clean-architect` | Identify doc needs /
|
|
280
|
+
| SCAN | `@clean-architect` | Identify doc needs / structure + patterns (any architecture) |
|
|
280
281
|
| ANALYZE / GENERATE (API) | `@api-designer` | API doc structure + accuracy |
|
|
281
282
|
| ANALYZE / GENERATE (DB) | `@db-designer` | Database doc structure + accuracy |
|
|
282
283
|
| GENERATE | `@docs-writer` | Write all docs |
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: feature-build
|
|
3
|
-
description: Feature lifecycle workflow — build new
|
|
3
|
+
description: Feature lifecycle workflow — build new features in the project's own architecture, refactor existing code (into DDD when asked), add/integrate APIs, or deprecate features. Stack-aware with phase-based checks and a review loop. Use when user says "implement feature", "add feature", "build feature", "create feature", "new feature", "refactor", "clean up", "improve code", "restructure", "migrate to ddd", "refactor ddd", "integrate api", "add endpoint", "new api", "connect api", "api integration", "deprecate", "remove feature", "sunset", "phase out", "delete feature".
|
|
4
4
|
args: "[MODE] [DOMAIN] [FEATURE]"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Feature Build Workflow
|
|
8
8
|
|
|
9
|
-
One skill for the full lifecycle of a feature: **create it, restructure it, expose it via API, or sunset it** —
|
|
9
|
+
One skill for the full lifecycle of a feature: **create it, restructure it, expose it via API, or sunset it** — following the project's own architecture (DDD when it uses DDD), with rule checks per phase and a review loop.
|
|
10
10
|
|
|
11
11
|
**ARGUMENTS:** `<mode> <domain> <feature>` — `mode` ∈ `new | refactor | api | deprecate`. e.g. `new wallet savings`, `refactor marketing notification`, `api catalog`, `deprecate payments legacy-checkout`.
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ One skill for the full lifecycle of a feature: **create it, restructure it, expo
|
|
|
14
14
|
|
|
15
15
|
| If you are… | Mode | Jump to |
|
|
16
16
|
|-------------|------|---------|
|
|
17
|
-
| Building a brand-new feature across
|
|
17
|
+
| Building a brand-new feature across the project's layers | **NEW** | [Mode NEW](#mode-new) |
|
|
18
18
|
| Restructuring existing code into DDD / fixing drift | **REFACTOR** | [Mode REFACTOR](#mode-refactor) |
|
|
19
19
|
| Adding an endpoint or integrating a third-party API | **API** | [Mode API](#mode-api) |
|
|
20
20
|
| Safely sunsetting a feature / endpoint / module | **DEPRECATE** | [Mode DEPRECATE](#mode-deprecate) |
|
|
@@ -23,20 +23,22 @@ One skill for the full lifecycle of a feature: **create it, restructure it, expo
|
|
|
23
23
|
- ❌ Don't know the right approach yet → `/research-explore` (WEB or SPIKE) first
|
|
24
24
|
- ❌ Multi-step task you want to run as a tracked checklist loop → `/feature-track`
|
|
25
25
|
|
|
26
|
-
## Read
|
|
26
|
+
## Read the project first (all modes)
|
|
27
27
|
|
|
28
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md
|
|
28
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md` for build/lint/test commands, then read a similar existing feature end-to-end to learn how THIS project is built. See `~/.claude/architecture/_shared/read-project-first.md`.
|
|
29
|
+
|
|
30
|
+
**The phases below are written for DDD-layered projects.** Load `ddd-architecture.md` and follow the DDD scaffolding only when: the project already uses DDD, OR the task explicitly asks to build/refactor toward it, OR it's greenfield and you've chosen DDD. **If the project uses another pattern (CRUD, MVC, feature-folder, service+repo…), do NOT impose DDD — mirror the reference module** and read the layer names below as a mapping to whatever layers the project actually has. Severity definitions: `~/.claude/architecture/_shared/severity-levels.md`.
|
|
29
31
|
|
|
30
32
|
---
|
|
31
33
|
---
|
|
32
34
|
|
|
33
35
|
# Mode NEW
|
|
34
36
|
|
|
35
|
-
Build a new feature following
|
|
37
|
+
Build a new feature following the project's architecture, with rule checks per phase and a final review loop. The DDD scaffolding here applies when the project is DDD (or you're going DDD on greenfield) — otherwise mirror the reference module you read.
|
|
36
38
|
|
|
37
39
|
## When to use
|
|
38
40
|
|
|
39
|
-
- ✅ Feature spans multiple
|
|
41
|
+
- ✅ Feature spans multiple parts/layers of the project (not a one-liner)
|
|
40
42
|
- ✅ The approach is well-understood (no major research / prototype needed)
|
|
41
43
|
- ✅ You want automated architecture review at the end
|
|
42
44
|
- ❌ Restructuring existing code → use **Mode REFACTOR**
|
|
@@ -88,6 +90,7 @@ Present to the user:
|
|
|
88
90
|
- ...
|
|
89
91
|
|
|
90
92
|
### Files to create
|
|
93
|
+
Mirror the reference module's paths + naming. (The example below is DDD; if the project uses another layout, follow that instead.)
|
|
91
94
|
- `domain/wallet/entities/savings_account.go`
|
|
92
95
|
- `domain/wallet/valueobjects/savings_status.go`
|
|
93
96
|
- `domain/wallet/ports/savings_store.go`
|
|
@@ -98,7 +101,7 @@ Present to the user:
|
|
|
98
101
|
```
|
|
99
102
|
|
|
100
103
|
### Gate
|
|
101
|
-
- [ ]
|
|
104
|
+
- [ ] Project pattern learned from the reference module (DDD docs read only if the project is DDD)
|
|
102
105
|
- [ ] Reference module read end-to-end
|
|
103
106
|
- [ ] Plan presented
|
|
104
107
|
- [ ] **User CONFIRMED** before any code is written
|
|
@@ -197,10 +200,11 @@ Build in order: **value objects → entities → events → ports → usecases**
|
|
|
197
200
|
|
|
198
201
|
```
|
|
199
202
|
LOOP:
|
|
200
|
-
1. /review-code architect {stack} {domain}
|
|
203
|
+
1. Review the touched code — DDD project: /review-code architect {stack} {domain}
|
|
204
|
+
· otherwise: /review-code SELF
|
|
201
205
|
2. IF violations severity ≥ MEDIUM:
|
|
202
206
|
fix all → build → tests → GOTO 1
|
|
203
|
-
3. IF score ≥ B → BREAK
|
|
207
|
+
3. IF review passes (DDD: score ≥ B) → BREAK
|
|
204
208
|
```
|
|
205
209
|
|
|
206
210
|
## Final Report (NEW)
|
|
@@ -498,9 +502,11 @@ paths:
|
|
|
498
502
|
|
|
499
503
|
## Phase 2: IMPLEMENT
|
|
500
504
|
|
|
501
|
-
**Goal:** implement the contract per stack conventions,
|
|
505
|
+
**Goal:** implement the contract per stack conventions, in whatever layers the project already uses.
|
|
502
506
|
|
|
503
|
-
|
|
507
|
+
Place each concern where this project's **existing endpoints** put it (you read 1–2 as reference above). The mapping below is the DDD layout — apply it only if the project is DDD; otherwise map each row to the project's real location.
|
|
508
|
+
|
|
509
|
+
### Layered placement (DDD projects)
|
|
504
510
|
|
|
505
511
|
| Concern | Layer | Notes |
|
|
506
512
|
|---------|-------|-------|
|
|
@@ -535,8 +541,8 @@ GET /resource?cursor=<opaque>&limit=<int 1..100, default 20>
|
|
|
535
541
|
### Gate
|
|
536
542
|
- [ ] Routes registered in router / app module
|
|
537
543
|
- [ ] Handler is thin (parse → service → respond)
|
|
538
|
-
- [ ] Business logic in
|
|
539
|
-
- [ ] External calls
|
|
544
|
+
- [ ] Business logic not inline in the handler (in whatever layer the project uses — service/usecase)
|
|
545
|
+
- [ ] External calls isolated behind the project's client/adapter pattern
|
|
540
546
|
- [ ] Auth + validation in middleware, not handler
|
|
541
547
|
- [ ] Build passes: `{stack_build_command}`
|
|
542
548
|
|
|
@@ -606,12 +612,12 @@ Create a resource. Idempotent via `Idempotency-Key` header.
|
|
|
606
612
|
|
|
607
613
|
## Review Loop (API)
|
|
608
614
|
|
|
609
|
-
|
|
615
|
+
Review the touched code and loop until it passes. DDD project: `/review-code architect {stack} {domain}` until score ≥ B. Otherwise: `/review-code SELF` until clean.
|
|
610
616
|
|
|
611
617
|
```
|
|
612
618
|
LOOP:
|
|
613
|
-
1. /review-code architect {stack} {domain}
|
|
614
|
-
2. Fix violations → re-run tests + build → GOTO 1 (until
|
|
619
|
+
1. /review-code architect {stack} {domain} (DDD) · otherwise /review-code SELF
|
|
620
|
+
2. Fix violations → re-run tests + build → GOTO 1 (until it passes)
|
|
615
621
|
```
|
|
616
622
|
|
|
617
623
|
## Final Report (API)
|
|
@@ -683,7 +689,7 @@ IDENTIFY → PLAN → MIGRATE → REMOVE → VERIFY
|
|
|
683
689
|
{log_query for endpoint hits over last 30/90 days}
|
|
684
690
|
```
|
|
685
691
|
3. Identify consumers: internal teams / services, external users / SDK consumers, third-party integrations, docs and tutorials that reference it
|
|
686
|
-
4. Assess impact
|
|
692
|
+
4. Assess impact: which parts/modules reference it, cross-module consumers, breaking-change severity
|
|
687
693
|
5. Find replacement (or document "no replacement, here's the workaround")
|
|
688
694
|
|
|
689
695
|
### Output
|
|
@@ -705,7 +711,7 @@ IDENTIFY → PLAN → MIGRATE → REMOVE → VERIFY
|
|
|
705
711
|
- Docs referencing it: {list}
|
|
706
712
|
|
|
707
713
|
### Impact
|
|
708
|
-
-
|
|
714
|
+
- Areas affected: {modules / layers that reference it}
|
|
709
715
|
- Severity: {breaking / non-breaking}
|
|
710
716
|
- Estimated migration effort per consumer: {hours}
|
|
711
717
|
```
|
|
@@ -858,12 +864,12 @@ class OldWidget { ... }
|
|
|
858
864
|
- **Read reference / old code first** — your code should look like the rest of the codebase; don't invent logic from variable names.
|
|
859
865
|
- **User confirms the plan / contract** before any code is written.
|
|
860
866
|
- **Phase order is sequential** — Rule Checks gate the next phase; don't skip ahead.
|
|
861
|
-
- **
|
|
862
|
-
- **
|
|
867
|
+
- **When the project is DDD: domain has zero framework imports** — enforce via grep in the domain gate.
|
|
868
|
+
- **When the project uses events: listeners handle side-effects** — never call notifications/SSE/analytics from a usecase.
|
|
863
869
|
- **REFACTOR preserves behavior** — never change business logic; all endpoints keep their paths; read old tests so no scenario is lost.
|
|
864
|
-
- **API:** never put business logic in the handler; never call an external API directly from
|
|
870
|
+
- **API:** never put business logic in the handler; never call an external API directly from business logic — go through the project's client/adapter layer (a domain port if DDD); error codes are stable strings; one pagination style; idempotency key for any state-creating POST.
|
|
865
871
|
- **DEPRECATE:** announce before removing; every `@deprecated` has a date + replacement; return 410 not 404; keep removal reversible.
|
|
866
|
-
- **Don't merge
|
|
872
|
+
- **Don't merge until the applicable review passes** — DDD: architect score ≥ B; otherwise SELF/PR clean. Fix violations or document the waiver.
|
|
867
873
|
|
|
868
874
|
## Related Skills
|
|
869
875
|
|
|
@@ -20,12 +20,14 @@ Run a multi-step task as a controlled loop: **brainstorm + plan first, get appro
|
|
|
20
20
|
- ❌ Single full DDD feature across all layers → use `/feature-build` (NEW mode)
|
|
21
21
|
- ❌ Driving ONE unit test-first with no branch/checklist → use `/review-code` (TDD mode)
|
|
22
22
|
|
|
23
|
-
## Read
|
|
23
|
+
## Read the project first
|
|
24
24
|
|
|
25
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md
|
|
25
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md` for:
|
|
26
26
|
- Test command + test file location convention
|
|
27
27
|
- Build + lint commands (for the VERIFY step)
|
|
28
|
-
- Mocking pattern for
|
|
28
|
+
- Mocking pattern for dependencies
|
|
29
|
+
|
|
30
|
+
Then see `~/.claude/architecture/_shared/read-project-first.md`: the checklist and every item's implementation must match the pattern THIS project already uses (read a similar existing feature first) — not an assumed DDD layout.
|
|
29
31
|
|
|
30
32
|
---
|
|
31
33
|
|
|
@@ -45,25 +47,62 @@ Detect stack via `~/.claude/architecture/_shared/stack-detection.md`. The stack
|
|
|
45
47
|
|
|
46
48
|
## Phase 0: BRAINSTORM & PLAN
|
|
47
49
|
|
|
48
|
-
**Goal:** understand the task, pick the simplest
|
|
50
|
+
**Goal:** understand the task deeply, pick the simplest approach that fits THIS project, decompose it into a high-quality checklist, self-critique the plan, and get the user to approve before touching anything. **A tracked loop is only as good as this plan** — a sloppy Phase 0 makes the whole loop sloppy, so this is where the rigor goes.
|
|
51
|
+
|
|
52
|
+
> **Fast-path:** for a trivial/obvious task, collapse steps 3 & 5 into one quick pass — don't turn a one-item change into ceremony. The rigor below is for real multi-item tasks.
|
|
49
53
|
|
|
50
54
|
### Steps
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
|
|
56
|
+
1. **Detect stack + read the project.** Get test/build/lint commands (`_shared/stack-detection.md`), then read 1–2 existing features closest to this task **end-to-end**. Write 2–3 lines capturing the *real* conventions (structure, naming, where logic lives, test style, wiring) — this proves you understood the codebase instead of guessing, and it's the pattern every item must match. See `_shared/read-project-first.md`.
|
|
57
|
+
|
|
58
|
+
2. **Clarify if ambiguous.** If scope, acceptance criteria, or edge cases are unclear, ask (AskUserQuestion) before planning. Don't assume.
|
|
59
|
+
|
|
60
|
+
3. **Choose the approach — brainstorm ≥2 options.** Invoke `/brainstorm` (First Principles, SCAMPER, Working Backwards, 5 Whys…). Compare options on effort / risk / blast-radius and pick the **simplest that fits the project's existing pattern**. Note in one line why the runner-up lost.
|
|
61
|
+
- **Unknown too big?** If you can't tell which approach works without building, STOP planning and run `/research-explore` (SPIKE) first, then return. Never commit a checklist around a guess.
|
|
62
|
+
|
|
63
|
+
4. **Decompose into a checklist — every item must pass this rubric:**
|
|
64
|
+
- **Vertical slice** — delivers one behavior testable on its own (not "all models" then "all handlers").
|
|
65
|
+
- **Independently testable** — a single failing test can describe it.
|
|
66
|
+
- **Right-sized** — one focused commit; needs two unrelated tests → split it; can't stand alone → merge it up.
|
|
67
|
+
- **Ordered by dependency** — earlier items unblock later ones.
|
|
68
|
+
- **Matches the project** — files/naming mirror the reference feature from step 1, not a textbook layer.
|
|
69
|
+
|
|
70
|
+
Any item failing the rubric → split, merge, or reorder until it passes.
|
|
71
|
+
|
|
72
|
+
5. **Self-challenge the plan — invoke `/challenge`.** Before showing the user, poke holes: over- or under-engineered? missing an edge case or acceptance criterion? wrong item order? any hidden **DB migration / security / performance** work? imposing structure this codebase doesn't use? Refine, then present.
|
|
73
|
+
|
|
74
|
+
6. **Present the plan doc and WAIT for approval.** The last planning step — no branch, no code, no `TaskCreate` yet.
|
|
75
|
+
|
|
76
|
+
```markdown
|
|
77
|
+
## Track Plan: {task}
|
|
78
|
+
|
|
79
|
+
### Goal + acceptance
|
|
80
|
+
{What "done" means for the whole track — the observable outcome.}
|
|
81
|
+
|
|
82
|
+
### Project fit (from step 1)
|
|
83
|
+
{The reference feature you read + the conventions each item will follow.}
|
|
84
|
+
|
|
85
|
+
### Approach
|
|
86
|
+
{Chosen approach} — picked over {runner-up} because {one line}.
|
|
87
|
+
|
|
88
|
+
### Checklist
|
|
89
|
+
| # | Item (vertical slice) | Test that proves it | Files (match reference) |
|
|
90
|
+
|---|-----------------------|---------------------|-------------------------|
|
|
91
|
+
| 1 | … | … | … |
|
|
92
|
+
| 2 | … | … | … |
|
|
93
|
+
Proposed branch: `feat/<slug>`
|
|
94
|
+
|
|
95
|
+
### Risks / rollback
|
|
96
|
+
{Edge cases + any DB-migration / security / perf flag to confirm before that item runs.}
|
|
97
|
+
```
|
|
60
98
|
|
|
61
99
|
### Gate
|
|
62
|
-
- [ ] Stack detected
|
|
100
|
+
- [ ] Stack detected + reference feature read (project pattern captured in 2–3 lines)
|
|
63
101
|
- [ ] Requirements clear (clarified if they weren't)
|
|
64
|
-
- [ ]
|
|
65
|
-
- [ ]
|
|
66
|
-
- [ ]
|
|
102
|
+
- [ ] ≥2 approaches compared, simplest project-fitting one picked (or SPIKE run for unknowns)
|
|
103
|
+
- [ ] Checklist drafted — **every item passes the rubric**
|
|
104
|
+
- [ ] Plan self-challenged via `/challenge` and refined
|
|
105
|
+
- [ ] Plan doc presented — **User APPROVED**
|
|
67
106
|
|
|
68
107
|
---
|
|
69
108
|
|
|
@@ -134,6 +173,7 @@ Branch: `feat/{slug}`
|
|
|
134
173
|
- **One commit per item** — don't squash steps together, don't push automatically.
|
|
135
174
|
- **DB operations (migrate / seed / drop)** inside any item: **CONFIRM with the user before running — every time, even if a previous item was already confirmed.**
|
|
136
175
|
- **Simple first** — don't overengineer an item.
|
|
176
|
+
- **Match the project** — every item mirrors an existing feature's structure/naming; never impose DDD/layers the codebase doesn't already use (see `~/.claude/architecture/_shared/read-project-first.md`).
|
|
137
177
|
|
|
138
178
|
---
|
|
139
179
|
|
|
@@ -142,8 +182,10 @@ Branch: `feat/{slug}`
|
|
|
142
182
|
| When | Use |
|
|
143
183
|
|------|-----|
|
|
144
184
|
| Need idea frameworks for Phase 0 | `/brainstorm` |
|
|
185
|
+
| Self-critique the plan in Phase 0 | `/challenge` |
|
|
186
|
+
| De-risk an unknown before planning | `/research-explore` (SPIKE mode) |
|
|
145
187
|
| Drive ONE unit deeper test-first | `/review-code` (TDD mode) |
|
|
146
|
-
| Full
|
|
188
|
+
| Full feature across the project's own layers | `/feature-build` (NEW mode) |
|
|
147
189
|
| Self-review the branch after the loop | `/review-code` (SELF mode) |
|
|
148
190
|
| Urgent prod bug, no checklist | `/fix-bug` (QUICK mode) |
|
|
149
191
|
|
|
@@ -21,9 +21,9 @@ One skill, two depths. Start in **QUICK** when the cause is clear; escalate to *
|
|
|
21
21
|
- ❌ Bug is on an open PR review → use `/review-code` (ADDRESS mode).
|
|
22
22
|
- ❌ Building a new feature → use `/feature-build` (NEW mode).
|
|
23
23
|
|
|
24
|
-
## Read
|
|
24
|
+
## Read the project first (both modes)
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
See `~/.claude/architecture/_shared/read-project-first.md`. Read the code around the bug to learn where a fix like this belongs in THIS project's structure — its own layers/modules, whatever they are (not an assumed DDD layout). Severity definitions: `~/.claude/architecture/_shared/severity-levels.md` (incident table). QUICK typically covers P2-P4; P1 → start with `/fix-incident`.
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
---
|
|
@@ -98,7 +98,7 @@ IDENTIFY → REPRODUCE → FIX → VERIFY → DEPLOY
|
|
|
98
98
|
|
|
99
99
|
### Rules
|
|
100
100
|
- Fix at the **root cause**, not the symptom
|
|
101
|
-
- Land the fix
|
|
101
|
+
- Land the fix where this codebase already puts that kind of logic — validate at the input/boundary, fix a business rule where the rule lives, fix a data-shape issue at the mapping/adapter step — using whatever the project's layers are named (don't invent DDD layers it doesn't have)
|
|
102
102
|
- **Add a regression test first** (RED), then make it pass (GREEN). See `/review-code` (TDD mode).
|
|
103
103
|
- Don't refactor on the fix — separate PR
|
|
104
104
|
- If the fix requires schema migration, plan it as 2 deploys (compatible code first, then migration)
|
|
@@ -108,7 +108,7 @@ For data-shape bugs (null where not expected, type mismatch from external API):
|
|
|
108
108
|
|
|
109
109
|
### Gate
|
|
110
110
|
- [ ] Regression test added (red → green)
|
|
111
|
-
- [ ] Fix is
|
|
111
|
+
- [ ] Fix is where this codebase already puts that kind of logic
|
|
112
112
|
- [ ] No unrelated changes in the PR
|
|
113
113
|
- [ ] Existing tests still pass
|
|
114
114
|
|
|
@@ -181,7 +181,7 @@ Document **before** deploying:
|
|
|
181
181
|
{From Phase 1, 5 Whys final answer}
|
|
182
182
|
|
|
183
183
|
### Fix
|
|
184
|
-
- File: `path/to/file:line` ·
|
|
184
|
+
- File: `path/to/file:line` · Where: {file/module + its role in the project's own structure}
|
|
185
185
|
- Approach: {boundary defense / logic correction / data migration}
|
|
186
186
|
|
|
187
187
|
### Tests
|
|
@@ -356,7 +356,7 @@ Only after Step 4 is answered. The fix MUST:
|
|
|
356
356
|
- Be defensive at **trust boundaries** (cache, DB, external API, user input) — NOT in internal logic
|
|
357
357
|
- Handle the specific edge case found, without breaking the normal path
|
|
358
358
|
- Be small + reviewable
|
|
359
|
-
- Land
|
|
359
|
+
- Land where this codebase puts that kind of logic — match the surrounding module, not a textbook layer (see `_shared/read-project-first.md`)
|
|
360
360
|
|
|
361
361
|
### Boundary defense pattern
|
|
362
362
|
For data-shape bugs from external sources: validate / coerce at the adapter, not inside business logic.
|
|
@@ -400,7 +400,7 @@ For data-shape bugs from external sources: validate / coerce at the adapter, not
|
|
|
400
400
|
{Cache / DB / Concurrency / Runtime / Env / Multi-tenant — or "none"}
|
|
401
401
|
|
|
402
402
|
### Fix
|
|
403
|
-
- File: `path/to/file:line` ·
|
|
403
|
+
- File: `path/to/file:line` · Where: {file/module + its role in the project's own structure}
|
|
404
404
|
- Approach: {boundary defense / type coercion / locking / cache invalidation / etc.}
|
|
405
405
|
- Why this is root-cause, not symptom: {explanation}
|
|
406
406
|
|
|
@@ -26,12 +26,11 @@ TRIAGE → INVESTIGATE → MITIGATE → RESOLVE → POSTMORTEM
|
|
|
26
26
|
comms comms comms comms learn
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
## Read
|
|
29
|
+
## Read the affected service first
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
1.
|
|
33
|
-
2.
|
|
34
|
-
3. Runbook for the affected component (`docs/runbooks/` or wiki)
|
|
31
|
+
See `~/.claude/architecture/_shared/read-project-first.md`. Mid-incident, skip architecture theory — you only need what helps you mitigate fast:
|
|
32
|
+
1. Stack-specific doc for the affected service (commands + conventions, if unfamiliar)
|
|
33
|
+
2. Runbook for the affected component (`docs/runbooks/` or wiki)
|
|
35
34
|
|
|
36
35
|
## Severity
|
|
37
36
|
|
|
@@ -22,9 +22,9 @@ One skill for the three ways to reduce the unknown: read the web, build a throwa
|
|
|
22
22
|
- ❌ Debugging a known bug → `/fix-bug` (DEEP mode)
|
|
23
23
|
- ❌ Generate a full docs site → `/docs-sync`
|
|
24
24
|
|
|
25
|
-
## Read
|
|
25
|
+
## Read the project first (all modes)
|
|
26
26
|
|
|
27
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md
|
|
27
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md` for commands. Then see `~/.claude/architecture/_shared/read-project-first.md`: let the codebase reveal its own pattern — don't preload a DDD lens. (WEB only needs the stack to filter queries; ONBOARDING's whole job is to discover the *real* pattern, so preloading DDD works against it.)
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
---
|
|
@@ -67,7 +67,7 @@ IDENTIFY → DETECT STACK → SEARCH → SYNTHESIZE → PROPOSE
|
|
|
67
67
|
|
|
68
68
|
## Step 2: DETECT STACK
|
|
69
69
|
|
|
70
|
-
Capture for filter use: language + version, framework + version, architecture pattern (DDD
|
|
70
|
+
Capture for filter use: language + version, framework + version, architecture pattern (whatever it is — MVC, CRUD, feature-folder, layered, DDD/hexagonal…), hard constraints (license, runtime, infra).
|
|
71
71
|
|
|
72
72
|
## Step 3: SEARCH
|
|
73
73
|
|
|
@@ -191,7 +191,7 @@ Lock the question, success criteria, timebox. Without these the spike has no exi
|
|
|
191
191
|
### Timebox
|
|
192
192
|
- Quick: 2-4h · Standard: 1-2d · Deep: 3-5d (rare — scope likely too big)
|
|
193
193
|
### Red flags (stop early if hit)
|
|
194
|
-
- Scope creep into productionising · Option breaks
|
|
194
|
+
- Scope creep into productionising · Option breaks the project's existing constraints/conventions · Options converge after 1h
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
### Gate
|
|
@@ -229,7 +229,7 @@ Build the smallest thing that answers the question.
|
|
|
229
229
|
|-----------|----------|----------|-------|
|
|
230
230
|
| Success criterion 1 (latency) | 42ms ✅ | 87ms ❌ | A at 1k rps |
|
|
231
231
|
| Success criterion 2 (effort) | 1 sprint | 3 sprints | B needs new dep |
|
|
232
|
-
| Fit with architecture | ✅ | ⚠️
|
|
232
|
+
| Fit with existing architecture | ✅ | ⚠️ needs structural change | |
|
|
233
233
|
| Risk | low | medium | |
|
|
234
234
|
|
|
235
235
|
### ADR template
|
|
@@ -303,14 +303,14 @@ git shortlog -sn --since=3months | head -10
|
|
|
303
303
|
### Read in this order
|
|
304
304
|
1. `README.md` — purpose + setup
|
|
305
305
|
2. `ARCHITECTURE.md` / `CONTRIBUTING.md` if present
|
|
306
|
-
3. **One existing module end-to-end** — smallest
|
|
307
|
-
4.
|
|
306
|
+
3. **One existing module end-to-end** — the smallest representative one. Trace it through whatever layers the project *actually* has (e.g. MVC: route → controller → model → view → test; feature-folder: the feature's own files; DDD: entity → port → usecase → handler → test).
|
|
307
|
+
4. How the pieces are wired together (router / DI / event bus registration, imports — however this project connects things)
|
|
308
308
|
5. CI config (`.github/workflows/`, `Makefile`) — what's enforced?
|
|
309
309
|
|
|
310
310
|
**Capture:** architecture pattern, naming conventions, where business logic lives, how errors are returned, test framework + folder convention, how code reaches prod.
|
|
311
311
|
|
|
312
312
|
### Gate
|
|
313
|
-
- [ ] One module read end-to-end ·
|
|
313
|
+
- [ ] One module read end-to-end · The project's actual structure understood (layers if it has any) · Test + CI conventions known
|
|
314
314
|
|
|
315
315
|
## Phase 3: EXPLAIN
|
|
316
316
|
|
|
@@ -323,18 +323,18 @@ Produce a 1-page mental model someone else can read.
|
|
|
323
323
|
### Stack
|
|
324
324
|
- Language / Framework / DB / Infra
|
|
325
325
|
### Architecture
|
|
326
|
-
{1 sentence
|
|
327
|
-
{ascii or mermaid:
|
|
328
|
-
###
|
|
329
|
-
|
|
|
326
|
+
{1 sentence describing the REAL pattern you saw — e.g. "MVC: fat models, thin controllers" / "feature-folders, hooks + services" / "DDD hexagonal — domain-pure, infra implements ports"}
|
|
327
|
+
{ascii or mermaid: diagram of the project's actual structure}
|
|
328
|
+
### Main parts
|
|
329
|
+
| Module / feature / package | Responsibility |
|
|
330
330
|
### Where to find things
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
| Add
|
|
335
|
-
| Add
|
|
336
|
-
| Add a
|
|
337
|
-
| Add a test |
|
|
331
|
+
Fill "Look in" from the REAL paths you found — these rows are prompts, not a required layout.
|
|
332
|
+
| If you need to... | Look in (this project) |
|
|
333
|
+
|-------------------|------------------------|
|
|
334
|
+
| Add a route / endpoint | `{where routes actually live}` |
|
|
335
|
+
| Add business logic | `{where this project puts logic — service / model / usecase…}` |
|
|
336
|
+
| Add a DB query | `{where data access lives}` |
|
|
337
|
+
| Add a test | `{project's test location + naming}` |
|
|
338
338
|
### Conventions
|
|
339
339
|
- Error handling / Logging / Config / Branch + commit
|
|
340
340
|
### Gotchas
|
|
@@ -349,7 +349,7 @@ Produce a 1-page mental model someone else can read.
|
|
|
349
349
|
Unblock the first real change. Pick a "quick win" (≤30 min, one layer, clear success criterion).
|
|
350
350
|
|
|
351
351
|
- [ ] Local env runs: build + lint + tests all green from a fresh clone
|
|
352
|
-
- [ ] Made the change in the right
|
|
352
|
+
- [ ] Made the change in the right place (per Phase 3 table)
|
|
353
353
|
- [ ] Added or updated 1 test
|
|
354
354
|
- [ ] Followed naming + error-handling conventions
|
|
355
355
|
- [ ] Commit message matches project style (`git log --oneline`)
|
|
@@ -21,16 +21,16 @@ One skill covering the full review surface. Pick the mode that matches your situ
|
|
|
21
21
|
- ❌ Security-only sweep → use `@security-audit` agent
|
|
22
22
|
- ❌ Bug surfaced by review → use `/fix-bug`
|
|
23
23
|
|
|
24
|
-
## Read
|
|
24
|
+
## Read the project first (all modes)
|
|
25
25
|
|
|
26
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md
|
|
26
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md` for build/lint/test commands. Then see `~/.claude/architecture/_shared/read-project-first.md`: **review against the pattern the codebase ACTUALLY uses** — read 1–2 existing modules of the same kind and judge the changes for consistency with them. Load `ddd-architecture.md` + its rule set **only when the project is genuinely DDD** (or the task asks to move toward it) — a CRUD/MVC repo is not "non-compliant", it just isn't DDD. Severity definitions: `~/.claude/architecture/_shared/severity-levels.md` (code severity table).
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
---
|
|
30
30
|
|
|
31
31
|
# Mode SELF
|
|
32
32
|
|
|
33
|
-
Self-review your branch vs a base branch before pushing or opening a PR. Checks architecture
|
|
33
|
+
Self-review your branch vs a base branch before pushing or opening a PR. Checks consistency with the codebase's existing architecture, stack conventions, and code quality — on **changed files only**, not the whole codebase.
|
|
34
34
|
|
|
35
35
|
**ARGUMENTS:** (optional) base branch. Default: `main` (fallback to `master`).
|
|
36
36
|
|
|
@@ -42,8 +42,9 @@ Self-review your branch vs a base branch before pushing or opening a PR. Checks
|
|
|
42
42
|
|
|
43
43
|
## Phase 0: DETECT
|
|
44
44
|
- [ ] Stack detected (ask user if ambiguous, e.g., monorepo)
|
|
45
|
-
- [ ]
|
|
46
|
-
- [ ]
|
|
45
|
+
- [ ] Read ≥1 existing module of the same kind — learn the project's real pattern
|
|
46
|
+
- [ ] Build / lint / test commands known
|
|
47
|
+
- [ ] (If the project is DDD) forbidden-imports list extracted
|
|
47
48
|
|
|
48
49
|
## Phase 1: COLLECT
|
|
49
50
|
|
|
@@ -56,7 +57,7 @@ git diff "$BASE"...HEAD --stat
|
|
|
56
57
|
git diff "$BASE"...HEAD --name-only --diff-filter=ACMR
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
Categorize changed files by
|
|
60
|
+
Categorize changed files by how this repo groups code (feature-folder, MVC, layers…) — the table below is an example for layered/DDD repos, not a required shape:
|
|
60
61
|
|
|
61
62
|
| Layer | Typical paths |
|
|
62
63
|
|-------|---------------|
|
|
@@ -83,6 +84,10 @@ Run the stack's build + typecheck + lint commands. If any fail → mark **CRITIC
|
|
|
83
84
|
|
|
84
85
|
## Phase 3: ARCHITECTURE (changed files only)
|
|
85
86
|
|
|
87
|
+
> **Gate first — is this project actually DDD/layered?** (Does it have `domain/`, `ports/`, `usecases/`, entities with behavior?)
|
|
88
|
+
> - **No** → skip the D/A/I/M rule tables below. Review one question instead: *do the changed files stay consistent with how this codebase already organizes similar code* — same structure, same place for business logic, same naming, same test style? Flag inconsistencies with the repo, not missing DDD constructs.
|
|
89
|
+
> - **Yes** (or the task is refactor-to-DDD) → run the rule tables below.
|
|
90
|
+
|
|
86
91
|
### 3.1 Domain (if changed)
|
|
87
92
|
| # | Rule |
|
|
88
93
|
|---|------|
|
|
@@ -253,11 +258,11 @@ gh pr view $PR --comments
|
|
|
253
258
|
## Phase 3: REVIEW — 5 dimensions
|
|
254
259
|
|
|
255
260
|
### 3.1 Architecture (CRITICAL / HIGH)
|
|
256
|
-
-
|
|
257
|
-
-
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
- **For deep DDD audit:** switch to **Mode ARCHITECT** and link result.
|
|
261
|
+
- Code follows the architecture the rest of the repo already uses — business logic sits where this codebase puts it (service / model / controller / usecase — whatever it uses), not in the wrong place
|
|
262
|
+
- No new cross-module coupling the codebase otherwise avoids
|
|
263
|
+
- Async work uses background context, not request context
|
|
264
|
+
- **If the repo is DDD:** domain has zero framework imports, no cross-domain imports, ports in `ports/`, entities raise events on state changes
|
|
265
|
+
- **For deep DDD audit (DDD repos only):** switch to **Mode ARCHITECT** and link result.
|
|
261
266
|
|
|
262
267
|
### 3.2 Security (CRITICAL / HIGH)
|
|
263
268
|
- Input validation at trust boundary (handler / DTO)
|
|
@@ -277,7 +282,7 @@ gh pr view $PR --comments
|
|
|
277
282
|
- Synchronous external API calls have timeouts
|
|
278
283
|
|
|
279
284
|
### 3.4 Testing (HIGH / MEDIUM)
|
|
280
|
-
- New business logic has unit tests (
|
|
285
|
+
- New business logic has unit tests (whatever unit holds it — usecase / service / model)
|
|
281
286
|
- New endpoints have at least 1 integration test (happy + error)
|
|
282
287
|
- Tests assert on behavior, not implementation
|
|
283
288
|
- Tests don't depend on order, time, or env
|
|
@@ -369,6 +374,17 @@ RESOLVE → LOAD RULES → AUTOMATED CHECKS → MANUAL REVIEW → REPORT → FIX
|
|
|
369
374
|
### Gate
|
|
370
375
|
- [ ] Architecture file loaded · Domain identified (if scoped)
|
|
371
376
|
|
|
377
|
+
## Phase 0.5: CONFIRM DDD INTENT (before scoring)
|
|
378
|
+
|
|
379
|
+
ARCHITECT scores against DDD. First confirm the project is actually *trying* to be DDD — otherwise the A–F score is meaningless: a clean CRUD/MVC app would score **F** for "missing" constructs it was never meant to have.
|
|
380
|
+
|
|
381
|
+
Check: does the codebase have `domain/` + `ports/` + `usecases/` (or clear equivalents)? Do existing entities carry behavior? Any doc/convention declaring DDD?
|
|
382
|
+
- **Yes** (or the task explicitly asks to audit/refactor toward DDD) → run Phase 1–5, score A–F against DDD rules as written.
|
|
383
|
+
- **No** → **STOP** the DDD scoring. Tell the user: *"This repo isn't DDD — it uses {actual pattern: MVC / feature-folder / CRUD…}. Scoring it against DDD would produce a false F."* Then offer: **(a)** review against the repo's OWN pattern — score internal consistency (do new modules match existing ones in structure / naming / wiring?), **(b)** proceed with the DDD scale anyway (only if there's a real intent to migrate), or **(c)** stop.
|
|
384
|
+
|
|
385
|
+
### Gate
|
|
386
|
+
- [ ] Project's real architecture identified · DDD intent confirmed OR user picked a path
|
|
387
|
+
|
|
372
388
|
## Phase 1: LOAD RULES
|
|
373
389
|
|
|
374
390
|
Read `ddd-architecture.md` (core) + the stack doc. Extract: DDD directory layout, layer import rules + forbidden imports, hard rules (HR1-HR15), stack-specific check scripts, wiring + test patterns.
|
|
@@ -423,7 +439,7 @@ Focus on **architecture structure**, not business correctness. 10 areas:
|
|
|
423
439
|
| **B** | 0 CRITICAL/HIGH, max 3 MEDIUM |
|
|
424
440
|
| **C** | 0 CRITICAL, max 2 HIGH |
|
|
425
441
|
| **D** | Has CRITICAL or 3+ HIGH |
|
|
426
|
-
| **F** | Multiple CRITICAL — architecture broken |
|
|
442
|
+
| **F** | Multiple CRITICAL — architecture broken *against the project's own DDD goal* (never "isn't DDD"; see Phase 0.5) |
|
|
427
443
|
|
|
428
444
|
## Phase 5: FIX LOOP (if user confirms)
|
|
429
445
|
|
|
@@ -485,7 +501,9 @@ Red-Green-Refactor cycle: write failing test → write minimal code to pass →
|
|
|
485
501
|
### Gate
|
|
486
502
|
- [ ] All tests still green · No new public API added · Code easier to read
|
|
487
503
|
|
|
488
|
-
## Test patterns per layer (DDD)
|
|
504
|
+
## Test patterns per layer (example: DDD layering)
|
|
505
|
+
|
|
506
|
+
If the project isn't DDD, map these rows to the units it actually has (model / service / controller / component…).
|
|
489
507
|
|
|
490
508
|
| Layer | Test type | Dependencies |
|
|
491
509
|
|-------|-----------|--------------|
|
|
@@ -563,7 +581,7 @@ Ambiguous comment ("this feels off")? Ask the reviewer for specifics before gues
|
|
|
563
581
|
- One concern per commit (`fix(handler): validate input in DTO per #pr-comment-1`)
|
|
564
582
|
- After each batch: run build + lint + tests locally
|
|
565
583
|
- Re-run **Mode SELF** before pushing
|
|
566
|
-
- **Structural change requested** (move logic between layers,
|
|
584
|
+
- **Structural change requested** (move logic between the repo's layers, restructure a module) → use `/feature-build` (REFACTOR mode) for that subtree, then come back to respond
|
|
567
585
|
|
|
568
586
|
### Gate
|
|
569
587
|
- [ ] All must-fix items addressed · Build + lint + tests green · Self-review clean
|
|
@@ -595,7 +613,7 @@ After replying, mark threads resolved. Don't leave dangling threads.
|
|
|
595
613
|
- **Match severity honestly** — don't grade-inflate to push for a fix; one severity per finding.
|
|
596
614
|
- **Always include "what went well"** in PR reviews — pure-criticism reviews demoralize.
|
|
597
615
|
- **Don't bikeshed style** when the team has a linter — let the tool flag it.
|
|
598
|
-
- **ARCHITECT:** all CRITICAL/HIGH fixed before merge; MEDIUM allowed with explicit waiver; don't skip manual review.
|
|
616
|
+
- **ARCHITECT:** confirm DDD intent (Phase 0.5) before scoring — never grade a non-DDD repo as "broken"; all CRITICAL/HIGH fixed before merge; MEDIUM allowed with explicit waiver; don't skip manual review.
|
|
599
617
|
- **TDD:** RED first always; minimal GREEN; REFACTOR is a phase, not optional; test behavior not implementation; unit tests <100ms.
|
|
600
618
|
- **ADDRESS:** reply to every comment; push back politely with a real reason; one concern per commit.
|
|
601
619
|
|
|
@@ -612,7 +630,7 @@ After replying, mark threads resolved. Don't leave dangling threads.
|
|
|
612
630
|
|
|
613
631
|
| Mode / Phase | Agent | Purpose |
|
|
614
632
|
|--------------|-------|---------|
|
|
615
|
-
| SELF/PR Architecture | `@clean-architect` | DDD compliance |
|
|
633
|
+
| SELF/PR Architecture | `@clean-architect` | Consistency with the repo's architecture (DDD compliance if it's a DDD repo) |
|
|
616
634
|
| SELF/PR Security | `@security-audit` | Vulnerability sweep |
|
|
617
635
|
| PR Performance | `@perf-optimizer` | N+1, indexes, slow paths |
|
|
618
636
|
| Quality | `@code-reviewer` | Code smells |
|