@brunosps00/dev-workflow 1.0.0 → 1.0.1
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 +2 -0
- package/package.json +1 -1
- package/scaffold/en/agent-instructions.md +7 -3
- package/scaffold/en/commands/dw-brainstorm.md +166 -23
- package/scaffold/pt-br/agent-instructions.md +7 -3
- package/scaffold/pt-br/commands/dw-brainstorm.md +166 -23
- package/scaffold/skills/dw-simplification/SKILL.md +10 -5
- package/scaffold/skills/dw-simplification/references/deep-modules.md +105 -0
package/README.md
CHANGED
|
@@ -262,6 +262,8 @@ Incident response (`dw-incident-response`) adapted from [`wilsto/claude-code-sta
|
|
|
262
262
|
|
|
263
263
|
LLM evaluation (`dw-llm-eval`) trajectory-match modes (strict / unordered / subset / superset) and tool-argument matching strategies adapted from [`langchain-ai/agentevals`](https://github.com/langchain-ai/agentevals) (MIT). The broader oracle-ladder framing, judge-calibration discipline, and reference-dataset principle are distilled from the open evaluations literature (OpenAI evals cookbook, Anthropic evals guidance, the academic eval-of-LLM body of work) and rewritten in our voice.
|
|
264
264
|
|
|
265
|
+
Four patterns from [`mattpocock/skills`](https://github.com/mattpocock/skills) by Matt Pocock (MIT) were integrated **without adding new commands or skills** — instead they fold into the existing surface as internal modes and inline guidance: (1) **grill-with-docs** → `/dw-brainstorm` `grill` mode (interview discipline that stress-tests plan vocabulary against `.dw/rules/`); (2) **prototype** → `/dw-brainstorm` `prototype` mode (LOGIC terminal app or UI variant dispatch); (3) **improve-codebase-architecture** → `dw-simplification/references/deep-modules.md` (deletion test, locality, leverage, seam, adapter diagnostic invoked by the `refactor-audit` mode); (4) **zoom-out** → one-paragraph guidance in `agent-instructions.md`. The same release also collapses `/dw-brainstorm`'s six legacy flags into a single full-flow entry point that auto-dispatches modes based on project signals.
|
|
266
|
+
|
|
265
267
|
## Migration from v0.x (1.0.0 is a consolidation release)
|
|
266
268
|
|
|
267
269
|
v1.0.0 consolidates 30 commands → 20. **The `dev-workflow update` command auto-removes obsolete wrappers** via the migrator that landed in v0.13.0; no manual action required.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brunosps00/dev-workflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "AI-driven development workflow commands for any project. Scaffolds a complete PRD-to-PR pipeline with multi-platform AI assistant support.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dev-workflow": "./bin/dev-workflow.js"
|
|
@@ -26,9 +26,7 @@ This project uses [`@brunosps00/dev-workflow`](https://www.npmjs.com/package/@br
|
|
|
26
26
|
| "Just the code quality review" | `/dw-review --code-only` |
|
|
27
27
|
| "Time to commit" / changes are validated and ready | `/dw-commit` |
|
|
28
28
|
| "Open a PR" / "Ship this" | `/dw-generate-pr` |
|
|
29
|
-
| "Brainstorm X" / "Explore ideas" | `/dw-brainstorm "X"` |
|
|
30
|
-
| "Research X" / "Compare A vs B with citations" | `/dw-brainstorm --research "X"` |
|
|
31
|
-
| "Code-health audit" / "Find tech debt" / "Refactoring opportunities" | `/dw-brainstorm --refactor` |
|
|
29
|
+
| "Brainstorm X" / "Explore ideas" / "Research X" / "Code-health audit" / "Find tech debt" | `/dw-brainstorm "X"` (auto-dispatches grill / prototype / council / research / refactor-audit / onepager based on signals) |
|
|
32
30
|
| "Where is X?" / "What uses Y?" / "How is Z structured?" | `/dw-intel "<question>"` |
|
|
33
31
|
| "Rebuild the codebase index" / "Refresh intel" | `/dw-intel --build` |
|
|
34
32
|
| "Redesign this UI" / "Audit and ship a new design" | `/dw-redesign-ui "<target>"` |
|
|
@@ -58,6 +56,12 @@ When any of these apply, answer directly and do **not** invoke a `dw-*` command:
|
|
|
58
56
|
- User explicitly says "do this directly" / "skip autopilot" / "no need for a PRD" — honor it.
|
|
59
57
|
- The conversation is already inside a `dw-*` flow (you're already executing tasks; don't start a new pipeline).
|
|
60
58
|
|
|
59
|
+
## Zoom-out pattern (for unfamiliar code areas)
|
|
60
|
+
|
|
61
|
+
When you land in an area of the codebase you don't know and orientation costs more than the task itself, **don't dive into files first** — ask an exploring agent to produce a map. Give it the project's domain glossary (`.dw/rules/index.md`) and tell it: "zoom out one level — show me the relevant modules, their public surfaces, who calls them, and the data flow between them, using domain glossary vocabulary." Get the lay of the land, then dive. This avoids the trap of reading the deepest file first and reconstructing the architecture from leaves upward.
|
|
62
|
+
|
|
63
|
+
Adapted from [`mattpocock/skills/zoom-out`](https://github.com/mattpocock/skills/tree/main/zoom-out) (MIT).
|
|
64
|
+
|
|
61
65
|
## Workflow Reference
|
|
62
66
|
|
|
63
67
|
```
|
|
@@ -11,14 +11,34 @@ You are a brainstorming facilitator for the current workspace. This command exis
|
|
|
11
11
|
## Pipeline Position
|
|
12
12
|
**Predecessor:** (user idea) | **Successor:** `/dw-plan prd`
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## How this command works (auto-dispatch, not flag switchboard)
|
|
15
15
|
|
|
16
|
-
- **
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
`/dw-brainstorm` runs **FULL** by default. It opens with a **Signal Reading** phase that inspects the user's request, the project state (PRDs, rules, intel, recent commits), and the conversation so far, then **dispatches one or more internal modes**. The user does not pick a mode — the command does.
|
|
17
|
+
|
|
18
|
+
Internal modes (the dispatcher picks 1+):
|
|
19
|
+
|
|
20
|
+
| Mode | Auto-fires when |
|
|
21
|
+
|------|-----------------|
|
|
22
|
+
| **option-matrix** (always-on default) | Default surface: 3-7 options (conservative / balanced / bold) with `[IMPROVES] / [CONSOLIDATES] / [NEW]` tags. Always runs unless a hard override says otherwise. |
|
|
23
|
+
| **grill** | Vocabulary feels unsettled — user terms differ from `.dw/rules/` / `.dw/constitution.md`, or two synonyms compete in the same conversation, or a contributor proposes a name that clashes with the glossary. |
|
|
24
|
+
| **prototype** | User asks "is this state model right?" / "what should this look like?" with no clear answer; or the next sensible step is to RUN code, not write words. |
|
|
25
|
+
| **council** | Two or more competing approaches surface with no obvious winner; or consensus forms too quickly (false-consensus signal). |
|
|
26
|
+
| **research** | The question depends on external state-of-the-art ("what's the current best practice for X", multi-source comparisons, regulatory or framework landscape). |
|
|
27
|
+
| **refactor-audit** | User points at a directory or describes a code area as "messy", "needs cleanup", "tech debt"; or a quarterly health-check is requested. |
|
|
28
|
+
| **onepager** | The conversation has converged enough to deserve a durable product artifact (`.dw/spec/ideas/<slug>.md`); or the user signals they're about to call `/dw-plan prd` next. |
|
|
29
|
+
|
|
30
|
+
Modes can chain inside one session — grill can surface a design question that the dispatcher then sends to prototype; refactor-audit can produce findings that the dispatcher sends to council for stress-testing.
|
|
31
|
+
|
|
32
|
+
### Optional overrides (rarely needed)
|
|
33
|
+
|
|
34
|
+
- **`--mode=<name>`** — force a specific dispatch and skip Signal Reading. Names: `option-matrix`, `grill`, `prototype`, `council`, `research`, `refactor-audit`, `onepager`. Combine with `+` to chain explicitly: `--mode=grill+onepager`.
|
|
35
|
+
- **`--quiet`** — skip Signal Reading entirely and run only `option-matrix` as a minimal facilitator.
|
|
36
|
+
|
|
37
|
+
Power users who already know what they want can pass `--mode=`. Everyone else gets auto-dispatch by default — the command reads the room and acts.
|
|
38
|
+
|
|
39
|
+
### Migration note (transitional)
|
|
40
|
+
|
|
41
|
+
Old flag invocations (`--onepager`, `--council`, `--research`, `--refactor`, `--grill`, `--prototype`) remain accepted for one minor cycle and map to the equivalent `--mode=` value. New code should use `--mode=` or rely on auto-dispatch.
|
|
22
42
|
|
|
23
43
|
## Decision Flowchart: Brainstorm vs Direct PRD
|
|
24
44
|
|
|
@@ -42,15 +62,16 @@ digraph brainstorm_decision {
|
|
|
42
62
|
|
|
43
63
|
When available in the project under `./.agents/skills/`, use these skills to enrich ideation:
|
|
44
64
|
|
|
45
|
-
- `dw-council
|
|
46
|
-
- `dw-
|
|
47
|
-
- `
|
|
48
|
-
- `
|
|
65
|
+
- `dw-council`: invoked by the dispatcher's **council** mode — multi-advisor stress-test of the most promising options with mandatory steel-manning and concession tracking. The dispatcher fires it when 2+ paths tie OR consensus forms too quickly (false-consensus signal). Not invoked on every brainstorm — only when signals justify it.
|
|
66
|
+
- `dw-simplification`: invoked by the dispatcher's **refactor-audit** mode — applies Chesterton's Fence + complexity metrics + the new **deep-modules** reference (deletion test, locality, leverage, interface depth) to every flagged smell.
|
|
67
|
+
- `dw-ui-discipline`: use when brainstorming involves frontend or UI direction — its hard-gate (scene sentence, surface job) is a generative forcing function during ideation, not just a review check. Also picked up by the **prototype** mode's UI branch.
|
|
68
|
+
- `vercel-react-best-practices`: use when brainstorming React/Next.js architecture or performance trade-offs.
|
|
69
|
+
- `security-review`: use when brainstorming touches auth, data handling, or security-sensitive features.
|
|
49
70
|
|
|
50
71
|
## Template Reference
|
|
51
72
|
|
|
52
73
|
- Brainstorm matrix template: `.dw/templates/brainstorm-matrix.md` (relative to workspace root)
|
|
53
|
-
- Durable one-pager template: `.dw/templates/idea-onepager.md` (used
|
|
74
|
+
- Durable one-pager template: `.dw/templates/idea-onepager.md` (used by the **onepager** mode)
|
|
54
75
|
|
|
55
76
|
Use this command when the user wants to:
|
|
56
77
|
- Generate ideas for product, UX, architecture, or automation
|
|
@@ -63,6 +84,19 @@ Use this command when the user wants to:
|
|
|
63
84
|
|
|
64
85
|
<critical>The brainstorm is a **product-level** phase, not technical. DO NOT dive into architecture, stack, endpoints, schemas. That's the techspec's job. Here we work user journeys, value, features, and boundaries.</critical>
|
|
65
86
|
|
|
87
|
+
### 0. Signal Reading (always first, unless `--quiet` or explicit `--mode=`)
|
|
88
|
+
|
|
89
|
+
Before producing any output, **read the situation**:
|
|
90
|
+
|
|
91
|
+
1. Inspect `.dw/spec/prd-*/`, `.dw/rules/`, `.dw/constitution.md`, `.dw/intel/` if they exist. Note the project's current vocabulary and recent PRDs.
|
|
92
|
+
2. Inspect recent git activity (`git log --oneline -20`) to detect ongoing work.
|
|
93
|
+
3. Re-read the user's request against the Auto-Dispatch table at the top of this file. Match signals to modes.
|
|
94
|
+
4. Decide the dispatch: **option-matrix** always runs unless an explicit mode override skips it. Other modes (grill, prototype, council, research, refactor-audit, onepager) fire **additively** when their signals are present.
|
|
95
|
+
5. State the dispatch decision to the user in one short line: e.g., "Dispatching: option-matrix + onepager (PRD is one step away)" or "Dispatching: grill (vocabulary unsettled in current PRD)". Do not bury this — surface it before running.
|
|
96
|
+
6. Then proceed with the modes in this order (when chained): grill → research → option-matrix → council → refactor-audit → prototype → onepager. Skip modes not in the dispatch.
|
|
97
|
+
|
|
98
|
+
### Standard flow (option-matrix mode)
|
|
99
|
+
|
|
66
100
|
1. Start by summarizing the problem in 1 to 3 sentences.
|
|
67
101
|
2. **Reframe as "How Might We"**: turn the raw idea into `How might we [verb] for [user] so that [outcome]?`. This pulls the team out of premature "solution mode".
|
|
68
102
|
3. **Product Inventory (required if the product exists)**:
|
|
@@ -80,7 +114,7 @@ Use this command when the user wants to:
|
|
|
80
114
|
- Approximate effort level
|
|
81
115
|
7. Whenever it makes sense, include conservative, balanced, and bold alternatives.
|
|
82
116
|
8. Close with a pragmatic recommendation and clear next steps.
|
|
83
|
-
9. **If the
|
|
117
|
+
9. **If the dispatcher selected `onepager` mode** (auto-fires when conversation has converged enough, or user signals they're heading to `/dw-plan prd` next): at the end, generate `.dw/spec/ideas/<slug>.md` using `.dw/templates/idea-onepager.md`, filling Feature Inventory, Classification & Rationale, Recommended Direction (product language), MVP Scope (user stories), Not Doing, Key Assumptions, and Open Questions. Report the path to the user.
|
|
84
118
|
|
|
85
119
|
## Preferred Response Format
|
|
86
120
|
|
|
@@ -104,7 +138,7 @@ Use this command when the user wants to:
|
|
|
104
138
|
- Recommend 1 or 2 paths
|
|
105
139
|
- Explain why they win in the current context
|
|
106
140
|
|
|
107
|
-
### 6. One-pager (if
|
|
141
|
+
### 6. One-pager (if `onepager` mode fired)
|
|
108
142
|
- Path of the created file at `.dw/spec/ideas/<slug>.md`
|
|
109
143
|
|
|
110
144
|
### 7. Next Steps
|
|
@@ -141,13 +175,15 @@ At the end, always leave the user in one of these situations:
|
|
|
141
175
|
- With a clear recommendation (including an IMPROVES/CONSOLIDATES/NEW classification)
|
|
142
176
|
- With better questions to decide
|
|
143
177
|
- With a next workspace command to follow
|
|
144
|
-
- With the one-pager at `.dw/spec/ideas/<slug>.md` (if
|
|
145
|
-
- With the research report at `~/Documents/<Topic>_Research_<date>/` (if
|
|
146
|
-
- With the refactor plan at `<target>/refactor-plan.md` (if
|
|
178
|
+
- With the one-pager at `.dw/spec/ideas/<slug>.md` (if **onepager** mode fired)
|
|
179
|
+
- With the research report at `~/Documents/<Topic>_Research_<date>/` (if **research** mode fired)
|
|
180
|
+
- With the refactor plan at `<target>/refactor-plan.md` (if **refactor-audit** mode fired)
|
|
181
|
+
- With sharpened glossary entries in `.dw/rules/` (if **grill** mode fired)
|
|
182
|
+
- With a runnable throwaway prototype + verdict template (if **prototype** mode fired)
|
|
147
183
|
|
|
148
|
-
## Mode:
|
|
184
|
+
## Mode: research (multi-source research)
|
|
149
185
|
|
|
150
|
-
|
|
186
|
+
Fires when the question depends on external state-of-the-art (multi-source comparisons, framework / regulatory landscape, decisions needing cited evidence). Override: `--mode=research`. Replaces the default option-matrix with a structured research pipeline that produces a cited document with verified claims.
|
|
151
187
|
|
|
152
188
|
<critical>Every factual claim MUST be cited immediately with [N] in the same sentence</critical>
|
|
153
189
|
<critical>NEVER fabricate citations — if no source is found, say so explicitly</critical>
|
|
@@ -165,7 +201,7 @@ Activated by the `--research` flag. Replaces the default brainstorm with a struc
|
|
|
165
201
|
```
|
|
166
202
|
Selection
|
|
167
203
|
├── Initial exploration → quick (3 phases, 2-5 min)
|
|
168
|
-
├── Standard research → standard (6 phases, 5-10 min) [DEFAULT for
|
|
204
|
+
├── Standard research → standard (6 phases, 5-10 min) [DEFAULT for research]
|
|
169
205
|
├── Critical decision → deep (8 phases, 10-20 min)
|
|
170
206
|
└── Comprehensive review → ultradeep (8+ phases, 20-45 min)
|
|
171
207
|
```
|
|
@@ -216,9 +252,9 @@ Target lengths: quick 2-4k words; standard 4-8k; deep 8-15k; ultradeep 15-20k+.
|
|
|
216
252
|
- Label speculation explicitly.
|
|
217
253
|
- Admit uncertainty: "No sources found for X."
|
|
218
254
|
|
|
219
|
-
## Mode:
|
|
255
|
+
## Mode: refactor-audit (code-smell catalog + deep-modules)
|
|
220
256
|
|
|
221
|
-
|
|
257
|
+
Fires when the user points at a directory or describes a code area as "messy" / "needs cleanup" / "tech debt", or when a quarterly health-check is requested. Override: `--mode=refactor-audit`. Audits the target area for refactoring opportunities using Martin Fowler's smell taxonomy combined with the deep-modules analysis (deletion test, locality, leverage, interface depth) bundled in the `dw-simplification` skill.
|
|
222
258
|
|
|
223
259
|
<critical>ASK EXACTLY 3 CLARIFICATION QUESTIONS BEFORE STARTING THE ANALYSIS</critical>
|
|
224
260
|
|
|
@@ -292,6 +328,111 @@ Saved to `<target>/refactor-plan.md`:
|
|
|
292
328
|
- Proposing refactors that aren't tested or testable → high risk, won't ship.
|
|
293
329
|
- Ignoring documented architectural decisions in `.dw/rules/` → flagging intentional design as smell.
|
|
294
330
|
|
|
331
|
+
## Mode: grill (domain-grilling)
|
|
332
|
+
|
|
333
|
+
Fires when vocabulary feels unsettled — user terms differ from `.dw/rules/` / `.dw/constitution.md`, two synonyms compete in the same conversation, or a contributor proposes a name that clashes with the glossary. Override: `--mode=grill`. Replaces the option-generation default with an **interview-style stress-test** of the plan/PRD against the project's domain vocabulary. Each round of questions sharpens one piece. Updates `.dw/rules/` (or `.dw/constitution.md`) inline as terms crystallize — never deferred to "after the conversation."
|
|
334
|
+
|
|
335
|
+
<critical>Ask ONE question at a time. Wait for the answer. Don't dump a list of 5 questions and hope for the best.</critical>
|
|
336
|
+
|
|
337
|
+
### When to use grill mode
|
|
338
|
+
|
|
339
|
+
- Before `/dw-plan prd` when the domain feels unsettled or the team uses competing terms.
|
|
340
|
+
- After `/dw-plan prd` when reviewers flag ambiguous language in the PRD.
|
|
341
|
+
- During architectural discussion when "module", "service", "component" are being used interchangeably and you need to pin the canonical term.
|
|
342
|
+
- When a contributor proposes a name that doesn't match the project's existing glossary.
|
|
343
|
+
|
|
344
|
+
### During-session disciplines
|
|
345
|
+
|
|
346
|
+
1. **Challenge against the glossary.** Read `.dw/rules/index.md` + per-module `.dw/rules/<module>.md` + `.dw/constitution.md`. Flag terminology conflicts the instant the user uses a term that differs from (or contradicts) what's already documented.
|
|
347
|
+
|
|
348
|
+
2. **Sharpen fuzzy language.** When the user says "the user thing" or "the order stuff", propose a precise canonical term. Don't pretend you understood — push back.
|
|
349
|
+
|
|
350
|
+
3. **Discuss concrete scenarios.** Force precision via specific edge cases: "What happens to the Order in state X when event Y arrives during retry Z?" Vague answers go back as further questions.
|
|
351
|
+
|
|
352
|
+
4. **Cross-reference code.** When the user states a behavior, glance at the codebase to confirm it. Surface contradictions: "You said the API returns `OrderId` but `src/api/orders.ts:42` returns `{ order_id, status }`." Don't argue from generalities.
|
|
353
|
+
|
|
354
|
+
5. **Update `.dw/rules/` inline.** When a term crystallizes, write it into the appropriate rules file in the same conversation turn. Lazy file creation: if the file doesn't exist, create it. Format follows the glossary discipline established by the project (see `.dw/rules/index.md` for shape).
|
|
355
|
+
|
|
356
|
+
6. **Skip implementation details in the glossary.** `.dw/rules/` and `.dw/constitution.md` describe vocabulary and principles — not implementation. "Order: a customer's request to purchase one or more items, in one of these states: pending, paid, shipped, delivered, refunded" is fine. "Order: a TypeScript class in `src/orders/`" is implementation leak.
|
|
357
|
+
|
|
358
|
+
### ADR creation discipline
|
|
359
|
+
|
|
360
|
+
Only propose an ADR via `/dw-adr` when **all three** hold:
|
|
361
|
+
|
|
362
|
+
| Criterion | Test |
|
|
363
|
+
|-----------|------|
|
|
364
|
+
| **Hard to reverse** | If we change this in 6 months, does it cost >1 week of work? |
|
|
365
|
+
| **Surprising without context** | Would a new contributor reasonably reach a different decision? |
|
|
366
|
+
| **Genuine trade-off** | Was there a real alternative we considered and chose against? |
|
|
367
|
+
|
|
368
|
+
If any is missing, skip the ADR. Don't ADR every casual decision — that turns the ADR folder into noise.
|
|
369
|
+
|
|
370
|
+
### Output
|
|
371
|
+
|
|
372
|
+
grill mode produces:
|
|
373
|
+
- **Updated `.dw/rules/<module>.md`** or `.dw/constitution.md` with crystallized terms.
|
|
374
|
+
- **Updated PRD / TechSpec** if grilling happens mid-plan (terms in the artifact are aligned with the glossary).
|
|
375
|
+
- **Optional `.dw/spec/<prd>/adrs/adr-NNN.md`** if criteria above hold.
|
|
376
|
+
- **NO** option matrix or recommendation (that's option-matrix mode; grill is purely about sharpening). If the dispatcher chained grill+option-matrix, the option matrix runs in a separate phase.
|
|
377
|
+
|
|
378
|
+
### When the discipline bends
|
|
379
|
+
|
|
380
|
+
- **Greenfield project with no `.dw/rules/`**: grill anyway; the conversation produces the FIRST entries in `.dw/rules/index.md`. That's the value.
|
|
381
|
+
- **Cosmetic terminology disagreements** ("should we call it `userId` or `user_id`?"): skip grill mode; use a coding-conventions ADR or `.dw/rules/index.md` Naming section.
|
|
382
|
+
|
|
383
|
+
## Mode: prototype (throwaway prototype)
|
|
384
|
+
|
|
385
|
+
Fires when the user asks "is this state model right?" / "what should this look like?" with no clear answer — i.e., the next sensible step is to RUN code, not write words. Override: `--mode=prototype`. Builds a **throwaway prototype that answers a single question**. The question decides the shape — pick a branch.
|
|
386
|
+
|
|
387
|
+
<critical>The prototype is throwaway from day one. Don't polish. Don't add tests. Don't extract abstractions. The point is to LEARN something fast and then DELETE or absorb.</critical>
|
|
388
|
+
|
|
389
|
+
### Pick a branch
|
|
390
|
+
|
|
391
|
+
| User's question | Branch |
|
|
392
|
+
|-----------------|--------|
|
|
393
|
+
| "Does this state/logic model feel right?" | **LOGIC** — interactive terminal app that pushes the state machine through edge cases that are hard to reason about on paper. |
|
|
394
|
+
| "What should this look like?" | **UI** — several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar. |
|
|
395
|
+
|
|
396
|
+
If the question is ambiguous, ask the user. If user not reachable: default by surrounding code (backend module → LOGIC; page/component → UI) and state the assumption at the top of the prototype.
|
|
397
|
+
|
|
398
|
+
### Rules (apply to both branches)
|
|
399
|
+
|
|
400
|
+
1. **Throwaway from day one, clearly marked.** Place the prototype next to the module/page it's prototyping for (so context is obvious) but name it so a casual reader can see it's a prototype (`prototype-<slug>.ts`, `prototype-route.tsx`, etc.).
|
|
401
|
+
|
|
402
|
+
2. **One command to run.** Whatever the project's task runner supports — `pnpm <name>`, `python <path>`, `bun <path>`, etc. The user must start it without thinking.
|
|
403
|
+
|
|
404
|
+
3. **No persistence by default.** State lives in memory. Persistence is what the prototype is CHECKING, not what it depends on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear `PROTOTYPE — wipe me` name.
|
|
405
|
+
|
|
406
|
+
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype runnable, no abstractions.
|
|
407
|
+
|
|
408
|
+
5. **Surface the state.** After every action (LOGIC) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
|
|
409
|
+
|
|
410
|
+
6. **Delete or absorb when done.** When the prototype has answered its question, either delete it or fold the validated decision into real code. Don't leave it rotting in the repo.
|
|
411
|
+
|
|
412
|
+
### When done
|
|
413
|
+
|
|
414
|
+
The **answer** is the only thing worth keeping. Capture it durably:
|
|
415
|
+
- Commit message that closes the prototype: "removed prototype X; decided <answer> based on <observation>"
|
|
416
|
+
- Or an ADR (if the criteria from grill mode hold)
|
|
417
|
+
- Or `.dw/spec/<prd>/NOTES.md` if mid-PRD
|
|
418
|
+
- Or an issue comment if user-driven
|
|
419
|
+
|
|
420
|
+
If the user isn't around, leave a `PROTOTYPE VERDICT: <pending>` placeholder so the next pass can fill it in before deletion.
|
|
421
|
+
|
|
422
|
+
### Output
|
|
423
|
+
|
|
424
|
+
prototype mode produces:
|
|
425
|
+
- **Throwaway code file(s)** in the appropriate location.
|
|
426
|
+
- A `NOTES.md` next to the prototype with the QUESTION it's answering.
|
|
427
|
+
- After the user runs it and answers the question, instructions to remove the prototype + capture the verdict.
|
|
428
|
+
|
|
429
|
+
### Anti-patterns
|
|
430
|
+
|
|
431
|
+
- Building a prototype that's actually a feature in disguise — production-quality code, tests, deployment config. That's not a prototype; it's a first draft.
|
|
432
|
+
- Leaving the prototype in the repo "in case we need it later" — six months later it's load-bearing.
|
|
433
|
+
- Not capturing the verdict — the prototype answered the question and the answer evaporated.
|
|
434
|
+
- Multiple prototypes stacked up at once — pick one question, answer it, move.
|
|
435
|
+
|
|
295
436
|
## Inspired by
|
|
296
437
|
|
|
297
438
|
The codebase-grounded idea refinement pattern is inspired by [`addyosmani/agent-skills@idea-refine`](https://skills.sh/addyosmani/agent-skills/idea-refine) (Addy Osmani, Google — 1.4K+ installs). Adaptations for dev-workflow:
|
|
@@ -301,6 +442,8 @@ The codebase-grounded idea refinement pattern is inspired by [`addyosmani/agent-
|
|
|
301
442
|
- Output at `.dw/spec/ideas/<slug>.md` (sibling of `prd-<slug>/`) instead of `docs/ideas/` — preserves dev-workflow path conventions.
|
|
302
443
|
- Integration with the existing pipeline: `/dw-plan prd` accepts the one-pager as input, reducing clarification questions.
|
|
303
444
|
|
|
304
|
-
|
|
445
|
+
The **grill** and **prototype** modes are adapted from [`mattpocock/skills/grill-with-docs`](https://github.com/mattpocock/skills/tree/main/grill-with-docs) and [`mattpocock/skills/prototype`](https://github.com/mattpocock/skills/tree/main/prototype) (Matt Pocock, MIT). dev-workflow adaptation: integrated as INTERNAL auto-dispatched modes rather than separate skills, paths rebased on `.dw/rules/` + `.dw/spec/<prd>/`, ADR creation gated on the 3-criteria test (hard-to-reverse + surprising + genuine trade-off).
|
|
446
|
+
|
|
447
|
+
Credit: Addy Osmani (idea-refine) and Matt Pocock (grill-with-docs, prototype).
|
|
305
448
|
|
|
306
449
|
</system_instructions>
|
|
@@ -26,9 +26,7 @@ Este projeto usa [`@brunosps00/dev-workflow`](https://www.npmjs.com/package/@bru
|
|
|
26
26
|
| "Só code review qualidade" | `/dw-review --code-only` |
|
|
27
27
|
| "Hora de commitar" / mudanças validadas e prontas | `/dw-commit` |
|
|
28
28
|
| "Abre um PR" / "Sobe isso" | `/dw-generate-pr` |
|
|
29
|
-
| "Brainstorm X" / "Explora ideias" | `/dw-brainstorm "X"` |
|
|
30
|
-
| "Research X" / "Compara A vs B com citações" | `/dw-brainstorm --research "X"` |
|
|
31
|
-
| "Auditoria de saúde do código" / "Tech debt" / "Oportunidades de refactor" | `/dw-brainstorm --refactor` |
|
|
29
|
+
| "Brainstorm X" / "Explora ideias" / "Research X" / "Auditoria de saúde do código" / "Tech debt" | `/dw-brainstorm "X"` (auto-dispatch dos modos grill / prototype / council / research / refactor-audit / onepager conforme os sinais) |
|
|
32
30
|
| "Onde está X?" / "O que usa Y?" / "Como Z é estruturado?" | `/dw-intel "<pergunta>"` |
|
|
33
31
|
| "Reconstrói o índice" / "Refresh do intel" | `/dw-intel --build` |
|
|
34
32
|
| "Redesign dessa UI" / "Audita e entrega novo design" | `/dw-redesign-ui "<target>"` |
|
|
@@ -58,6 +56,12 @@ Quando qualquer destes se aplica, responda direto e **não** invoque comando `dw
|
|
|
58
56
|
- Usuário diz explicitamente "faz direto" / "pula autopilot" / "não precisa de PRD" — honre.
|
|
59
57
|
- A conversa já está dentro de um fluxo `dw-*` (você já está executando tasks; não inicie pipeline novo).
|
|
60
58
|
|
|
59
|
+
## Padrão zoom-out (para áreas desconhecidas do código)
|
|
60
|
+
|
|
61
|
+
Quando você cai numa área do codebase que não conhece e a orientação custa mais que a tarefa em si, **não mergulhe nos arquivos primeiro** — peça a um agente de exploração que produza um mapa. Passe o glossário de domínio do projeto (`.dw/rules/index.md`) e diga: "zoom out de um nível — me mostra os módulos relevantes, suas superfícies públicas, quem chama, e o fluxo de dados entre eles, usando o vocabulário do glossário de domínio." Pegue a visão geral, e só então mergulhe. Isso evita a armadilha de ler o arquivo mais profundo primeiro e reconstruir a arquitetura das folhas pra cima.
|
|
62
|
+
|
|
63
|
+
Adaptado de [`mattpocock/skills/zoom-out`](https://github.com/mattpocock/skills/tree/main/zoom-out) (MIT).
|
|
64
|
+
|
|
61
65
|
## Referência de Workflow
|
|
62
66
|
|
|
63
67
|
```
|
|
@@ -11,14 +11,34 @@ Você é um facilitador de brainstorming para o workspace atual. Este comando ex
|
|
|
11
11
|
## Posição no Pipeline
|
|
12
12
|
**Antecessor:** (ideia do usuário) | **Sucessor:** `/dw-plan prd`
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Como este comando funciona (auto-dispatch, não switchboard de flags)
|
|
15
15
|
|
|
16
|
-
- **
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
`/dw-brainstorm` roda **FULL** por padrão. Abre com uma fase de **Signal Reading** que inspeciona o pedido do usuário, o estado do projeto (PRDs, rules, intel, commits recentes) e a conversa até agora, e então **dispara um ou mais modos internos**. O usuário não escolhe o modo — o comando escolhe.
|
|
17
|
+
|
|
18
|
+
Modos internos (o dispatcher seleciona 1+):
|
|
19
|
+
|
|
20
|
+
| Modo | Dispara automaticamente quando |
|
|
21
|
+
|------|--------------------------------|
|
|
22
|
+
| **option-matrix** (default sempre ativo) | Surface padrão: 3-7 opções (conservadora / equilibrada / ousada) com tags `[IMPROVES] / [CONSOLIDATES] / [NEW]`. Sempre roda salvo override explícito. |
|
|
23
|
+
| **grill** | Vocabulário está instável — termos do usuário divergem de `.dw/rules/` / `.dw/constitution.md`, ou dois sinônimos competem na mesma conversa, ou alguém propõe um nome que conflita com o glossário. |
|
|
24
|
+
| **prototype** | Usuário pergunta "esse modelo de estado faz sentido?" / "como isso deveria parecer?" sem resposta clara; ou o próximo passo razoável é RODAR código, não escrever palavras. |
|
|
25
|
+
| **council** | Duas ou mais abordagens competem sem vencedor óbvio; ou o consenso se forma rápido demais (sinal de false-consensus). |
|
|
26
|
+
| **research** | A pergunta depende de state-of-the-art externo ("qual é a best practice atual para X", comparações multi-fonte, landscape regulatório ou de framework). |
|
|
27
|
+
| **refactor-audit** | Usuário aponta um diretório ou descreve uma área como "bagunçada", "precisa de limpeza", "tech debt"; ou pede health-check trimestral. |
|
|
28
|
+
| **onepager** | A conversa convergiu o suficiente para merecer um artefato durável (`.dw/spec/ideas/<slug>.md`); ou o usuário sinaliza que vai chamar `/dw-plan prd` em seguida. |
|
|
29
|
+
|
|
30
|
+
Modos podem encadear numa sessão — grill pode revelar uma pergunta de design que o dispatcher manda para prototype; refactor-audit pode produzir findings que o dispatcher manda para council pra stress-test.
|
|
31
|
+
|
|
32
|
+
### Overrides opcionais (raramente necessários)
|
|
33
|
+
|
|
34
|
+
- **`--mode=<nome>`** — força um dispatch específico e pula Signal Reading. Nomes: `option-matrix`, `grill`, `prototype`, `council`, `research`, `refactor-audit`, `onepager`. Combine com `+` para encadear explicitamente: `--mode=grill+onepager`.
|
|
35
|
+
- **`--quiet`** — pula Signal Reading inteiramente e roda apenas `option-matrix` como facilitador mínimo.
|
|
36
|
+
|
|
37
|
+
Power users que já sabem o que querem podem passar `--mode=`. Todo mundo mais ganha auto-dispatch por padrão — o comando lê a situação e age.
|
|
38
|
+
|
|
39
|
+
### Nota de migração (transitória)
|
|
40
|
+
|
|
41
|
+
Invocações antigas com flags (`--onepager`, `--council`, `--research`, `--refactor`, `--grill`, `--prototype`) continuam aceitas por um ciclo minor e mapeiam para o `--mode=` equivalente. Código novo deve usar `--mode=` ou confiar no auto-dispatch.
|
|
22
42
|
|
|
23
43
|
## Fluxograma de Decisão: Brainstorm vs PRD Direto
|
|
24
44
|
|
|
@@ -42,15 +62,16 @@ digraph brainstorm_decision {
|
|
|
42
62
|
|
|
43
63
|
Quando disponíveis no projeto em `./.agents/skills/`, use para enriquecer a ideação:
|
|
44
64
|
|
|
45
|
-
- `dw-council
|
|
46
|
-
- `dw-
|
|
47
|
-
- `
|
|
48
|
-
- `
|
|
65
|
+
- `dw-council`: invocada pelo modo **council** do dispatcher — stress-test multi-advisor das opções mais promissoras com steel-manning obrigatório e concession tracking. O dispatcher dispara quando 2+ caminhos empatam OU consenso se forma rápido demais (sinal de false-consensus). Não roda em todo brainstorm — só quando os sinais justificam.
|
|
66
|
+
- `dw-simplification`: invocada pelo modo **refactor-audit** — aplica Chesterton's Fence + métricas de complexidade + a nova referência **deep-modules** (deletion test, locality, leverage, interface depth) em todo smell flagueado.
|
|
67
|
+
- `dw-ui-discipline`: use quando o brainstorm envolver frontend ou direção de UI — o hard-gate (scene sentence, surface job) é forcing function generativa durante ideação, não só check de review. Também usado pelo branch UI do modo **prototype**.
|
|
68
|
+
- `vercel-react-best-practices`: use quando explorar arquitetura React/Next.js ou trade-offs de performance.
|
|
69
|
+
- `security-review`: use quando o brainstorm tocar auth, manipulação de dados ou features sensíveis à segurança.
|
|
49
70
|
|
|
50
71
|
## Referência do Template
|
|
51
72
|
|
|
52
73
|
- Template da matriz de brainstorm: `.dw/templates/brainstorm-matrix.md` (relativo ao workspace root)
|
|
53
|
-
- Template do one-pager durável: `.dw/templates/idea-onepager.md` (usado
|
|
74
|
+
- Template do one-pager durável: `.dw/templates/idea-onepager.md` (usado pelo modo **onepager**)
|
|
54
75
|
|
|
55
76
|
Use este comando quando o usuario quiser:
|
|
56
77
|
- gerar ideias para produto, UX, arquitetura ou automacao
|
|
@@ -63,6 +84,19 @@ Use este comando quando o usuario quiser:
|
|
|
63
84
|
|
|
64
85
|
<critical>O brainstorm é fase **nível de produto**, não técnica. NÃO entre em arquitetura, stack, endpoints, schemas. Isso é trabalho do techspec. Aqui trabalhamos jornada do usuário, valor, features e fronteiras.</critical>
|
|
65
86
|
|
|
87
|
+
### 0. Signal Reading (sempre primeiro, exceto com `--quiet` ou `--mode=` explícito)
|
|
88
|
+
|
|
89
|
+
Antes de produzir qualquer output, **leia a situação**:
|
|
90
|
+
|
|
91
|
+
1. Inspecione `.dw/spec/prd-*/`, `.dw/rules/`, `.dw/constitution.md`, `.dw/intel/` se existirem. Anote vocabulário atual e PRDs recentes.
|
|
92
|
+
2. Inspecione git recente (`git log --oneline -20`) pra detectar trabalho em andamento.
|
|
93
|
+
3. Releia o pedido do usuário contra a tabela de Auto-Dispatch no topo desse arquivo. Casa sinais com modos.
|
|
94
|
+
4. Decida o dispatch: **option-matrix** sempre roda salvo override que pule. Outros modos (grill, prototype, council, research, refactor-audit, onepager) disparam **aditivamente** quando seus sinais estão presentes.
|
|
95
|
+
5. Diga ao usuário em uma linha curta qual o dispatch decidido: ex. "Dispatch: option-matrix + onepager (PRD está um passo à frente)" ou "Dispatch: grill (vocabulário instável no PRD atual)". Não esconda — surface antes de rodar.
|
|
96
|
+
6. Depois, execute os modos nessa ordem (quando encadeados): grill → research → option-matrix → council → refactor-audit → prototype → onepager. Pule modos fora do dispatch.
|
|
97
|
+
|
|
98
|
+
### Fluxo padrão (modo option-matrix)
|
|
99
|
+
|
|
66
100
|
1. Comece resumindo o problema em 1 a 3 frases.
|
|
67
101
|
2. **Reformule como "How Might We"**: transforme a ideia bruta em `How might we [verbo] para [usuário] de forma que [resultado]?`. Isso tira o time de "solution mode" prematuro.
|
|
68
102
|
3. **Product Inventory (obrigatório se o produto existe)**:
|
|
@@ -80,7 +114,7 @@ Use este comando quando o usuario quiser:
|
|
|
80
114
|
- nível de esforço aproximado
|
|
81
115
|
7. Sempre que fizer sentido, inclua alternativas conservadora, equilibrada e ousada.
|
|
82
116
|
8. Feche com recomendação pragmática e próximos passos claros.
|
|
83
|
-
9. **Se
|
|
117
|
+
9. **Se o dispatcher selecionou o modo `onepager`** (auto-dispara quando a conversa converge ou usuário sinaliza que vai pra `/dw-plan prd`): ao final, gerar `.dw/spec/ideas/<slug>.md` usando `.dw/templates/idea-onepager.md`, preenchendo Feature Inventory, Classification & Rationale, Recommended Direction (linguagem de produto), MVP Scope (user stories), Not Doing, Key Assumptions e Open Questions. Apresentar path ao usuário ao final.
|
|
84
118
|
|
|
85
119
|
## Formato de resposta preferido
|
|
86
120
|
|
|
@@ -104,7 +138,7 @@ Use este comando quando o usuario quiser:
|
|
|
104
138
|
- recomende 1 ou 2 caminhos
|
|
105
139
|
- diga por que eles vencem no contexto atual
|
|
106
140
|
|
|
107
|
-
### 6. One-pager (se
|
|
141
|
+
### 6. One-pager (se modo `onepager` disparou)
|
|
108
142
|
- path do arquivo criado em `.dw/spec/ideas/<slug>.md`
|
|
109
143
|
|
|
110
144
|
### 7. Próximos passos
|
|
@@ -141,13 +175,15 @@ Ao final, sempre deixe o usuario em uma destas situacoes:
|
|
|
141
175
|
- com uma recomendacao clara (incluindo classificação IMPROVES/CONSOLIDATES/NEW)
|
|
142
176
|
- com perguntas melhores para decidir
|
|
143
177
|
- com um proximo comando do workspace para seguir
|
|
144
|
-
- com o one-pager em `.dw/spec/ideas/<slug>.md` (se
|
|
145
|
-
- com o relatório de research em `~/Documents/<Tópico>_Research_<data>/` (se
|
|
146
|
-
- com o plano de refactor em `<target>/refactor-plan.md` (se
|
|
178
|
+
- com o one-pager em `.dw/spec/ideas/<slug>.md` (se modo **onepager** disparou)
|
|
179
|
+
- com o relatório de research em `~/Documents/<Tópico>_Research_<data>/` (se modo **research** disparou)
|
|
180
|
+
- com o plano de refactor em `<target>/refactor-plan.md` (se modo **refactor-audit** disparou)
|
|
181
|
+
- com entradas de glossário sharpened em `.dw/rules/` (se modo **grill** disparou)
|
|
182
|
+
- com um protótipo throwaway rodável + template de verdict (se modo **prototype** disparou)
|
|
147
183
|
|
|
148
|
-
## Modo:
|
|
184
|
+
## Modo: research (research multi-fonte)
|
|
149
185
|
|
|
150
|
-
|
|
186
|
+
Dispara quando a pergunta depende de state-of-the-art externo (comparações multi-fonte, framework/regulatory landscape, decisões precisando de evidência citada). Override: `--mode=research`. Substitui o option-matrix padrão por um pipeline estruturado de research que produz documento citado com claims verificados.
|
|
151
187
|
|
|
152
188
|
<critical>Cada afirmação factual DEVE ser citada imediatamente com [N] na mesma frase</critical>
|
|
153
189
|
<critical>NUNCA fabrique citações — se não encontrar fonte, diga explicitamente</critical>
|
|
@@ -165,7 +201,7 @@ Ativado pela flag `--research`. Substitui o brainstorm padrão por um pipeline e
|
|
|
165
201
|
```
|
|
166
202
|
Seleção
|
|
167
203
|
├── Exploração inicial → quick (3 fases, 2-5 min)
|
|
168
|
-
├── Research padrão → standard (6 fases, 5-10 min) [DEFAULT pra
|
|
204
|
+
├── Research padrão → standard (6 fases, 5-10 min) [DEFAULT pra research]
|
|
169
205
|
├── Decisão crítica → deep (8 fases, 10-20 min)
|
|
170
206
|
└── Review abrangente → ultradeep (8+ fases, 20-45 min)
|
|
171
207
|
```
|
|
@@ -216,9 +252,9 @@ Tamanhos-alvo: quick 2-4k palavras; standard 4-8k; deep 8-15k; ultradeep 15-20k+
|
|
|
216
252
|
- Rotular especulação explicitamente.
|
|
217
253
|
- Admitir incerteza: "Sem fontes encontradas para X."
|
|
218
254
|
|
|
219
|
-
## Modo:
|
|
255
|
+
## Modo: refactor-audit (catálogo de code smells + deep-modules)
|
|
220
256
|
|
|
221
|
-
|
|
257
|
+
Dispara quando o usuário aponta um diretório ou descreve uma área como "bagunçada" / "precisa de limpeza" / "tech debt", ou pede health-check trimestral. Override: `--mode=refactor-audit`. Audita a área-alvo por oportunidades de refactoring usando a taxonomia de smells de Martin Fowler combinada com a análise deep-modules (deletion test, locality, leverage, interface depth) embutida na skill `dw-simplification`.
|
|
222
258
|
|
|
223
259
|
<critical>FAÇA EXATAMENTE 3 PERGUNTAS DE CLARIFICAÇÃO ANTES DE INICIAR ANÁLISE</critical>
|
|
224
260
|
|
|
@@ -292,6 +328,111 @@ Salvo em `<target>/refactor-plan.md`:
|
|
|
292
328
|
- Propor refactors sem teste ou não-testáveis → alto risco, não shippa.
|
|
293
329
|
- Ignorar decisões arquiteturais documentadas em `.dw/rules/` → flagar design intencional como smell.
|
|
294
330
|
|
|
331
|
+
## Modo: grill (domain-grilling)
|
|
332
|
+
|
|
333
|
+
Dispara quando o vocabulário está instável — termos do usuário divergem de `.dw/rules/` / `.dw/constitution.md`, dois sinônimos competem, ou alguém propõe um nome que conflita com o glossário. Override: `--mode=grill`. Substitui o option-matrix por um **stress-test estilo entrevista** do plan/PRD contra o vocabulário do projeto. Cada rodada sharpens um pedaço. Atualiza `.dw/rules/` (ou `.dw/constitution.md`) inline conforme termos cristalizam — nunca adia pra "depois da conversa".
|
|
334
|
+
|
|
335
|
+
<critical>Pergunte UMA pergunta de cada vez. Espere a resposta. Não despeje 5 perguntas e torça pelo melhor.</critical>
|
|
336
|
+
|
|
337
|
+
### Quando usar grill mode
|
|
338
|
+
|
|
339
|
+
- Antes de `/dw-plan prd` quando o domínio parece instável ou o time usa termos competindo.
|
|
340
|
+
- Depois de `/dw-plan prd` quando reviewers flagam linguagem ambígua no PRD.
|
|
341
|
+
- Durante discussão de arquitetura quando "módulo", "serviço", "componente" são usados de forma intercambiável e precisa fixar o termo canônico.
|
|
342
|
+
- Quando alguém propõe um nome que não combina com o glossário existente do projeto.
|
|
343
|
+
|
|
344
|
+
### Disciplinas durante a sessão
|
|
345
|
+
|
|
346
|
+
1. **Desafie contra o glossário.** Leia `.dw/rules/index.md` + `.dw/rules/<modulo>.md` + `.dw/constitution.md`. Flague conflitos de terminologia no instante em que o usuário usa um termo que diverge do que já está documentado.
|
|
347
|
+
|
|
348
|
+
2. **Sharpen linguagem vaga.** Quando o usuário disser "a coisa do user" ou "aquele lance de pedidos", proponha um termo canônico preciso. Não finja que entendeu — empurre de volta.
|
|
349
|
+
|
|
350
|
+
3. **Discuta cenários concretos.** Force precisão com edge cases específicos: "O que acontece com a Order no estado X quando o evento Y chega durante o retry Z?" Respostas vagas voltam como mais perguntas.
|
|
351
|
+
|
|
352
|
+
4. **Cross-reference o código.** Quando o usuário afirmar um comportamento, olhe rápido no codebase pra confirmar. Surface contradições: "Você disse que a API retorna `OrderId` mas `src/api/orders.ts:42` retorna `{ order_id, status }`." Não argumente em generalidades.
|
|
353
|
+
|
|
354
|
+
5. **Atualize `.dw/rules/` inline.** Quando um termo cristaliza, escreva no arquivo de rules apropriado no mesmo turn da conversa. Lazy file creation: se o arquivo não existir, crie. Formato segue a disciplina de glossário do projeto (ver `.dw/rules/index.md`).
|
|
355
|
+
|
|
356
|
+
6. **Pule detalhe de implementação no glossário.** `.dw/rules/` e `.dw/constitution.md` descrevem vocabulário e princípios — não implementação. "Order: pedido de um cliente para comprar itens, em um destes estados: pending, paid, shipped, delivered, refunded" é bom. "Order: uma classe TypeScript em `src/orders/`" é vazamento de implementação.
|
|
357
|
+
|
|
358
|
+
### Disciplina de criação de ADR
|
|
359
|
+
|
|
360
|
+
Só proponha um ADR via `/dw-adr` quando **todos os três** valem:
|
|
361
|
+
|
|
362
|
+
| Critério | Teste |
|
|
363
|
+
|----------|-------|
|
|
364
|
+
| **Difícil de reverter** | Se mudarmos em 6 meses, custa >1 semana de trabalho? |
|
|
365
|
+
| **Surpreendente sem contexto** | Um novo contribuinte chegaria razoavelmente a uma decisão diferente? |
|
|
366
|
+
| **Trade-off real** | Havia uma alternativa real considerada e descartada? |
|
|
367
|
+
|
|
368
|
+
Se algum falta, pule o ADR. Não ADR toda decisão casual — vira ruído na pasta de ADRs.
|
|
369
|
+
|
|
370
|
+
### Output
|
|
371
|
+
|
|
372
|
+
O modo grill produz:
|
|
373
|
+
- **`.dw/rules/<modulo>.md` ou `.dw/constitution.md` atualizado** com termos cristalizados.
|
|
374
|
+
- **PRD / TechSpec atualizado** se grill rodou no meio do planejamento (termos alinhados com o glossário).
|
|
375
|
+
- **`.dw/spec/<prd>/adrs/adr-NNN.md` opcional** se os critérios acima valem.
|
|
376
|
+
- **NÃO** produz option matrix ou recomendação (esse é o option-matrix; grill é só sharpening). Se o dispatcher encadeou grill+option-matrix, o option matrix roda em fase separada.
|
|
377
|
+
|
|
378
|
+
### Quando a disciplina dobra
|
|
379
|
+
|
|
380
|
+
- **Projeto greenfield sem `.dw/rules/`**: grille mesmo assim; a conversa produz as PRIMEIRAS entradas em `.dw/rules/index.md`. Isso é o valor.
|
|
381
|
+
- **Discordância cosmética de terminologia** ("usamos `userId` ou `user_id`?"): pule grill mode; use ADR de convenção de código ou seção Naming em `.dw/rules/index.md`.
|
|
382
|
+
|
|
383
|
+
## Modo: prototype (protótipo descartável)
|
|
384
|
+
|
|
385
|
+
Dispara quando o usuário pergunta "esse modelo de estado faz sentido?" / "como isso deveria parecer?" sem resposta clara — i.e., o próximo passo razoável é RODAR código, não escrever palavras. Override: `--mode=prototype`. Constrói um **protótipo descartável que responde a uma única pergunta**. A pergunta decide a forma — escolha um branch.
|
|
386
|
+
|
|
387
|
+
<critical>O protótipo é descartável desde o dia um. Não polir. Não adicionar testes. Não extrair abstrações. O ponto é APRENDER algo rápido e depois DELETAR ou absorver.</critical>
|
|
388
|
+
|
|
389
|
+
### Escolha um branch
|
|
390
|
+
|
|
391
|
+
| Pergunta do usuário | Branch |
|
|
392
|
+
|---------------------|--------|
|
|
393
|
+
| "Esse modelo de state/logic faz sentido?" | **LOGIC** — terminal app interativo que empurra a máquina de estado por edge cases difíceis de raciocinar no papel. |
|
|
394
|
+
| "Como isso deveria parecer?" | **UI** — várias variações radicalmente diferentes de UI num único route, toggleable por search param e bottom bar flutuante. |
|
|
395
|
+
|
|
396
|
+
Se a pergunta é ambígua, pergunte ao usuário. Se não puder alcançar: default pelo contexto (módulo backend → LOGIC; página/componente → UI) e declare a suposição no topo do protótipo.
|
|
397
|
+
|
|
398
|
+
### Regras (valem para os dois branches)
|
|
399
|
+
|
|
400
|
+
1. **Descartável desde o dia um, claramente marcado.** Coloque o protótipo perto do módulo/página que ele está prototipando (pra contexto) mas nomeie pra que um leitor casual veja que é protótipo (`prototype-<slug>.ts`, `prototype-route.tsx`, etc.).
|
|
401
|
+
|
|
402
|
+
2. **Um comando pra rodar.** Qualquer que seja o task runner do projeto — `pnpm <nome>`, `python <path>`, `bun <path>`, etc. O usuário tem que rodar sem pensar.
|
|
403
|
+
|
|
404
|
+
3. **Sem persistência por padrão.** Estado vive em memória. Persistência é o que o protótipo está VERIFICANDO, não algo do qual depende. Se a pergunta envolve banco, use um DB scratch ou arquivo local com nome claro `PROTOTYPE — wipe me`.
|
|
405
|
+
|
|
406
|
+
4. **Pule o polish.** Sem testes, sem error handling além do mínimo pro protótipo rodar, sem abstrações.
|
|
407
|
+
|
|
408
|
+
5. **Surface o estado.** Depois de cada ação (LOGIC) ou troca de variante (UI), imprima ou renderize o estado relevante completo pro usuário ver o que mudou.
|
|
409
|
+
|
|
410
|
+
6. **Delete ou absorva quando terminar.** Quando o protótipo respondeu sua pergunta, ou delete ou dobre a decisão validada em código real. Não deixe apodrecendo no repo.
|
|
411
|
+
|
|
412
|
+
### Quando terminar
|
|
413
|
+
|
|
414
|
+
A **resposta** é a única coisa que vale guardar. Capture duravelmente:
|
|
415
|
+
- Commit message fechando o protótipo: "removed prototype X; decided <resposta> based on <observação>"
|
|
416
|
+
- Ou um ADR (se os critérios do grill valem)
|
|
417
|
+
- Ou `.dw/spec/<prd>/NOTES.md` se mid-PRD
|
|
418
|
+
- Ou comentário em issue se user-driven
|
|
419
|
+
|
|
420
|
+
Se o usuário não está por perto, deixe um placeholder `PROTOTYPE VERDICT: <pending>` pro próximo pass preencher antes da deleção.
|
|
421
|
+
|
|
422
|
+
### Output
|
|
423
|
+
|
|
424
|
+
O modo prototype produz:
|
|
425
|
+
- **Arquivo(s) de código descartável** na localização apropriada.
|
|
426
|
+
- Um `NOTES.md` ao lado do protótipo com a PERGUNTA que está respondendo.
|
|
427
|
+
- Depois do usuário rodar e responder a pergunta, instruções pra remover o protótipo + capturar o verdict.
|
|
428
|
+
|
|
429
|
+
### Anti-patterns
|
|
430
|
+
|
|
431
|
+
- Construir protótipo que é feature disfarçada — código production-quality, testes, deploy config. Isso não é protótipo; é primeiro draft.
|
|
432
|
+
- Deixar o protótipo no repo "por via das dúvidas" — seis meses depois é load-bearing.
|
|
433
|
+
- Não capturar o verdict — protótipo respondeu a pergunta e a resposta evaporou.
|
|
434
|
+
- Múltiplos protótipos empilhados — escolha uma pergunta, responda, mova.
|
|
435
|
+
|
|
295
436
|
## Inspired by
|
|
296
437
|
|
|
297
438
|
O padrão de codebase-grounded idea refinement é inspirado em [`addyosmani/agent-skills@idea-refine`](https://skills.sh/addyosmani/agent-skills/idea-refine) (Addy Osmani, Google — 1.4K+ installs). Adaptações para o dev-workflow:
|
|
@@ -301,6 +442,8 @@ O padrão de codebase-grounded idea refinement é inspirado em [`addyosmani/agen
|
|
|
301
442
|
- Output em `.dw/spec/ideas/<slug>.md` (irmão de `prd-<slug>/`) em vez de `docs/ideas/` — mantém a convenção de paths do dev-workflow.
|
|
302
443
|
- Integração com o pipeline existente: `/dw-plan prd` aceita o one-pager como input, reduzindo perguntas de clarificação.
|
|
303
444
|
|
|
304
|
-
|
|
445
|
+
Os modos **grill** e **prototype** são adaptados de [`mattpocock/skills/grill-with-docs`](https://github.com/mattpocock/skills/tree/main/grill-with-docs) e [`mattpocock/skills/prototype`](https://github.com/mattpocock/skills/tree/main/prototype) (Matt Pocock, MIT). Adaptação dev-workflow: integrados como modos INTERNOS auto-dispatchados em vez de skills separadas, paths rebaseados em `.dw/rules/` + `.dw/spec/<prd>/`, criação de ADR gated no teste 3-critérios (difícil de reverter + surpreendente + trade-off real).
|
|
446
|
+
|
|
447
|
+
Crédito: Addy Osmani (idea-refine) e Matt Pocock (grill-with-docs, prototype).
|
|
305
448
|
|
|
306
449
|
</system_instructions>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dw-simplification
|
|
3
|
-
description: Use when simplifying code. Chesterton's Fence (
|
|
3
|
+
description: Use when simplifying code. Chesterton's Fence (WHY first), behavior-preserving refactor, complexity metrics, deep-modules analysis. Triggers from /dw-review and /dw-brainstorm refactor-audit.
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Read
|
|
6
6
|
- Edit
|
|
@@ -18,7 +18,7 @@ Behavioral discipline for simplifying code without breaking it. The trap of refa
|
|
|
18
18
|
Read this skill when:
|
|
19
19
|
|
|
20
20
|
- `/dw-review --code-only` flagged a complexity issue (deep nesting, long function, duplication).
|
|
21
|
-
- `/dw-brainstorm
|
|
21
|
+
- `/dw-brainstorm` dispatched its **refactor-audit** mode and proposed a simplification target.
|
|
22
22
|
- The user explicitly asks to "clean this up" / "simplify X".
|
|
23
23
|
- During `/dw-run` if the implementation accidentally produced complex code that wants pre-commit cleanup.
|
|
24
24
|
|
|
@@ -117,11 +117,13 @@ For changes that altered cyclomatic complexity, optionally run a complexity anal
|
|
|
117
117
|
|
|
118
118
|
In the formal Level 3 review (post-Level 2 chain from `dw-review-implementation`), code-review flags complexity issues using the patterns above. Each flagged issue references this skill: "consider simplifying via guard clauses; apply Chesterton's Fence — verify why the nested check exists before flattening."
|
|
119
119
|
|
|
120
|
-
## How
|
|
120
|
+
## How `/dw-brainstorm` refactor-audit mode uses this
|
|
121
|
+
|
|
122
|
+
The refactor-audit mode dispatched by `/dw-brainstorm` catalogs code smells (Fowler vocabulary) AND runs the deep-modules analysis (`references/deep-modules.md`) against the target area. For each smell or shallow-module flag, the proposed refactor cites:
|
|
121
123
|
|
|
122
|
-
The analysis catalogs code smells (Fowler vocabulary). For each smell, the proposed refactor cites:
|
|
123
124
|
1. Which simplification rule applies (early return / extract method / lookup table / etc.).
|
|
124
125
|
2. Whether Chesterton's Fence concerns block the refactor (existing tests inadequate? no recent commits explaining the structure? → flag as YELLOW, don't act).
|
|
126
|
+
3. Whether the deep-modules test points the other way (some "code smells" are actually deep-module wrappers that absorb complexity; the fix is to make the wrapper deeper, not to flatten it).
|
|
125
127
|
|
|
126
128
|
## Anti-patterns
|
|
127
129
|
|
|
@@ -136,7 +138,10 @@ The analysis catalogs code smells (Fowler vocabulary). For each smell, the propo
|
|
|
136
138
|
- `references/chestertons-fence.md` — the protocol in detail; case studies of "obvious-but-wrong" removals.
|
|
137
139
|
- `references/complexity-metrics.md` — when each metric (cyclomatic, cognitive, depth, fanout) actually matters; how to measure cheaply.
|
|
138
140
|
- `references/behavior-preserving.md` — characterization tests, refactor with test gate, rollback patterns, codemod tooling per language.
|
|
141
|
+
- `references/deep-modules.md` — high-leverage modules behind small interfaces; deletion test, locality, leverage, seam, adapter diagnostic; anti-patterns (shallow wrapper, god-module). Invoked by `/dw-brainstorm` refactor-audit mode.
|
|
139
142
|
|
|
140
143
|
## Inspired by
|
|
141
144
|
|
|
142
|
-
Adapted from [`addyosmani/agent-skills/code-simplification`](https://github.com/addyosmani/agent-skills) by Addy Osmani (MIT license). Core principles (Chesterton's Fence, behavior preservation, scope discipline, Rule of 500) preserved. dev-workflow integration: invoked by `dw-code-review` and
|
|
145
|
+
Adapted from [`addyosmani/agent-skills/code-simplification`](https://github.com/addyosmani/agent-skills) by Addy Osmani (MIT license). Core principles (Chesterton's Fence, behavior preservation, scope discipline, Rule of 500) preserved. dev-workflow integration: invoked by `dw-code-review` and `/dw-brainstorm` refactor-audit mode via Complementary Skills.
|
|
146
|
+
|
|
147
|
+
The deep-modules reference is adapted from [`mattpocock/skills/improve-codebase-architecture`](https://github.com/mattpocock/skills/tree/main/improve-codebase-architecture) by Matt Pocock (MIT license). Core framing (deep modules = high leverage at small interface, deletion test, shallow-wrapper anti-pattern) preserved; paths and integration points rebased on dev-workflow conventions.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Deep modules — high leverage at small interface
|
|
2
|
+
|
|
3
|
+
A **deep module** absorbs complexity behind a narrow public surface. Its callers see a small, stable API and get a lot of work done per call. A **shallow module** is the opposite — small interface AND small implementation, so it adds an indirection without absorbing any complexity. Or worse: a god-module, deep implementation BUT huge interface, where the surface itself is the complexity.
|
|
4
|
+
|
|
5
|
+
The refactor-audit mode of `/dw-brainstorm` checks every candidate module against this framing alongside the Fowler smell taxonomy. A "code smell" can mislead if the construct is actually a deep wrapper doing its job correctly.
|
|
6
|
+
|
|
7
|
+
## The premise
|
|
8
|
+
|
|
9
|
+
Good abstractions hide complexity. The metric isn't "how short is the code?" — it's "how much complexity does the interface eliminate per unit of public surface area?"
|
|
10
|
+
|
|
11
|
+
- **Deep module**: 1000 lines of implementation, 3 public functions. Caller does NOT need to know the 1000 lines.
|
|
12
|
+
- **Shallow module**: 50 lines of implementation, 8 public functions. Caller has to learn all 8 to use the 50 productively.
|
|
13
|
+
- **God-module**: 5000 lines of implementation, 60 public functions. Surface area is itself unmanageable.
|
|
14
|
+
|
|
15
|
+
The deep version wins not because it's shorter overall (it's longer), but because the cost of using it is concentrated in the implementation, not spread to every caller.
|
|
16
|
+
|
|
17
|
+
## Diagnostic checklist
|
|
18
|
+
|
|
19
|
+
When the refactor-audit mode evaluates a module, ask these in order:
|
|
20
|
+
|
|
21
|
+
### 1. Deletion test
|
|
22
|
+
|
|
23
|
+
> If this module were deleted, how many call sites would break?
|
|
24
|
+
|
|
25
|
+
- **0–1 callers**: the module isn't pulling its weight. Inline it; the abstraction is shallower than the call sites' real shape. Mark this as `low` priority candidate for removal.
|
|
26
|
+
- **2–3 callers**: borderline. Look at what each caller does with the result — if they immediately wrap/unwrap, the module is shallow. If they consume the result directly, leave it alone.
|
|
27
|
+
- **4+ callers**: the module is at least somewhat load-bearing. Move to next checks.
|
|
28
|
+
|
|
29
|
+
### 2. Locality test
|
|
30
|
+
|
|
31
|
+
> Does the caller pass everything the module needs, OR does the module reach into globals / shared state to fill gaps?
|
|
32
|
+
|
|
33
|
+
A deep module is **self-contained**: callers pass in arguments, get back results. A module that reads from `process.env`, a shared singleton, or implicit thread-local state has a deeper coupling than its interface admits — the caller has to know about the hidden inputs too.
|
|
34
|
+
|
|
35
|
+
If the module reaches into shared state, its **effective interface** is bigger than what the function signature shows. That's a hidden shallowness — the public surface lies about its real cost.
|
|
36
|
+
|
|
37
|
+
### 3. Leverage test
|
|
38
|
+
|
|
39
|
+
> LOC saved per caller × number of callers — what's the multiplicative payoff?
|
|
40
|
+
|
|
41
|
+
Crude formula: if each caller would otherwise write ~N lines of inline code to replace this module's call, and there are M callers, the module's leverage is N × M. A module whose leverage is < 2× its own LOC is shallow — it's not absorbing enough complexity to justify itself.
|
|
42
|
+
|
|
43
|
+
### 4. Seam test
|
|
44
|
+
|
|
45
|
+
> How often does the public interface change relative to the implementation?
|
|
46
|
+
|
|
47
|
+
A stable public interface with frequently-changing implementation is the **ideal seam** — callers stay put while internals evolve. An interface that changes every few months means callers track it; the abstraction is leaking.
|
|
48
|
+
|
|
49
|
+
Check `git log --oneline -- <module>` against `git log --oneline -- <module-public-surface-file>`. If they move together, the seam is weak.
|
|
50
|
+
|
|
51
|
+
### 5. Adapter test
|
|
52
|
+
|
|
53
|
+
> Does this module mediate between two foreign vocabularies?
|
|
54
|
+
|
|
55
|
+
The best deep modules are **adapters** — they translate between two domains that have different naming conventions, error semantics, or state models. A module that doesn't mediate between domains is harder to justify as deep; it's probably either a passthrough (shallow) or just a piece of the same domain stretched across files (cohesion issue).
|
|
56
|
+
|
|
57
|
+
## Anti-patterns
|
|
58
|
+
|
|
59
|
+
### Shallow wrapper
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// shallow — passthrough with one line of "work"
|
|
63
|
+
export function getUserName(id: string) {
|
|
64
|
+
return db.users.findById(id).name;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The wrapper saves the caller 8 characters (`.name`) and forces them to learn a new function name. The leverage is < 1. Inline it.
|
|
69
|
+
|
|
70
|
+
When to keep a one-liner: it's an **adapter** that locks down ONE meaning of a query. If `getUserName` exists specifically because there are 4 candidate fields (`name`, `displayName`, `username`, `fullName`) and the team's canonical answer is "use `name`", the function IS pulling its weight by serving as the project's vocabulary anchor. Document the WHY in the function body.
|
|
71
|
+
|
|
72
|
+
### God-module
|
|
73
|
+
|
|
74
|
+
A class with 60 public methods is shallow even if each method is 100 lines, because the caller has to learn 60 concepts. Split by **role**: what is the smallest subset of methods a caller typically uses together? Each subset becomes a deep module of its own.
|
|
75
|
+
|
|
76
|
+
### Implementation-leak abstraction
|
|
77
|
+
|
|
78
|
+
A module that returns its internal representation directly (`return this.cache;`) makes callers depend on the internals. The first time the cache shape changes, every caller breaks. Wrap or copy on egress.
|
|
79
|
+
|
|
80
|
+
## When refactor-audit raises a smell, also check deep-modules
|
|
81
|
+
|
|
82
|
+
The combined verdict:
|
|
83
|
+
|
|
84
|
+
| Fowler smell | Deep-modules check | Action |
|
|
85
|
+
|--------------|--------------------|--------|
|
|
86
|
+
| Long Method | Is the method INSIDE a deep module that callers don't see? | If yes, leave it — internal complexity is OK in deep modules. If no, extract. |
|
|
87
|
+
| Large Class | Is the public surface narrow despite the line count? | If yes, leave it — that's deep. If no, split by role. |
|
|
88
|
+
| Long Parameter List | Does each parameter represent a real choice the caller makes? | If yes, the deep module is forcing necessary configuration; introduce a config object. If parameters are derivable from each other, reduce. |
|
|
89
|
+
| Feature Envy | Is the module a deep adapter between domains? | If yes, the "envy" is the mediation — keep it. If no, move the logic closer to its data. |
|
|
90
|
+
| Middle Man | Does the middle man absorb any complexity? | If no, delete the middle man. If yes, document the why (it's a deep wrapper). |
|
|
91
|
+
|
|
92
|
+
A flat "this is too long, extract method" recommendation is shallow analysis. Combining Fowler + deep-modules surfaces when the smell is actually a feature.
|
|
93
|
+
|
|
94
|
+
## Output for refactor-audit findings
|
|
95
|
+
|
|
96
|
+
When the audit flags a module as a shallow-wrapper or god-module candidate, the finding entry adds a `Deep-modules: <verdict>` line:
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
### P1 — Shallow Wrapper
|
|
100
|
+
**Files:** src/lib/getUserName.ts
|
|
101
|
+
**Symptom:** 1-line passthrough wrapper around `db.users.findById(id).name`; 2 callers.
|
|
102
|
+
**Deep-modules:** SHALLOW — fails deletion test (only 2 callers) AND leverage test (0 LOC saved per call).
|
|
103
|
+
**Refactor:** Inline at both call sites. If the wrapper exists for vocabulary reasons, document and keep — otherwise remove.
|
|
104
|
+
**Risk:** Low.
|
|
105
|
+
```
|