@brunosps00/dev-workflow 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +12 -4
  4. package/lib/constants.js +24 -24
  5. package/lib/init.js +8 -0
  6. package/lib/instruction-health.js +38 -0
  7. package/lib/post-update.js +2 -1
  8. package/lib/validate.js +3 -1
  9. package/package.json +1 -1
  10. package/scaffold/config/routing.json +61 -23
  11. package/scaffold/en/agent-instructions.md +31 -137
  12. package/scaffold/en/commands/dw-analyze-project.md +2 -0
  13. package/scaffold/en/commands/dw-autopilot.md +22 -245
  14. package/scaffold/en/commands/dw-bugfix.md +9 -35
  15. package/scaffold/en/commands/dw-claude-run.md +29 -45
  16. package/scaffold/en/commands/dw-codex-run.md +30 -45
  17. package/scaffold/en/commands/dw-context-budget.md +6 -14
  18. package/scaffold/en/commands/dw-copilot-run.md +29 -41
  19. package/scaffold/en/commands/dw-generate-pr.md +2 -2
  20. package/scaffold/en/commands/dw-goal.md +11 -5
  21. package/scaffold/en/commands/dw-help.md +2 -2
  22. package/scaffold/en/commands/dw-plan.md +14 -7
  23. package/scaffold/en/commands/dw-qa.md +2 -0
  24. package/scaffold/en/commands/dw-resume.md +5 -11
  25. package/scaffold/en/commands/dw-review.md +4 -3
  26. package/scaffold/en/commands/dw-run.md +19 -166
  27. package/scaffold/en/commands/dw-skill-health.md +7 -0
  28. package/scaffold/en/commands/dw-update.md +18 -4
  29. package/scaffold/en/references/command-routing.md +53 -0
  30. package/scaffold/en/references/execution-contract.md +55 -0
  31. package/scaffold/en/templates/frontend-quality-template.md +43 -0
  32. package/scaffold/en/templates/task-template.md +20 -40
  33. package/scaffold/en/templates/tasks-template.md +9 -6
  34. package/scaffold/en/templates/techspec-template.md +4 -0
  35. package/scaffold/pt-br/agent-instructions.md +31 -137
  36. package/scaffold/pt-br/commands/dw-analyze-project.md +2 -0
  37. package/scaffold/pt-br/commands/dw-autopilot.md +22 -245
  38. package/scaffold/pt-br/commands/dw-bugfix.md +9 -35
  39. package/scaffold/pt-br/commands/dw-claude-run.md +29 -46
  40. package/scaffold/pt-br/commands/dw-codex-run.md +30 -45
  41. package/scaffold/pt-br/commands/dw-context-budget.md +6 -14
  42. package/scaffold/pt-br/commands/dw-copilot-run.md +29 -43
  43. package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
  44. package/scaffold/pt-br/commands/dw-goal.md +11 -5
  45. package/scaffold/pt-br/commands/dw-help.md +2 -2
  46. package/scaffold/pt-br/commands/dw-plan.md +14 -7
  47. package/scaffold/pt-br/commands/dw-qa.md +2 -0
  48. package/scaffold/pt-br/commands/dw-resume.md +7 -11
  49. package/scaffold/pt-br/commands/dw-review.md +4 -3
  50. package/scaffold/pt-br/commands/dw-run.md +19 -166
  51. package/scaffold/pt-br/commands/dw-skill-health.md +7 -0
  52. package/scaffold/pt-br/commands/dw-update.md +18 -4
  53. package/scaffold/pt-br/references/command-routing.md +53 -0
  54. package/scaffold/pt-br/references/execution-contract.md +55 -0
  55. package/scaffold/pt-br/templates/frontend-quality-template.md +43 -0
  56. package/scaffold/pt-br/templates/task-template.md +20 -40
  57. package/scaffold/pt-br/templates/tasks-template.md +9 -6
  58. package/scaffold/pt-br/templates/techspec-template.md +4 -0
  59. package/scaffold/scripts/lib/workflow-contract.mjs +101 -0
  60. package/scaffold/skill-registry.json +23 -23
  61. package/scaffold/skills/dw-cli-run/SKILL.md +33 -217
  62. package/scaffold/skills/dw-cli-run/references/dispatch-tuning.md +14 -72
  63. package/scaffold/skills/dw-codebase-intel/SKILL.md +5 -39
  64. package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +1 -1
  65. package/scaffold/skills/dw-codebase-intel/references/agents-detail.md +7 -0
  66. package/scaffold/skills/dw-codebase-intel/references/files-in-dw-intel-detail.md +16 -0
  67. package/scaffold/skills/dw-codebase-intel/references/how-dw-intel-reads-this-detail.md +12 -0
  68. package/scaffold/skills/dw-codebase-intel/references/how-to-compose-the-typical-flow-detail.md +11 -0
  69. package/scaffold/skills/dw-council/SKILL.md +2 -17
  70. package/scaffold/skills/dw-council/references/integration-with-other-dw-commands-detail.md +7 -0
  71. package/scaffold/skills/dw-council/references/phase-2-tensions-and-rebuttals-detail.md +15 -0
  72. package/scaffold/skills/dw-domain-modeling/SKILL.md +1 -1
  73. package/scaffold/skills/dw-execute-phase/SKILL.md +12 -32
  74. package/scaffold/skills/dw-execute-phase/agents/executor.md +15 -252
  75. package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +4 -207
  76. package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +8 -18
  77. package/scaffold/skills/dw-execute-phase/references/de-sloppify-pass-optional-cleanup-task-detail.md +12 -0
  78. package/scaffold/skills/dw-execute-phase/references/deviation-rules-during-execution-detail.md +8 -0
  79. package/scaffold/skills/dw-execute-phase/references/how-the-two-agents-compose-detail.md +7 -0
  80. package/scaffold/skills/dw-execute-phase/references/plan-verification.md +9 -155
  81. package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +6 -97
  82. package/scaffold/skills/dw-git-discipline/SKILL.md +2 -2
  83. package/scaffold/skills/dw-grilling/SKILL.md +1 -1
  84. package/scaffold/skills/dw-incident-response/SKILL.md +1 -64
  85. package/scaffold/skills/dw-incident-response/references/the-five-phases-detail.md +66 -0
  86. package/scaffold/skills/dw-llm-eval/SKILL.md +5 -53
  87. package/scaffold/skills/dw-llm-eval/references/agent-tool-use-evaluation-detail.md +23 -0
  88. package/scaffold/skills/dw-llm-eval/references/anti-patterns-will-block-in-dw-review-code-only-detail.md +9 -0
  89. package/scaffold/skills/dw-llm-eval/references/consistency-run-to-run-stability-detail.md +10 -0
  90. package/scaffold/skills/dw-llm-eval/references/integration-with-dev-workflow-commands-detail.md +6 -0
  91. package/scaffold/skills/dw-llm-eval/references/the-oracle-ladder-detail.md +15 -0
  92. package/scaffold/skills/dw-memory/SKILL.md +4 -50
  93. package/scaffold/skills/dw-memory/references/context-budget.md +8 -56
  94. package/scaffold/skills/dw-memory/references/promotion-decision-test-detail.md +30 -0
  95. package/scaffold/skills/dw-minimalism/SKILL.md +4 -5
  96. package/scaffold/skills/dw-review-rigor/SKILL.md +1 -54
  97. package/scaffold/skills/dw-review-rigor/references/the-five-rules-detail.md +56 -0
  98. package/scaffold/skills/dw-simplification/SKILL.md +2 -55
  99. package/scaffold/skills/dw-simplification/references/pattern-recognition-detail.md +11 -0
  100. package/scaffold/skills/dw-simplification/references/the-five-rules-detail.md +48 -0
  101. package/scaffold/skills/dw-source-grounding/SKILL.md +1 -56
  102. package/scaffold/skills/dw-source-grounding/references/the-protocol-detect-fetch-implement-cite-detail.md +58 -0
  103. package/scaffold/skills/dw-testing-discipline/SKILL.md +25 -177
  104. package/scaffold/skills/dw-testing-discipline/references/agent-guardrails.md +9 -167
  105. package/scaffold/skills/dw-testing-discipline/references/core-rules.md +3 -3
  106. package/scaffold/skills/dw-testing-discipline/references/mutation-testing.md +19 -0
  107. package/scaffold/skills/dw-testing-discipline/references/patterns.md +3 -12
  108. package/scaffold/skills/dw-ui-discipline/SKILL.md +2 -59
  109. package/scaffold/skills/dw-ui-discipline/references/frontend-engineering.md +46 -0
  110. package/scaffold/skills/dw-ui-discipline/references/the-four-grounding-questions-detail.md +61 -0
  111. package/scaffold/skills/dw-verify/SKILL.md +26 -148
  112. package/scaffold/skills/dw-verify/references/verification-discovery-and-attribution.md +2 -2
  113. package/scaffold/skills/humanizer/SKILL.md +2 -1
  114. package/scaffold/skills/security-review/SKILL.md +3 -183
  115. package/scaffold/skills/security-review/references/do-not-flag-detail.md +49 -0
  116. package/scaffold/skills/security-review/references/quick-patterns-reference-detail.md +56 -0
  117. package/scaffold/skills/security-review/references/review-process-detail.md +84 -0
  118. package/scaffold/skills/vercel-react-best-practices/SKILL.md +1 -90
  119. package/scaffold/skills/vercel-react-best-practices/references/quick-reference-detail.md +92 -0
@@ -87,7 +87,7 @@ Create `MEMORY.md` and `<N>_memory.md` on first use with the template below. Nev
87
87
 
88
88
  ## Workflow
89
89
 
90
- ### 1. Load before editing code
90
+ ### 1. Load relevant task memory on start or resume
91
91
  - Read `MEMORY.md` and the current task's `<N>_memory.md` **before** any code change.
92
92
  - Treat these as mandatory context for the run, not optional notes.
93
93
  - If the caller marks either file for compaction, apply the Compaction Rules (below) before continuing.
@@ -116,34 +116,7 @@ Create `MEMORY.md` and `<N>_memory.md` on first use with the template below. Nev
116
116
 
117
117
  ## Promotion Decision Test
118
118
 
119
- Before promoting an item from `<N>_memory.md` to `MEMORY.md`, ask:
120
-
121
- 1. Will another task need this to avoid a mistake or rediscovery?
122
- 2. Is this fact durable across multiple runs, not just the current execution?
123
- 3. Is this information NOT already obvious from the PRD, TechSpec, task files, or the repository itself?
124
-
125
- All three must be "yes" to promote. If any is "no", the item stays in task memory.
126
-
127
- ### Confidence signal
128
-
129
- Tag each durable decision with a confidence in `[0.3–0.9]` plus the tasks that confirmed it — `… — [confidence: 0.7; seen in tasks 1,3,5]`:
130
-
131
- - Confirmed in **≥2 of the last 3 tasks** with no contradiction → **≥0.7** (trust it; safe to act on without re-deriving).
132
- - Confirmed once, or inferred but not yet reused → **0.3–0.5** (tentative; gather more signal before relying).
133
- - Contradicted by a later task or the repo → lower it or drop the decision (see Error Handling).
134
-
135
- Confidence makes cross-task learning explicit and is the signal `/dw-learn` reads to promote high-confidence decisions into durable instincts, constitution principles, or rules.
136
-
137
- ### Belongs in shared memory
138
- - A discovered constraint affecting multiple tasks ("the Stripe API rate-limits to 100 req/s — batch operations must respect this")
139
- - A cross-cutting architectural decision made during implementation ("chose React Server Components for data fetching across the whole feature")
140
- - An open risk future tasks must account for ("migration depends on schema v3 which is not yet deployed to staging")
141
-
142
- ### Stays in task memory
143
- - Files touched during this task's implementation
144
- - Debugging steps taken to resolve a task-specific error
145
- - The current task's objective and acceptance criteria snapshot
146
- - A workaround applied only to the current task's scope
119
+ For promotion decision test, read `references/promotion-decision-test-detail.md`. Load only when this part of the task applies.
147
120
 
148
121
  ## Compaction Rules
149
122
 
@@ -157,26 +130,7 @@ When flagged for compaction, apply inline:
157
130
 
158
131
  ## Context Budget
159
132
 
160
- Memory is part of a broader **context budget** the agent must respect during execution. A blown budget degrades reasoning before any output is produced — the model starts missing requirements, drops constraints, and reverts to averaged-over-training answers. Full guidance: [`references/context-budget.md`](references/context-budget.md).
161
-
162
- **Targets:**
163
-
164
- - **Total active context:** under **40k tokens** (rough working budget across PRD + TechSpec + tasks + MEMORY.md + per-task memory + open files).
165
- - **Reserve:** at least **120k tokens** of headroom for actual reasoning, tool output, and the model's response stream.
166
- - **Hard ceiling per memory file:** `MEMORY.md` ≤ 6KB; `<N>_memory.md` ≤ 3KB. Past those, compact instead of growing.
167
-
168
- **Anti-co-load rules** (apply on every load):
169
-
170
- 1. Never load two PRD specs in the same context. If switching PRDs, drop the previous PRD's spec/techspec/tasks references from the active set.
171
- 2. Never load multiple archived `.dw/bugfixes/` SUMMARY.md files together — load only what's needed for the active fix or query.
172
- 3. Never load `.dw/intel/files.json` and `.dw/intel/deps.json` simultaneously when answering a single question — pick the primary per query shape (see `dw-codebase-intel/references/query-patterns.md`).
173
- 4. Never load a design proposal AND the prior design's full text — if comparing, summarize the prior into 5-10 lines.
174
-
175
- **Monitoring signal:**
176
-
177
- If the agent finds itself reading large files repeatedly or summarizing the same fact across multiple turns, that's a budget signal. Compact memory and explicitly drop unrelated loaded context before proceeding. Note this in `MEMORY.md` under Handoff Notes so the next task starts lean.
178
-
179
- This budget is doctrine, not a hard gate. No command currently rejects work for exceeding 40k. The discipline lives here because future sessions read this skill first.
133
+ For context budget, read `references/context-budget.md`. Load only when this part of the task applies.
180
134
 
181
135
  ## Error Handling
182
136
 
@@ -199,7 +153,7 @@ Ported from Compozy's `cy-workflow-memory` skill (`/tmp/compozy/.agents/skills/c
199
153
 
200
154
  - Paths are `.dw/spec/<prd-slug>/` instead of `.compozy/tasks/<name>/`.
201
155
  - Task-local file is `<N>_memory.md` next to `<N>_task.md` (mirrors the existing dev-workflow task layout).
202
- - Inline Compaction Rules (Compozy keeps them in `references/memory-guidelines.md`); the budget discipline was extracted to `references/context-budget.md` because it's about model behavior, not file management.
156
+ - Inline Compaction Rules (Compozy keeps them in its upstream memory-guidelines reference); the budget discipline was extracted to `references/context-budget.md` because it's about model behavior, not file management.
203
157
 
204
158
  Credit: Compozy project (https://github.com/compozy/compozy).
205
159
 
@@ -1,63 +1,15 @@
1
- # Context Budget — Discipline
1
+ # Context and memory budget
2
2
 
3
- A working context window is finite. Past about 40k tokens of active content, model output quality degrades — the model starts to miss requirements, lose constraints, blur details across sources, and revert to training-set averages. This file codifies the discipline that keeps active context lean across a long dev-workflow session.
3
+ Read when memory grows or repeated exploration obscures the active task. Context capacity and compaction behavior vary by host/model; do not assume a universal 40k active limit or 120k reserve. A model may expose telemetry; label estimates and unknown usage accurately.
4
4
 
5
- ## The numbers
5
+ Keep relevant requirements, constraints, decisions, pending work and evidence available. Read sections or query indexes when that answers the question. Comparing PRDs/designs or tracing source plus dependencies can require multiple sources; do not prohibit necessary co-loading. Avoid bulk-loading unrelated archived summaries or task memories.
6
6
 
7
- - **Target active load:** under **40k tokens** total — PRD, TechSpec, tasks, MEMORY.md, per-task memory, all open files together.
8
- - **Reasoning reserve:** **120k+ tokens** of headroom for tool output, model thinking, and response generation.
9
- - **Soft alert:** when active load crosses **30k tokens**, plan to compact before the next major task.
10
- - **Compaction threshold for `MEMORY.md`:** ≤ 6KB on disk.
11
- - **Compaction threshold for `<N>_memory.md`:** ≤ 3KB on disk.
7
+ Use concise durable memory: target MEMORY.md at most 6KB and per-task memory at most 3KB, moving detailed logs to linked artifacts. These are project maintenance targets, not model capacity claims or task-completion gates. Preserve unresolved decisions, acceptance criteria, session identity and evidence when compacting.
12
8
 
13
- These are doctrine, not enforced by any hard gate. The cost of breaking them is degraded output, not a command failure. Catch it yourself; the framework can't.
9
+ Repeated reads, growing summaries and confused task boundaries are reasons to inspect context use, not proof of exceeding a hidden token threshold. Update the checkpoint if context limits threaten continuity; otherwise continue authorized work. Do not promise to evict individual messages from a host's context.
14
10
 
15
- ## The anti-co-load rules
11
+ Use `../../dw-codebase-intel/references/query-patterns.md` for indexed queries when useful. Verification failures still require diagnosing actual code/environment; do not attribute them to context size without evidence.
16
12
 
17
- Each is a "do not load both simultaneously" pairing. Pick one; if you must consult the other, summarize it to 5–10 lines first and drop the full version.
13
+ ## Attribution
18
14
 
19
- 1. **Two PRDs at once.** Working on `prd-foo`, then user asks about `prd-bar`? Finish `prd-foo`'s active turn first, drop its spec/techspec/tasks from active context, then load `prd-bar`. Never carry both spec sets.
20
-
21
- 2. **Multiple archived bugfix SUMMARY.md files.** Bugfix history queries should go through `.dw/intel/bugfixes.json` (compact, indexed), not by reading 20 SUMMARY.md files. Read individual SUMMARY.md only when the user is acting on that specific fix.
22
-
23
- 3. **Files.json + deps.json simultaneously.** They overlap. Each query has a primary file per `dw-codebase-intel/references/query-patterns.md`. Pick the primary; consult the secondary only if the primary returns nothing.
24
-
25
- 4. **A design proposal AND its predecessor's full text.** When comparing two designs, summarize the older one to 5–10 lines (the deltas the new one addresses) and reference it that way. Don't carry both in full.
26
-
27
- 5. **Per-task memories from non-adjacent tasks.** Only the current task's `<N>_memory.md` and the immediately-previous one (for handoff) belong in active context. Older `<N>_memory.md` files are durable storage — read them when explicitly handing back to an old task, not as part of routine loading.
28
-
29
- ## The monitoring signal
30
-
31
- You will not see a token counter. You can't measure your own budget directly. But these are observable proxies that mean **you are over budget**:
32
-
33
- - You are reading the same file twice in the same session without it having changed.
34
- - You are summarizing the same fact across multiple turns to keep it in scope.
35
- - You are answering questions by re-deriving from the repo what a memory file would tell you in one line.
36
- - You are confusing details between two PRDs, tasks, or designs.
37
- - Your turn outputs are getting longer to compensate for context that is silently slipping out of the model's attention.
38
-
39
- When you notice any of these, stop:
40
-
41
- 1. Compact `MEMORY.md` and the active `<N>_memory.md` per the Compaction Rules in `SKILL.md`.
42
- 2. Explicitly state in chat what you are dropping from active context.
43
- 3. Note the budget event in `MEMORY.md` under Handoff Notes ("compacted at task N — see this section for what was dropped").
44
- 4. Resume the turn.
45
-
46
- ## What is NOT a budget problem
47
-
48
- These look like budget problems but aren't — don't compact for them:
49
-
50
- - **A genuinely complex task.** Some features legitimately need many files. Read what you need; the alternative (working from partial context) is worse.
51
- - **A long verification report.** Verify output can be long. Don't summarize it before logging it to disk; truncate the chat surface, not the artifact.
52
- - **A long user message.** The user wrote what they wrote. Don't compact to shave their words.
53
- - **The first PRD load of a new feature.** First-load is fine; second-load of the same PRD in the same turn is the signal.
54
-
55
- ## Integration with other skills
56
-
57
- - **`dw-memory` (this skill)**: compaction is the lever for memory files; this file describes when and why.
58
- - **`dw-codebase-intel`**: `query-patterns.md` defines the primary-vs-secondary rule that anti-co-load rule #3 references.
59
- - **`dw-verify`**: a budget-related degradation may show up as a verify regression. If verify keeps failing on facts the PRD already states, suspect budget before suspecting code.
60
-
61
- ## Source
62
-
63
- Adapted from [`tech-leads-club/agent-skills/tlc-spec-driven`](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). The 40k target, the anti-co-load principle, and the monitoring-signal framing come from there. The specific anti-co-load pairings, file-size ceilings, and the integration with `dw-memory`/`dw-codebase-intel` are dev-workflow-specific.
15
+ The earlier context-budget guidance adapted tech-leads-club's [tlc-spec-driven](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). This revision retains scoped retrieval and durable handoffs; rejects universal token thresholds and unconditional anti-co-loading rules. See docs/skills-ecosystem-comparison.md in the package source for the modernization decision.
@@ -0,0 +1,30 @@
1
+ ## Promotion Decision Test
2
+
3
+ Before promoting an item from `<N>_memory.md` to `MEMORY.md`, ask:
4
+
5
+ 1. Will another task need this to avoid a mistake or rediscovery?
6
+ 2. Is this fact durable across multiple runs, not just the current execution?
7
+ 3. Is this information NOT already obvious from the PRD, TechSpec, task files, or the repository itself?
8
+
9
+ All three must be "yes" to promote. If any is "no", the item stays in task memory.
10
+
11
+ ### Confidence signal
12
+
13
+ Tag each durable decision with a confidence in `[0.3–0.9]` plus the tasks that confirmed it — `… — [confidence: 0.7; seen in tasks 1,3,5]`:
14
+
15
+ - Confirmed in **≥2 of the last 3 tasks** with no contradiction → **≥0.7** (trust it; safe to act on without re-deriving).
16
+ - Confirmed once, or inferred but not yet reused → **0.3–0.5** (tentative; gather more signal before relying).
17
+ - Contradicted by a later task or the repo → lower it or drop the decision (see Error Handling).
18
+
19
+ Confidence makes cross-task learning explicit and is the signal `/dw-learn` reads to promote high-confidence decisions into durable instincts, constitution principles, or rules.
20
+
21
+ ### Belongs in shared memory
22
+ - A discovered constraint affecting multiple tasks ("the Stripe API rate-limits to 100 req/s — batch operations must respect this")
23
+ - A cross-cutting architectural decision made during implementation ("chose React Server Components for data fetching across the whole feature")
24
+ - An open risk future tasks must account for ("migration depends on schema v3 which is not yet deployed to staging")
25
+
26
+ ### Stays in task memory
27
+ - Files touched during this task's implementation
28
+ - Debugging steps taken to resolve a task-specific error
29
+ - The current task's objective and acceptance criteria snapshot
30
+ - A workaround applied only to the current task's scope
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dw-minimalism
3
- description: Pre-generation YAGNI gate. Before writing new code, infra, or abstractions, climb the decision ladder (need it? reuse? stdlib? native? installed dep? one line?) at the active lite/full/ultra intensity. Triggers from /dw-run, /dw-plan, /dw-review and any "add X / build Y" intent.
3
+ description: Evaluate a proposed abstraction, module or dependency for unnecessary complexity during planning or a focused over-engineering review.
4
4
  allowed-tools:
5
5
  - Read
6
6
  - Grep
@@ -11,8 +11,7 @@ allowed-tools:
11
11
  # dw-minimalism — Write the Least Code That Solves the Problem
12
12
 
13
13
  The cheapest code to maintain is the code you never wrote. This skill runs a
14
- **pre-generation gate**: before producing a new function, file, dependency, or
15
- abstraction, justify it against a decision ladder. It is the missing rung
14
+ **pre-generation gate**: when evaluating a proposed abstraction or module, assess its necessity against the task requirements. It is the missing rung
16
15
  between `dw-search-first` (which evaluates *external dependencies*) and
17
16
  `dw-simplification` (which cleans up code *after* it exists).
18
17
 
@@ -21,9 +20,9 @@ between `dw-search-first` (which evaluates *external dependencies*) and
21
20
  Read this skill when:
22
21
 
23
22
  - `/dw-plan` is about to specify new modules/services — pressure-test scope before tasks are written.
24
- - `/dw-run` is about to implement — climb the ladder before the first line of new code.
23
+ - A task proposes an abstraction or module whose necessity is unclear.
25
24
  - `/dw-review` flags over-engineering (speculative generality, premature abstraction, unused options).
26
- - The user (or a task) says "add X", "build Y", "create a helper/wrapper/abstraction for Z".
25
+ - The user asks to assess whether a helper, wrapper, abstraction or dependency is necessary.
27
26
 
28
27
  Do NOT use to:
29
28
 
@@ -34,60 +34,7 @@ Report only findings you are **>80% confident** are real. A style preference no
34
34
 
35
35
  ## The Five Rules
36
36
 
37
- ### 1. De-duplicate before writing
38
-
39
- If the same pattern (e.g., missing null check, unhandled error, magic constant) appears in multiple files, **create one finding** for the most representative instance and list the other affected files inside its body. Do not create N identical findings for N files sharing one root cause.
40
-
41
- Example — wrong:
42
- ```
43
- - [HIGH] src/a.ts:14 — missing null check on user
44
- - [HIGH] src/b.ts:22 — missing null check on user
45
- - [HIGH] src/c.ts:31 — missing null check on user
46
- ```
47
-
48
- Example — right:
49
- ```
50
- - [HIGH] Missing null check on `user` in 3 places.
51
- Representative: src/a.ts:14
52
- Also affects: src/b.ts:22, src/c.ts:31
53
- Fix: add `if (!user) return` at function entry.
54
- ```
55
-
56
- ### 2. Severity-order the output
57
-
58
- Always present findings in this order: **critical → high → medium → low**. Inside each severity, order by impact or blast radius, not by file path.
59
-
60
- Severity definitions:
61
- - **critical** — correctness bug, security hole, data loss, unavailability.
62
- - **high** — material deviation from PRD/TechSpec, concurrency hazard, significant perf regression, missing error handling on a user path.
63
- - **medium** — maintainability cost that will hurt the next change, missing edge-case handling, inconsistent with project rules.
64
- - **low** — stylistic, naming, minor readability. Often omit unless pattern-level.
65
-
66
- ### 3. Verify intent before flagging
67
-
68
- Before creating a finding, check whether the pattern is intentional:
69
- - adjacent comment explaining the choice?
70
- - ADR in `.dw/spec/*/adrs/` that justifies it?
71
- - test coverage that asserts the behavior?
72
- - rule in `.dw/rules/` that permits it?
73
-
74
- If the code looks suspicious but has a clear justification (e.g., `// intentionally ignoring close error on read-only handle`), do NOT create a finding. Only flag patterns that are genuinely problematic, not merely unconventional.
75
-
76
- ### 4. Skip what linters already catch
77
-
78
- Before writing findings, ensure the project's linter/formatter has run. Anything the configured linter would flag is NOT a finding in this review — it is a linter task. Save human attention for issues linters cannot find (logic, architecture, security, requirements).
79
-
80
- If the linter cannot run (missing tooling, build errors), note that in the summary and proceed with the review.
81
-
82
- ### 5. Signal over volume
83
-
84
- Aim for fewer, higher-quality findings.
85
-
86
- - Keep ALL `critical` and `high`.
87
- - If total findings exceed 20, prune `medium` and `low` to the most impactful ones.
88
- - A review with 8 precise findings is more useful than one with 30 that includes marginal concerns.
89
-
90
- **Also note well-implemented aspects.** They inform the summary and calibrate tone — but they do not produce findings.
37
+ For the five rules, read `references/the-five-rules-detail.md`. Load only when this part of the task applies.
91
38
 
92
39
  ## Prior-Round Awareness
93
40
 
@@ -0,0 +1,56 @@
1
+ ## The Five Rules
2
+
3
+ ### 1. De-duplicate before writing
4
+
5
+ If the same pattern (e.g., missing null check, unhandled error, magic constant) appears in multiple files, **create one finding** for the most representative instance and list the other affected files inside its body. Do not create N identical findings for N files sharing one root cause.
6
+
7
+ Example — wrong:
8
+ ```
9
+ - [HIGH] src/a.ts:14 — missing null check on user
10
+ - [HIGH] src/b.ts:22 — missing null check on user
11
+ - [HIGH] src/c.ts:31 — missing null check on user
12
+ ```
13
+
14
+ Example — right:
15
+ ```
16
+ - [HIGH] Missing null check on `user` in 3 places.
17
+ Representative: src/a.ts:14
18
+ Also affects: src/b.ts:22, src/c.ts:31
19
+ Fix: add `if (!user) return` at function entry.
20
+ ```
21
+
22
+ ### 2. Severity-order the output
23
+
24
+ Always present findings in this order: **critical → high → medium → low**. Inside each severity, order by impact or blast radius, not by file path.
25
+
26
+ Severity definitions:
27
+ - **critical** — correctness bug, security hole, data loss, unavailability.
28
+ - **high** — material deviation from PRD/TechSpec, concurrency hazard, significant perf regression, missing error handling on a user path.
29
+ - **medium** — maintainability cost that will hurt the next change, missing edge-case handling, inconsistent with project rules.
30
+ - **low** — stylistic, naming, minor readability. Often omit unless pattern-level.
31
+
32
+ ### 3. Verify intent before flagging
33
+
34
+ Before creating a finding, check whether the pattern is intentional:
35
+ - adjacent comment explaining the choice?
36
+ - ADR in `.dw/spec/*/adrs/` that justifies it?
37
+ - test coverage that asserts the behavior?
38
+ - rule in `.dw/rules/` that permits it?
39
+
40
+ If the code looks suspicious but has a clear justification (e.g., `// intentionally ignoring close error on read-only handle`), do NOT create a finding. Only flag patterns that are genuinely problematic, not merely unconventional.
41
+
42
+ ### 4. Skip what linters already catch
43
+
44
+ Before writing findings, ensure the project's linter/formatter has run. Anything the configured linter would flag is NOT a finding in this review — it is a linter task. Save human attention for issues linters cannot find (logic, architecture, security, requirements).
45
+
46
+ If the linter cannot run (missing tooling, build errors), note that in the summary and proceed with the review.
47
+
48
+ ### 5. Signal over volume
49
+
50
+ Aim for fewer, higher-quality findings.
51
+
52
+ - Keep ALL `critical` and `high`.
53
+ - If total findings exceed 20, prune `medium` and `low` to the most impactful ones.
54
+ - A review with 8 precise findings is more useful than one with 30 that includes marginal concerns.
55
+
56
+ **Also note well-implemented aspects.** They inform the summary and calibrate tone — but they do not produce findings.
@@ -30,64 +30,11 @@ Do NOT use when:
30
30
 
31
31
  ## The Five Rules
32
32
 
33
- ### 1. Chesterton's Fence — understand BEFORE changing
34
-
35
- Before removing or rewriting any code, answer three questions:
36
-
37
- 1. **What does it actually do?** Run/trace it; don't guess from the name.
38
- 2. **Why was it added?** Check `git log --follow <file> --oneline` and look at the introducing commit's message + PR. Often there's a reason.
39
- 3. **What breaks if it's gone?** Search for callers. Run the test suite to find what changes.
40
-
41
- If you can't answer all three, you're not ready to simplify. Get answers first.
42
-
43
- Concrete cases where Chesterton's Fence saves you:
44
- - A "redundant" early return that handles a race condition.
45
- - A "useless" type cast that fixes a compiler bug on a specific platform.
46
- - A "duplicated" check that exists for clarity at the API boundary.
47
- - A "dead" branch that runs only with a feature flag enabled in production.
48
-
49
- ### 2. Preserve behavior exactly
50
-
51
- The test for "did I simplify or did I change?" is: do the existing tests still pass without modification? If yes, behavior is preserved. If you needed to update tests, you changed behavior — that's a refactor, not a simplification.
52
-
53
- When tests are inadequate to confirm behavior preservation, write tests FIRST that document current behavior, then simplify against them. This is the test characterization technique.
54
-
55
- ### 3. Follow project conventions
56
-
57
- Match what the project already does. If files use 2-space indent and arrow functions, your simplified version uses 2-space indent and arrow functions — even if you'd prefer 4-space and `function`. Conventions matter more than personal preference; consistency is itself a form of clarity.
58
-
59
- Project conventions live in `.dw/rules/<module>.md` (from `/dw-analyze-project`). Read first.
60
-
61
- ### 4. Prefer clarity over cleverness
62
-
63
- Rules of thumb:
64
-
65
- - A line of code that takes 30 seconds to understand is worse than three lines that take 5 seconds each.
66
- - A "neat trick" with comments is uglier than the boring obvious code without comments.
67
- - Optimization that costs readability needs measurement (`dw-performance` skill territory) — without numbers, prefer the readable version.
68
- - "Magic" that requires knowing a language feature most teammates haven't used is anti-clarity. Use it only when the alternative is genuinely worse.
69
-
70
- ### 5. Scope to recent changes
71
-
72
- Don't go simplifying old code while you're "in there". The risk-to-benefit ratio of changing 5-year-old battle-tested code is bad. Limit simplification to:
73
-
74
- - Code you just wrote in this session.
75
- - Code your current task touches.
76
- - Code with explicit recent breakage (e.g., a bug just fixed that revealed bad structure).
77
-
78
- Out of scope: any other code, no matter how ugly. Open a task / ADR for those instead of fixing in-flight.
33
+ For the five rules, read `references/the-five-rules-detail.md`. Load only when this part of the task applies.
79
34
 
80
35
  ## Pattern recognition
81
36
 
82
- Frequent simplification targets — but apply Rules 1-5 before acting:
83
-
84
- | Smell | Healthy refactor | When NOT to refactor |
85
- |-------|------------------|----------------------|
86
- | Deep nesting (4+ levels) | Early returns / guard clauses | When the nesting maps to a real domain hierarchy (e.g., visitor pattern) |
87
- | Long function (>50 lines) | Extract method | When the "natural" extraction would produce 3-4 single-call helpers — you're trading complexity for indirection |
88
- | Generic name (`data`, `info`, `helper`) | Rename to specific | When the function genuinely processes generic input (e.g., a serializer middleware) |
89
- | Duplication (same 5 lines twice) | Extract to function/constant | When the duplication is by design (e.g., independent business rules that may diverge) |
90
- | `if/elif/else` chain (5+ branches) | Strategy pattern / lookup table | When the branches are naturally exclusive states with branch-specific logic |
37
+ For pattern recognition, read `references/pattern-recognition-detail.md`. Load only when this part of the task applies.
91
38
 
92
39
  ## Rule of 500 — automate large refactors
93
40
 
@@ -0,0 +1,11 @@
1
+ ## Pattern recognition
2
+
3
+ Frequent simplification targets — but apply Rules 1-5 before acting:
4
+
5
+ | Smell | Healthy refactor | When NOT to refactor |
6
+ |-------|------------------|----------------------|
7
+ | Deep nesting (4+ levels) | Early returns / guard clauses | When the nesting maps to a real domain hierarchy (e.g., visitor pattern) |
8
+ | Long function (>50 lines) | Extract method | When the "natural" extraction would produce 3-4 single-call helpers — you're trading complexity for indirection |
9
+ | Generic name (`data`, `info`, `helper`) | Rename to specific | When the function genuinely processes generic input (e.g., a serializer middleware) |
10
+ | Duplication (same 5 lines twice) | Extract to function/constant | When the duplication is by design (e.g., independent business rules that may diverge) |
11
+ | `if/elif/else` chain (5+ branches) | Strategy pattern / lookup table | When the branches are naturally exclusive states with branch-specific logic |
@@ -0,0 +1,48 @@
1
+ ## The Five Rules
2
+
3
+ ### 1. Chesterton's Fence — understand BEFORE changing
4
+
5
+ Before removing or rewriting any code, answer three questions:
6
+
7
+ 1. **What does it actually do?** Run/trace it; don't guess from the name.
8
+ 2. **Why was it added?** Check `git log --follow <file> --oneline` and look at the introducing commit's message + PR. Often there's a reason.
9
+ 3. **What breaks if it's gone?** Search for callers. Run the test suite to find what changes.
10
+
11
+ If you can't answer all three, you're not ready to simplify. Get answers first.
12
+
13
+ Concrete cases where Chesterton's Fence saves you:
14
+ - A "redundant" early return that handles a race condition.
15
+ - A "useless" type cast that fixes a compiler bug on a specific platform.
16
+ - A "duplicated" check that exists for clarity at the API boundary.
17
+ - A "dead" branch that runs only with a feature flag enabled in production.
18
+
19
+ ### 2. Preserve behavior exactly
20
+
21
+ The test for "did I simplify or did I change?" is: do the existing tests still pass without modification? If yes, behavior is preserved. If you needed to update tests, you changed behavior — that's a refactor, not a simplification.
22
+
23
+ When tests are inadequate to confirm behavior preservation, write tests FIRST that document current behavior, then simplify against them. This is the test characterization technique.
24
+
25
+ ### 3. Follow project conventions
26
+
27
+ Match what the project already does. If files use 2-space indent and arrow functions, your simplified version uses 2-space indent and arrow functions — even if you'd prefer 4-space and `function`. Conventions matter more than personal preference; consistency is itself a form of clarity.
28
+
29
+ Project conventions live in `.dw/rules/<module>.md` (from `/dw-analyze-project`). Read first.
30
+
31
+ ### 4. Prefer clarity over cleverness
32
+
33
+ Rules of thumb:
34
+
35
+ - A line of code that takes 30 seconds to understand is worse than three lines that take 5 seconds each.
36
+ - A "neat trick" with comments is uglier than the boring obvious code without comments.
37
+ - Optimization that costs readability needs measurement (`dw-performance` skill territory) — without numbers, prefer the readable version.
38
+ - "Magic" that requires knowing a language feature most teammates haven't used is anti-clarity. Use it only when the alternative is genuinely worse.
39
+
40
+ ### 5. Scope to recent changes
41
+
42
+ Don't go simplifying old code while you're "in there". The risk-to-benefit ratio of changing 5-year-old battle-tested code is bad. Limit simplification to:
43
+
44
+ - Code you just wrote in this session.
45
+ - Code your current task touches.
46
+ - Code with explicit recent breakage (e.g., a bug just fixed that revealed bad structure).
47
+
48
+ Out of scope: any other code, no matter how ugly. Open a task / ADR for those instead of fixing in-flight.
@@ -34,62 +34,7 @@ Do NOT use when:
34
34
 
35
35
  ## The Protocol — Detect → Fetch → Implement → Cite
36
36
 
37
- ### 1. Detect — read the actual version first
38
-
39
- Before researching anything, read the project's manifest and identify the EXACT version of the library/framework that matters:
40
-
41
- | Stack | File | Field |
42
- |-------|------|-------|
43
- | Node/TS | `package.json` | `dependencies`, `devDependencies` |
44
- | Python | `pyproject.toml`, `requirements*.txt`, `Pipfile.lock` | each dep with version |
45
- | .NET | `*.csproj`, `packages.lock.json` | `PackageReference Version="..."` |
46
- | Rust | `Cargo.toml`, `Cargo.lock` | `[dependencies]` |
47
-
48
- Record the version. If a range (`^4.18.0`), note the lockfile-resolved version.
49
-
50
- If no manifest exists OR the dep is not yet in the manifest (e.g., choosing what to install), record "no version yet — choosing fresh".
51
-
52
- ### 2. Fetch — pull the matching version's official docs
53
-
54
- Authority hierarchy:
55
-
56
- 1. **Official docs** for the EXACT version (or nearest stable). E.g., `react.dev/reference/react?version=18` not `react.dev` default.
57
- 2. **Official changelog / migration guide** when transitioning across versions.
58
- 3. **Web standards** (MDN, RFCs, W3C) for cross-implementation behavior.
59
- 4. **Compatibility tables** (caniuse, Compat data) for API support across runtimes.
60
-
61
- Forbidden as primary source:
62
-
63
- - Stack Overflow answers (use only as discovery, then verify via official).
64
- - Tutorial blogs (frequently outdated; never authoritative).
65
- - AI training data (your training is months/years stale).
66
- - README screenshots from random GitHub repos.
67
-
68
- Fetch via `WebFetch` or `mcp__context7__*` if available. If both fail, surface to the user that you're falling back to training-data knowledge AND mark the citation `[source: training-data, unverified]`.
69
-
70
- ### 3. Implement — apply the documented pattern
71
-
72
- Use exactly the API the documented version provides. Don't mix patterns from multiple versions ("this useEffect example is from React 16; you're on 18.3"). When the doc shows multiple acceptable patterns, pick the simplest that matches the project's style.
73
-
74
- If the doc presents migration warnings (e.g., "deprecated in v5, use X instead"), follow the new path unless the project explicitly pins to the old version for a documented reason.
75
-
76
- ### 4. Cite — record the source verifiably
77
-
78
- Every decision that depended on an external source ends with a citation block:
79
-
80
- ```
81
- [source: <url>, version: <X.Y>, retrieved: <YYYY-MM-DD>]
82
- ```
83
-
84
- Examples:
85
-
86
- ```
87
- [source: https://react.dev/reference/react/useEffect, version: 18.3, retrieved: 2026-05-07]
88
- [source: https://docs.python.org/3.12/library/asyncio-task.html, version: 3.12, retrieved: 2026-05-07]
89
- [source: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html, version: SDK v3, retrieved: 2026-05-07]
90
- ```
91
-
92
- When citing in PRDs, techspecs, decision logs, or deps-audit reports, the citation is mandatory adjacent to each claim. A future engineer reading the doc can click and verify.
37
+ For the protocol — detect → fetch → implement → cite, read `references/the-protocol-detect-fetch-implement-cite-detail.md`. Load only when this part of the task applies.
93
38
 
94
39
  ## How `dw-create-techspec` uses this
95
40
 
@@ -0,0 +1,58 @@
1
+ ## The Protocol — Detect → Fetch → Implement → Cite
2
+
3
+ ### 1. Detect — read the actual version first
4
+
5
+ Before researching anything, read the project's manifest and identify the EXACT version of the library/framework that matters:
6
+
7
+ | Stack | File | Field |
8
+ |-------|------|-------|
9
+ | Node/TS | `package.json` | `dependencies`, `devDependencies` |
10
+ | Python | `pyproject.toml`, `requirements*.txt`, `Pipfile.lock` | each dep with version |
11
+ | .NET | `*.csproj`, `packages.lock.json` | `PackageReference Version="..."` |
12
+ | Rust | `Cargo.toml`, `Cargo.lock` | `[dependencies]` |
13
+
14
+ Record the version. If a range (`^4.18.0`), note the lockfile-resolved version.
15
+
16
+ If no manifest exists OR the dep is not yet in the manifest (e.g., choosing what to install), record "no version yet — choosing fresh".
17
+
18
+ ### 2. Fetch — pull the matching version's official docs
19
+
20
+ Authority hierarchy:
21
+
22
+ 1. **Official docs** for the EXACT version (or nearest stable). E.g., `react.dev/reference/react?version=18` not `react.dev` default.
23
+ 2. **Official changelog / migration guide** when transitioning across versions.
24
+ 3. **Web standards** (MDN, RFCs, W3C) for cross-implementation behavior.
25
+ 4. **Compatibility tables** (caniuse, Compat data) for API support across runtimes.
26
+
27
+ Forbidden as primary source:
28
+
29
+ - Stack Overflow answers (use only as discovery, then verify via official).
30
+ - Tutorial blogs (frequently outdated; never authoritative).
31
+ - AI training data (your training is months/years stale).
32
+ - README screenshots from random GitHub repos.
33
+
34
+ Fetch via `WebFetch` or `mcp__context7__*` if available. If both fail, surface to the user that you're falling back to training-data knowledge AND mark the citation `[source: training-data, unverified]`.
35
+
36
+ ### 3. Implement — apply the documented pattern
37
+
38
+ Use exactly the API the documented version provides. Don't mix patterns from multiple versions ("this useEffect example is from React 16; you're on 18.3"). When the doc shows multiple acceptable patterns, pick the simplest that matches the project's style.
39
+
40
+ If the doc presents migration warnings (e.g., "deprecated in v5, use X instead"), follow the new path unless the project explicitly pins to the old version for a documented reason.
41
+
42
+ ### 4. Cite — record the source verifiably
43
+
44
+ Every decision that depended on an external source ends with a citation block:
45
+
46
+ ```
47
+ [source: <url>, version: <X.Y>, retrieved: <YYYY-MM-DD>]
48
+ ```
49
+
50
+ Examples:
51
+
52
+ ```
53
+ [source: https://react.dev/reference/react/useEffect, version: 18.3, retrieved: 2026-05-07]
54
+ [source: https://docs.python.org/3.12/library/asyncio-task.html, version: 3.12, retrieved: 2026-05-07]
55
+ [source: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html, version: SDK v3, retrieved: 2026-05-07]
56
+ ```
57
+
58
+ When citing in PRDs, techspecs, decision logs, or deps-audit reports, the citation is mandatory adjacent to each claim. A future engineer reading the doc can click and verify.