@brunosps00/dev-workflow 0.9.0 → 0.11.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 (83) hide show
  1. package/README.md +48 -20
  2. package/lib/constants.js +2 -10
  3. package/lib/init.js +20 -3
  4. package/lib/migrate-gsd.js +1 -1
  5. package/lib/utils.js +8 -3
  6. package/package.json +1 -1
  7. package/scaffold/en/commands/dw-analyze-project.md +61 -0
  8. package/scaffold/en/commands/dw-autopilot.md +6 -6
  9. package/scaffold/en/commands/dw-brainstorm.md +1 -1
  10. package/scaffold/en/commands/dw-bugfix.md +1 -0
  11. package/scaffold/en/commands/dw-code-review.md +29 -0
  12. package/scaffold/en/commands/dw-commit.md +6 -0
  13. package/scaffold/en/commands/dw-create-prd.md +16 -0
  14. package/scaffold/en/commands/dw-create-tasks.md +42 -0
  15. package/scaffold/en/commands/dw-create-techspec.md +19 -0
  16. package/scaffold/en/commands/dw-deep-research.md +6 -0
  17. package/scaffold/en/commands/dw-deps-audit.md +1 -0
  18. package/scaffold/en/commands/dw-find-skills.md +4 -4
  19. package/scaffold/en/commands/dw-fix-qa.md +1 -0
  20. package/scaffold/en/commands/dw-generate-pr.md +1 -0
  21. package/scaffold/en/commands/dw-help.md +9 -29
  22. package/scaffold/en/commands/dw-intel.md +1 -1
  23. package/scaffold/en/commands/dw-refactoring-analysis.md +2 -1
  24. package/scaffold/en/commands/dw-review-implementation.md +28 -2
  25. package/scaffold/en/commands/dw-run-plan.md +2 -2
  26. package/scaffold/en/templates/constitution-template.md +111 -0
  27. package/scaffold/en/templates/idea-onepager.md +1 -1
  28. package/scaffold/pt-br/commands/dw-analyze-project.md +61 -0
  29. package/scaffold/pt-br/commands/dw-autopilot.md +6 -6
  30. package/scaffold/pt-br/commands/dw-brainstorm.md +1 -1
  31. package/scaffold/pt-br/commands/dw-bugfix.md +1 -0
  32. package/scaffold/pt-br/commands/dw-code-review.md +29 -0
  33. package/scaffold/pt-br/commands/dw-commit.md +6 -0
  34. package/scaffold/pt-br/commands/dw-create-prd.md +16 -0
  35. package/scaffold/pt-br/commands/dw-create-tasks.md +42 -0
  36. package/scaffold/pt-br/commands/dw-create-techspec.md +19 -0
  37. package/scaffold/pt-br/commands/dw-deep-research.md +6 -0
  38. package/scaffold/pt-br/commands/dw-deps-audit.md +1 -0
  39. package/scaffold/pt-br/commands/dw-find-skills.md +4 -4
  40. package/scaffold/pt-br/commands/dw-fix-qa.md +1 -0
  41. package/scaffold/pt-br/commands/dw-generate-pr.md +1 -0
  42. package/scaffold/pt-br/commands/dw-help.md +9 -29
  43. package/scaffold/pt-br/commands/dw-intel.md +1 -1
  44. package/scaffold/pt-br/commands/dw-refactoring-analysis.md +2 -1
  45. package/scaffold/pt-br/commands/dw-review-implementation.md +21 -2
  46. package/scaffold/pt-br/commands/dw-run-plan.md +2 -2
  47. package/scaffold/pt-br/templates/constitution-template.md +111 -0
  48. package/scaffold/pt-br/templates/idea-onepager.md +1 -1
  49. package/scaffold/skills/dw-codebase-intel/SKILL.md +1 -0
  50. package/scaffold/skills/dw-codebase-intel/references/api-design-discipline.md +138 -0
  51. package/scaffold/skills/dw-debug-protocol/SKILL.md +106 -0
  52. package/scaffold/skills/dw-debug-protocol/references/error-categorization.md +127 -0
  53. package/scaffold/skills/dw-debug-protocol/references/non-reproducible-strategy.md +108 -0
  54. package/scaffold/skills/dw-debug-protocol/references/six-step-triage.md +139 -0
  55. package/scaffold/skills/dw-debug-protocol/references/stop-the-line.md +52 -0
  56. package/scaffold/skills/dw-git-discipline/SKILL.md +120 -0
  57. package/scaffold/skills/dw-git-discipline/references/atomic-commits-discipline.md +158 -0
  58. package/scaffold/skills/dw-git-discipline/references/branch-hygiene.md +150 -0
  59. package/scaffold/skills/dw-git-discipline/references/trunk-based-pattern.md +82 -0
  60. package/scaffold/skills/dw-memory/SKILL.md +1 -2
  61. package/scaffold/skills/dw-simplification/SKILL.md +142 -0
  62. package/scaffold/skills/dw-simplification/references/behavior-preserving.md +148 -0
  63. package/scaffold/skills/dw-simplification/references/chestertons-fence.md +152 -0
  64. package/scaffold/skills/dw-simplification/references/complexity-metrics.md +147 -0
  65. package/scaffold/skills/dw-source-grounding/SKILL.md +128 -0
  66. package/scaffold/skills/dw-source-grounding/references/citation-protocol.md +108 -0
  67. package/scaffold/skills/dw-source-grounding/references/freshness-check.md +108 -0
  68. package/scaffold/skills/dw-source-grounding/references/source-priority.md +146 -0
  69. package/scaffold/skills/dw-verify/SKILL.md +0 -1
  70. package/scaffold/skills/vercel-react-best-practices/SKILL.md +4 -0
  71. package/scaffold/skills/vercel-react-best-practices/references/perf-discipline.md +122 -0
  72. package/scaffold/skills/webapp-testing/SKILL.md +5 -0
  73. package/scaffold/skills/webapp-testing/references/security-boundary.md +115 -0
  74. package/scaffold/skills/webapp-testing/references/three-workflow-patterns.md +144 -0
  75. package/scaffold/templates-overrides-readme.md +75 -0
  76. package/scaffold/en/commands/dw-execute-phase.md +0 -149
  77. package/scaffold/en/commands/dw-plan-checker.md +0 -144
  78. package/scaffold/en/commands/dw-quick.md +0 -103
  79. package/scaffold/en/commands/dw-resume.md +0 -84
  80. package/scaffold/pt-br/commands/dw-execute-phase.md +0 -149
  81. package/scaffold/pt-br/commands/dw-plan-checker.md +0 -144
  82. package/scaffold/pt-br/commands/dw-quick.md +0 -103
  83. package/scaffold/pt-br/commands/dw-resume.md +0 -84
package/README.md CHANGED
@@ -32,7 +32,7 @@ npx @brunosps00/dev-workflow install-deps
32
32
  Facilitates structured ideation before opening a PRD or implementation. Explores multiple directions — conservative, balanced, and bold — with trade-offs for each, then converges on concrete next steps. **Product-aware**: when PRDs or rules exist, automatically reads them to produce a Feature Inventory and tags each option as `[IMPROVES: <feature>]`, `[CONSOLIDATES: <A>+<B>]`, or `[NEW]`. With optional `--onepager` flag, generates a durable one-pager at `.dw/spec/ideas/<slug>.md` that `/dw-create-prd` can consume to reduce clarification questions. Inspired by [`addyosmani/agent-skills@idea-refine`](https://skills.sh/addyosmani/agent-skills/idea-refine), adapted to product-level (features) rather than code-level grounding. No code is written or project files modified by the brainstorm itself.
33
33
 
34
34
  #### `/dw-autopilot`
35
- Full pipeline orchestrator that takes a wish and automatically runs the entire development flow: codebase intelligence (`/dw-map-codebase` + `/dw-intel`), research (conditional), brainstorm, PRD, techspec, tasks, execution (with `/dw-plan-checker` gate and `/dw-execute-phase` wave-based parallel dispatch), QA, review, and commit. Stops at 3 gates: PRD approval, tasks approval, and PR confirmation.
35
+ Full pipeline orchestrator that takes a wish and automatically runs the entire development flow: codebase intelligence (`/dw-map-codebase` + `/dw-intel`), research (conditional), brainstorm, PRD, techspec, tasks, execution (gated by goal-backward plan verification, then wave-based parallel dispatch from the `dw-execute-phase` bundled skill), QA, review, and commit. Stops at 3 gates: PRD approval, tasks approval, and PR confirmation.
36
36
 
37
37
  #### `/dw-create-prd`
38
38
  Creates a Product Requirements Document by first asking at least 7 clarification questions to fully understand the feature. Generates a structured PRD with numbered functional requirements focused on what and why, saved to `.dw/spec/prd-[feature-name]/prd.md`.
@@ -49,7 +49,7 @@ Breaks down the PRD and TechSpec into implementable tasks with a target of ~6 ta
49
49
  Executes a single task from the task list, implementing code that follows project patterns and includes mandatory unit tests. Performs Level 1 validation (acceptance criteria + tests + standards check) and creates a commit upon completion.
50
50
 
51
51
  #### `/dw-run-plan`
52
- Executes all pending tasks via `/dw-execute-phase`, which gates on `/dw-plan-checker` (6-dimension goal-backward verification) before any code is touched. Wave-based parallel dispatch for independent tasks; atomic commit per task; deviation handling. After all tasks complete, performs a final Level 2 review (PRD compliance) with an interactive corrections cycle until no gaps remain or the user accepts pending items.
52
+ Executes all pending tasks via the `dw-execute-phase` bundled skill gated by 6-dimension goal-backward verification (`plan-checker` agent) before any code is touched. Wave-based parallel dispatch (`executor` agent) for independent tasks; atomic commit per task; deviation handling. After all tasks complete, performs a final Level 2 review (PRD compliance) with an interactive corrections cycle until no gaps remain or the user accepts pending items.
53
53
 
54
54
  #### `/dw-bugfix`
55
55
  Analyzes and fixes bugs with automatic triage that distinguishes between bugs, feature requests, and excessive scope. Asks exactly 3 clarification questions before proposing a solution. Supports Direct mode (executes fix immediately) and Analysis mode (`--analysis`) that generates a document for the techspec/tasks pipeline.
@@ -57,9 +57,6 @@ Analyzes and fixes bugs with automatic triage that distinguishes between bugs, f
57
57
  #### `/dw-redesign-ui`
58
58
  Audits existing frontend pages or components, proposes 2-3 design directions using `ui-ux-pro-max` (colors, typography, layout), waits for user approval, then implements the redesign following the project's CSS methodology. Framework-agnostic (React, Angular, Vue). Generates a design contract persisted for consistency across tasks.
59
59
 
60
- #### `/dw-quick`
61
- Executes a one-off change with workflow guarantees (validation, atomic commit) without requiring a full PRD. For hotfixes, config adjustments, dependency updates, and small refactors. Warns and redirects to `/dw-create-prd` if the change is too large.
62
-
63
60
  ### Quality
64
61
 
65
62
  #### `/dw-run-qa`
@@ -69,7 +66,7 @@ Validates the implementation against PRD, TechSpec, and Tasks. **Mode-aware**: i
69
66
  Fixes bugs found during QA testing with evidence-driven retesting. **Mode-aware**: in UI mode replays the failing flow via Playwright MCP and saves a retest screenshot; in API mode replays the failing `.http`/recipe and appends a `verdict: PASS|FAIL` JSONL line to `QA/logs/api/BUG-NN-retest.log`. Runs iterative cycles of identify, fix, retest, updating `QA/bugs.md` and `QA/qa-report.md` with status and mode-correct evidence.
70
67
 
71
68
  #### `/dw-review-implementation`
72
- Compares documented requirements (PRD + TechSpec + Tasks) against actual code as a Level 2 review. Maps each requirement to endpoints and tasks with evidence, identifies gaps, partial implementations, and extra undocumented code. Does not execute fixeswaits for user instruction.
69
+ Compares documented requirements (PRD + TechSpec + Tasks) against actual code as a Level 2 review. Maps each requirement to endpoints and tasks with evidence, identifies gaps, partial implementations, and extra undocumented code. After the coverage map is complete, automatically chains `/dw-code-review` (Level 3 quality layer) so a single invocation produces a consolidated coverage + quality report pass `--no-code-review` if you want only Level 2.
73
70
 
74
71
  #### `/dw-code-review`
75
72
  Performs a formal Level 3 code review before PR creation, verifying PRD compliance, code quality (SOLID, DRY, complexity, security), and conformance with project rules in `.dw/rules/`. Runs tests, verifies coverage targets, and generates a persistent report with APPROVED, APPROVED WITH CAVEATS, or REJECTED status.
@@ -111,9 +108,6 @@ Records an Architecture Decision Record (ADR) for a non-trivial decision during
111
108
 
112
109
  ### Intelligence
113
110
 
114
- #### `/dw-resume`
115
- Restores context from the last session by reading `.dw/spec/active-session.md` (written by `/dw-execute-phase` at checkpoint), pending tasks, recent git history, and active branches. Suggests the next command to execute.
116
-
117
111
  #### `/dw-intel`
118
112
  Queries codebase intelligence to answer questions about patterns, conventions, and architecture. Reads `.dw/intel/` (built by `/dw-map-codebase`) as primary source, falls back to `.dw/rules/` and direct grep when absent. Surfaces stale-index warnings (>7 days). Always cites sources with file paths and line numbers.
119
113
 
@@ -130,13 +124,11 @@ Generates a functional documentation dossier with screen mapping, E2E flows, and
130
124
  Displays the complete guide of available commands, integration flows, and when to use each one. Can be invoked without arguments for the full guide or with a specific command name for a detailed section.
131
125
 
132
126
  #### `/dw-find-skills`
133
- Discovers skills from the open agent skills ecosystem (`npx skills` / [skills.sh](https://skills.sh/)) when no `dw-*` already covers the request. Checks the leaderboard first, then runs `npx skills find <query>` if needed, vets each candidate (install count, source reputation, GitHub stars), and presents 1–3 options with the install commands. Asks whether to install globally (`-g`, lands in `~/.agents/skills/`) or locally (this repo) before running `npx skills add`. Falls back to `/dw-brainstorm` or `/dw-quick` when no skill matches. Ports the `find-skills` Claude superpowers skill into a `dw-*` command so every supported platform gets the same discovery on-ramp.
127
+ Discovers skills from the open agent skills ecosystem (`npx skills` / [skills.sh](https://skills.sh/)) when no `dw-*` already covers the request. Checks the leaderboard first, then runs `npx skills find <query>` if needed, vets each candidate (install count, source reputation, GitHub stars), and presents 1–3 options with the install commands. Asks whether to install globally (`-g`, lands in `~/.agents/skills/`) or locally (this repo) before running `npx skills add`. Falls back to `/dw-brainstorm` or `/dw-run-task` when no skill matches. Ports the `find-skills` Claude superpowers skill into a `dw-*` command so every supported platform gets the same discovery on-ramp.
134
128
 
135
129
  ## Workflow
136
130
 
137
131
  ```
138
- /dw-resume (pick up where you left off)
139
- |
140
132
  /dw-autopilot "wish" ------> Runs entire pipeline automatically
141
133
  (gates: PRD approval, Tasks approval, PR confirmation)
142
134
  --- OR ---
@@ -162,11 +154,35 @@ Discovers skills from the open agent skills ecosystem (`npx skills` / [skills.sh
162
154
  /dw-commit + /dw-generate-pr
163
155
 
164
156
  Shortcuts:
165
- /dw-quick "description" One-off change with workflow guarantees
166
157
  /dw-intel "question" Query codebase intelligence
167
158
  /dw-redesign-ui "target" Visual redesign of a page or component
168
159
  ```
169
160
 
161
+ ## Constitution
162
+
163
+ A **constitution** is a declarative list of principles your team commits to (e.g., "every state-changing endpoint requires server-side authorization", "every bug fix ships with a regression test"). It lives at `.dw/constitution.md` and complements `.dw/rules/`:
164
+
165
+ | File | Type | Authored by |
166
+ |------|------|-------------|
167
+ | `.dw/rules/` | Analytical — describes what the code IS (observed patterns) | `/dw-analyze-project` |
168
+ | `.dw/constitution.md` | Declarative — describes what the code SHOULD BE (committed principles) | `/dw-analyze-project` (Step 8) or auto-installed defaults |
169
+
170
+ **How it works:**
171
+
172
+ - `/dw-analyze-project` offers three paths: synthesize from observed patterns (with your approval), install canonical defaults, or skip.
173
+ - If `/dw-create-prd`, `/dw-create-techspec`, or `/dw-code-review` run **without** a constitution, they auto-install the defaults template (10 canonical principles at `severity: info`), notify in chat, and continue. Ausência nunca bloqueia.
174
+ - Once principles exist:
175
+ - `severity: info` → reported, never blocks.
176
+ - `severity: high` → blocks PR/techspec when violated, unless an ADR justifies the deviation.
177
+ - `severity: critical` → blocks plus requires reviewer sign-off in the ADR.
178
+ - Defaults start at `info`; you promote severities as your team trusts enforcement.
179
+
180
+ **Tasks consistency check.** At the end of `/dw-create-tasks`, a 5-dimension consistency check validates PRD ↔ TechSpec ↔ Tasks alignment (FR coverage, task grounding, test coverage, dependency DAG, constitution alignment) and writes `.dw/spec/prd-<feature>/tasks-validation.md`. Any FAIL blocks user approval until resolved or explicitly overridden.
181
+
182
+ ## Template Overrides
183
+
184
+ Customize templates locally without losing dev-workflow updates. Drop a file at `.dw/templates/overrides/<name>.md`; the override is used in place of the bundled core template on every `update`. Subdirectories work too (e.g., `.dw/templates/overrides/functional-doc/e2e-runbook.md`). See `.dw/templates/overrides/README.md` (created on init) for the workflow and `diff` cadence guidance.
185
+
170
186
  ## Platform Support
171
187
 
172
188
  | Platform | Wrapper Location | Status |
@@ -183,12 +199,14 @@ All wrappers point to `.dw/commands/` as the single source of truth.
183
199
  ```
184
200
  your-project/
185
201
  ├── .dw/
186
- │ ├── commands/ # 31 workflow command files
202
+ │ ├── commands/ # 30 workflow command files
187
203
  │ ├── templates/ # Document templates (PRD, TechSpec, etc.)
204
+ │ │ └── overrides/ # Project-local template customizations (override > core)
188
205
  │ ├── rules/ # Project-specific rules (run /dw-analyze-project)
206
+ │ ├── constitution.md # Declarative principles (auto-installed when missing)
189
207
  │ ├── references/ # Reference documentation
190
208
  │ ├── scripts/ # Utility scripts
191
- │ └── spec/ # PRD directories created by commands
209
+ │ └── spec/ # PRD directories each contains tasks-validation.md
192
210
  ├── .claude/
193
211
  │ ├── skills/ # Claude Code wrappers
194
212
  │ └── settings.json # MCP servers (Context7, Playwright)
@@ -206,21 +224,27 @@ These are not slash commands — they are primitives other commands call to enfo
206
224
 
207
225
  | Skill | Description | Invoked by | Inspired by |
208
226
  |-------|-------------|------------|-------------|
209
- | **dw-verify** | Enforces fresh verification evidence before any completion, commit, or PR claim — with Iron Law, gate function, and Verification Report template | `dw-run-task`, `dw-run-plan`, `dw-fix-qa`, `dw-bugfix`, `dw-code-review`, `dw-generate-pr`, `dw-quick` | [Compozy](https://github.com/compozy/compozy) `cy-final-verify` |
210
- | **dw-memory** | Two-tier workflow memory (shared `MEMORY.md` + per-task `<N>_memory.md`) with promotion test and compaction rules, so cross-task context persists cleanly | `dw-run-task`, `dw-run-plan`, `dw-autopilot`, `dw-resume` | [Compozy](https://github.com/compozy/compozy) `cy-workflow-memory` |
227
+ | **dw-verify** | Enforces fresh verification evidence before any completion, commit, or PR claim — with Iron Law, gate function, and Verification Report template | `dw-run-task`, `dw-run-plan`, `dw-fix-qa`, `dw-bugfix`, `dw-code-review`, `dw-generate-pr` | [Compozy](https://github.com/compozy/compozy) `cy-final-verify` |
228
+ | **dw-memory** | Two-tier workflow memory (shared `MEMORY.md` + per-task `<N>_memory.md`) with promotion test and compaction rules, so cross-task context persists cleanly | `dw-run-task`, `dw-run-plan`, `dw-autopilot` | [Compozy](https://github.com/compozy/compozy) `cy-workflow-memory` |
211
229
  | **dw-review-rigor** | Review discipline: de-duplication, severity ordering, verify-intent-before-flagging, skip-linter-issues, signal-over-volume | `dw-code-review`, `dw-review-implementation`, `dw-refactoring-analysis` | [Compozy](https://github.com/compozy/compozy) `cy-review-round` |
212
230
  | **dw-council** | Multi-advisor debate (3-5 archetypes) with steel-manning, concession tracking, and dissent-preserving synthesis. Opt-in only. | `dw-brainstorm --council`, `dw-create-techspec --council` | [Compozy](https://github.com/compozy/compozy) `cy-idea-factory` |
231
+ | **dw-codebase-intel** | Codebase intelligence (`stack.json`, `files.json`, `apis.json`, `deps.json`, `arch.md`) with incremental updates and query patterns. Cross-cutting reference: `api-design-discipline` (Hyrum's Law, contract-first, error semantics) used when techspecs design API endpoints. | `/dw-intel`, `/dw-map-codebase`, `dw-create-techspec` | [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) (MIT) + [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) (MIT) |
232
+ | **dw-execute-phase** | Goal-backward 6-dimension plan verification (`plan-checker`) and wave-based parallel task execution (`executor`) with atomic commit, deviation handling, and checkpoint recovery | `dw-run-plan`, `dw-autopilot` | [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) (MIT) |
233
+ | **dw-source-grounding** | Detect → Fetch → Implement → Cite protocol with `[source: <url>, version: X.Y, retrieved: YYYY-MM-DD]` citations. Strict source-priority hierarchy (Tier 1 official docs > Tier 2 maintainer blogs > Tier 3 Stack Overflow as discovery only). | `dw-create-techspec`, `dw-deps-audit`, `dw-deep-research` | [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) (MIT) |
234
+ | **dw-simplification** | Chesterton's Fence (understand WHY before changing), behavior-preserving refactor protocol (test gate before/after), complexity metrics (cyclomatic, cognitive, depth, fan-out), Rule of 500 for large refactors | `dw-code-review`, `dw-refactoring-analysis` | [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) (MIT) |
235
+ | **dw-debug-protocol** | Stop-the-line discipline plus six-step triage (Reproduce → Localize → Reduce → Fix Root Cause → Guard → Verify End-to-End). Error categorization matrix; instrument-first non-reproducible-bug strategy. | `dw-bugfix`, `dw-fix-qa` | [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) (MIT) |
236
+ | **dw-git-discipline** | Trunk-based pattern (1-3 day branches, daily rebase, feature flags), atomic commit discipline (one intent per commit; refactor separate from feature), Conventional Commits, branch hygiene | `dw-commit`, `dw-generate-pr` | [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) (MIT) |
213
237
 
214
238
  ### Domain expertise
215
239
 
216
240
  | Skill | Description | Source | License |
217
241
  |-------|-------------|--------|---------|
218
242
  | **ui-ux-pro-max** | Design intelligence: 50+ styles, 161 color palettes, 57 font pairings, 99 UX guidelines across 10 stacks | [Next Level Builder](https://github.com/skills-sh) | MIT |
219
- | **vercel-react-best-practices** | 67 React/Next.js performance optimization rules across 8 priority categories | [Vercel Labs](https://github.com/vercel-labs/agent-skills) | MIT |
243
+ | **vercel-react-best-practices** | 67 React/Next.js performance optimization rules across 8 priority categories. Wraps the rules with `references/perf-discipline.md` (measure → identify → fix → verify → guard) so perf work is data-driven, not vibes-based | [Vercel Labs](https://github.com/vercel-labs/agent-skills) + [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) | MIT |
220
244
  | **security-review** | Systematic vulnerability review based on OWASP with confidence-based reporting | [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/) | CC BY-SA 4.0 |
221
245
  | **humanizer** | Detects and removes 24 AI writing patterns based on Wikipedia's "Signs of AI Writing" guide | [Wikipedia AI Writing Guide](https://en.wikipedia.org/wiki/Wikipedia:Signs_of_AI_writing) | -- |
222
246
  | **remotion-best-practices** | 25+ rules for video creation in React with Remotion | [Remotion](https://www.remotion.dev/) | -- |
223
- | **webapp-testing** | Playwright-based browser testing toolkit for E2E validation and screenshots | [Playwright](https://playwright.dev/) | -- |
247
+ | **webapp-testing** | Playwright-based browser testing toolkit for E2E validation and screenshots. Cross-cutting references: `security-boundary` (every byte from a browser is potentially attacker-controlled) and `three-workflow-patterns` (UI bugs vs network issues vs perf — distinct workflows, don't conflate) | [Playwright](https://playwright.dev/) + [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) | -- |
224
248
 
225
249
  ## Dependencies
226
250
 
@@ -258,7 +282,11 @@ After running `npx @brunosps00/dev-workflow init`:
258
282
 
259
283
  ## Acknowledgements
260
284
 
261
- Codebase intelligence (`/dw-intel`, `/dw-map-codebase`, the `dw-codebase-intel` bundled skill) and phase execution patterns (`/dw-execute-phase`, `/dw-plan-checker`, the `dw-execute-phase` bundled skill) were adapted from [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) by gsd-build (MIT). Schemas (`stack.json`, `files.json`, `apis.json`, `deps.json`, `arch.md`), the goal-backward verification protocol, and the wave-based parallel execution pattern come from there. dev-workflow specifics: `.dw/` namespace instead of `.planning/`, agent-driven runtime instead of `gsd-sdk` CLI, integration with the rest of the `dw-*` command surface.
285
+ Codebase intelligence (`/dw-intel`, `/dw-map-codebase`, the `dw-codebase-intel` bundled skill) and phase execution patterns (the `dw-execute-phase` bundled skill, with its `plan-checker` and `executor` agents) were adapted from [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) by gsd-build (MIT). Schemas (`stack.json`, `files.json`, `apis.json`, `deps.json`, `arch.md`), the goal-backward verification protocol, and the wave-based parallel execution pattern come from there. dev-workflow specifics: `.dw/` namespace instead of `.planning/`, agent-driven runtime instead of `gsd-sdk` CLI, integration with the rest of the `dw-*` command surface.
286
+
287
+ Source-driven development, code simplification, debugging discipline, and git workflow patterns adapted from [`addyosmani/agent-skills`](https://github.com/addyosmani/agent-skills) by Addy Osmani (MIT) into the bundled `dw-source-grounding`, `dw-simplification`, `dw-debug-protocol`, and `dw-git-discipline` skills. Performance-optimization workflow (`vercel-react-best-practices/references/perf-discipline.md`), API-design discipline (`dw-codebase-intel/references/api-design-discipline.md`), and browser-DevTools patterns (`webapp-testing/references/{security-boundary, three-workflow-patterns}`) also incorporated as enhancements to existing bundled skills.
288
+
289
+ Spec-Driven Development patterns — declarative constitution (`.dw/constitution.md`), cross-artifact consistency check (PRD ↔ TechSpec ↔ Tasks), and template override layer (`.dw/templates/overrides/`) — adapted from [`github/spec-kit`](https://github.com/github/spec-kit) by GitHub (MIT). dev-workflow specifics: embedded into existing commands instead of new slash commands, severity-graded enforcement (`info`/`high`/`critical`) with ADR-justified deviation as the escape hatch, ausência-of-constitution never blocks (auto-installs defaults and continues), and integration with the analytical `.dw/rules/` already produced by `/dw-analyze-project`.
262
290
 
263
291
  ## License
264
292
 
package/lib/constants.js CHANGED
@@ -13,7 +13,6 @@ const COMMANDS = {
13
13
  { name: 'dw-deep-research', description: 'Researches a topic across sources, tracks citations, and flags claims that don\'t check out.' },
14
14
  { name: 'dw-deps-audit', description: 'Finds outdated and supply-chain-compromised packages, drafts a per-package update plan, and runs scoped QA after each upgrade.' },
15
15
  { name: 'dw-dockerize', description: 'Reads a project, detects the stack and runtime deps, then proposes Dockerfile and docker-compose for dev and prod with explicit trade-offs.' },
16
- { name: 'dw-execute-phase', description: 'Executes a PRD phase in waves with atomic commits per task, deviation handling, and a hard plan-checker gate before any code is touched.' },
17
16
  { name: 'dw-find-skills', description: 'Searches the npx skills ecosystem for a skill matching what you need, vets it, and installs it where you choose.' },
18
17
  { name: 'dw-fix-qa', description: 'Fixes bugs found in QA and retests them with screenshot evidence until they stay fixed.' },
19
18
  { name: 'dw-functional-doc', description: 'Maps screens and user flows into a functional doc, validated end-to-end with Playwright.' },
@@ -22,12 +21,9 @@ const COMMANDS = {
22
21
  { name: 'dw-intel', description: 'Answers questions about the codebase by querying .dw/intel/ (built by /dw-map-codebase) with .dw/rules/ and grep as fallbacks.' },
23
22
  { name: 'dw-map-codebase', description: 'Builds a queryable index in .dw/intel/ (stack, files, apis, deps, arch) so other commands stop re-exploring the codebase.' },
24
23
  { name: 'dw-new-project', description: 'Interviews you about stack and infra, then scaffolds a working monorepo with docker-compose for dev, .env, scripts, CI, and seeded rules.' },
25
- { name: 'dw-plan-checker', description: 'Goal-backward verification of a phase tasks.md before execution. Returns PASS, REVISE, or BLOCK across 6 dimensions.' },
26
- { name: 'dw-quick', description: 'Runs a small, well-defined change with workflow guarantees, no PRD needed.' },
27
24
  { name: 'dw-redesign-ui', description: 'Audits a frontend page, proposes design directions you choose from, then ships the redesign.' },
28
25
  { name: 'dw-refactoring-analysis', description: 'Catalogs code smells in Fowler\'s vocabulary and ranks them by impact, P0 to P3.' },
29
- { name: 'dw-resume', description: 'Picks up where you left off reads the active PRD, the last task, and tells you what\'s next.' },
30
- { name: 'dw-review-implementation', description: 'Maps every PRD requirement to the code that delivers it, and lists what is still missing.' },
26
+ { name: 'dw-review-implementation', description: 'Maps every PRD requirement to the code that delivers it, then runs /dw-code-review for the Level 3 quality layer.' },
31
27
  { name: 'dw-revert-task', description: 'Reverts the commits of one task, but only after checking nothing downstream depends on it.' },
32
28
  { name: 'dw-run-plan', description: 'Runs every pending task in order, with PRD-compliance review at the end.' },
33
29
  { name: 'dw-run-qa', description: 'Drives the browser to test happy paths, edge cases, and accessibility, with screenshot proof.' },
@@ -49,7 +45,6 @@ const COMMANDS = {
49
45
  { name: 'dw-deep-research', description: 'Pesquisa um topico em varias fontes, rastreia citacoes e marca o que nao confere.' },
50
46
  { name: 'dw-deps-audit', description: 'Encontra pacotes desatualizados e comprometidos por supply-chain, monta plano de update por pacote e roda QA do que foi afetado.' },
51
47
  { name: 'dw-dockerize', description: 'Le um projeto, detecta stack e deps de runtime, e propoe Dockerfile e docker-compose para dev e prod com trade-offs explicitos.' },
52
- { name: 'dw-execute-phase', description: 'Executa uma fase de PRD em waves com commits atomicos por task, deviation handling e gate hard de plan-checker antes de tocar codigo.' },
53
48
  { name: 'dw-find-skills', description: 'Busca no ecossistema npx skills uma skill que resolva o que voce precisa, valida e instala onde voce escolher.' },
54
49
  { name: 'dw-fix-qa', description: 'Corrige bugs do QA e retesta com evidencia em screenshot ate ficarem estaveis.' },
55
50
  { name: 'dw-functional-doc', description: 'Mapeia telas e fluxos em um dossie funcional, validado E2E com Playwright.' },
@@ -58,12 +53,9 @@ const COMMANDS = {
58
53
  { name: 'dw-intel', description: 'Responde perguntas sobre o codebase consultando .dw/intel/ (do /dw-map-codebase) com .dw/rules/ e grep como fallback.' },
59
54
  { name: 'dw-map-codebase', description: 'Constroi um indice queryable em .dw/intel/ (stack, files, apis, deps, arch) para outros comandos pararem de re-explorar o codebase.' },
60
55
  { name: 'dw-new-project', description: 'Entrevista voce sobre stack e infra, depois faz scaffold de um monorepo com docker-compose para dev, .env, scripts, CI e rules seed.' },
61
- { name: 'dw-plan-checker', description: 'Verificacao goal-backward de tasks.md de uma fase antes da execucao. Retorna PASS, REVISE ou BLOCK em 6 dimensoes.' },
62
- { name: 'dw-quick', description: 'Roda uma mudanca pequena e bem definida com garantias do workflow, sem precisar de PRD.' },
63
56
  { name: 'dw-redesign-ui', description: 'Audita uma pagina frontend, propoe direcoes de design que voce escolhe, e entrega o redesign.' },
64
57
  { name: 'dw-refactoring-analysis', description: 'Cataloga code smells no vocabulario de Fowler e ranqueia por impacto, P0 a P3.' },
65
- { name: 'dw-resume', description: 'Retoma de onde voce parou le o PRD ativo, a ultima task, e diz qual o proximo passo.' },
66
- { name: 'dw-review-implementation', description: 'Mapeia cada requisito do PRD ao codigo que o entrega, e lista o que ainda falta.' },
58
+ { name: 'dw-review-implementation', description: 'Mapeia cada requisito do PRD ao codigo que o entrega, e roda /dw-code-review para a camada de qualidade Nivel 3.' },
67
59
  { name: 'dw-revert-task', description: 'Reverte os commits de uma task, mas so depois de checar que nada a frente depende dela.' },
68
60
  { name: 'dw-run-plan', description: 'Roda todas as tasks pendentes em ordem, com review de PRD compliance no final.' },
69
61
  { name: 'dw-run-qa', description: 'Pilota o browser para testar fluxo feliz, edge cases e acessibilidade, com screenshot.' },
package/lib/init.js CHANGED
@@ -48,18 +48,35 @@ async function run({ force = false, lang = null, mode = 'init' }) {
48
48
  totalOverwritten += cmdResults.overwritten;
49
49
  console.log(` ${cmdResults.created} created, ${cmdResults.skipped} skipped, ${cmdResults.overwritten} overwritten\n`);
50
50
 
51
- // 3. Copy templates
51
+ // 3. Copy templates (override-aware: .dw/templates/overrides/<name> wins over scaffold core)
52
52
  console.log(' Templates:');
53
+ const templatesDir = path.join(projectRoot, '.dw', 'templates');
54
+ const overridesDir = path.join(templatesDir, 'overrides');
53
55
  const tplResults = copyDir(
54
56
  path.join(langDir, 'templates'),
55
- path.join(projectRoot, '.dw', 'templates'),
56
- managedForce
57
+ templatesDir,
58
+ managedForce,
59
+ overridesDir
57
60
  );
58
61
  totalCreated += tplResults.created;
59
62
  totalSkipped += tplResults.skipped;
60
63
  totalOverwritten += tplResults.overwritten;
61
64
  console.log(` ${tplResults.created} created, ${tplResults.skipped} skipped, ${tplResults.overwritten} overwritten\n`);
62
65
 
66
+ // 3.1. Seed .dw/templates/overrides/ with README on first init (never overwritten)
67
+ ensureDir(overridesDir);
68
+ const overridesReadmeSrc = path.join(SCAFFOLD_DIR, 'templates-overrides-readme.md');
69
+ const overridesReadmeDest = path.join(overridesDir, 'README.md');
70
+ if (require('fs').existsSync(overridesReadmeSrc)) {
71
+ const ovrStatus = writeFile(
72
+ overridesReadmeDest,
73
+ require('fs').readFileSync(overridesReadmeSrc, 'utf-8'),
74
+ false
75
+ );
76
+ if (ovrStatus === 'created') totalCreated++;
77
+ else totalSkipped++;
78
+ }
79
+
63
80
  // 3.5. Copy references (language-specific)
64
81
  const refsSrcDir = path.join(langDir, 'references');
65
82
  if (require('fs').existsSync(refsSrcDir)) {
@@ -124,7 +124,7 @@ function migrate(projectRoot) {
124
124
  if (stats.agents_removed) console.log(` - .claude/agents/gsd-*.md (${stats.agents_removed} files removed; native dw-* agents bundled in skills)`);
125
125
  if (stats.hooks_removed) console.log(` - .claude/hooks/gsd-*.js (${stats.hooks_removed} files removed; not used by dev-workflow)`);
126
126
  if (stats.manifest_removed) console.log(' - .claude/gsd-file-manifest.json (removed)');
127
- console.log(' Done. Native /dw-intel, /dw-map-codebase, /dw-execute-phase, /dw-plan-checker, /dw-resume now provide what GSD provided.');
127
+ console.log(' Done. Native /dw-intel, /dw-map-codebase, /dw-run-plan (with bundled phase-execution agents) now provide what GSD provided.');
128
128
  console.log();
129
129
 
130
130
  return stats;
package/lib/utils.js CHANGED
@@ -29,7 +29,7 @@ function writeFile(filePath, content, force = false) {
29
29
  return exists ? 'overwritten' : 'created';
30
30
  }
31
31
 
32
- function copyDir(srcDir, destDir, force = false) {
32
+ function copyDir(srcDir, destDir, force = false, overridesDir = null) {
33
33
  const results = { created: 0, skipped: 0, overwritten: 0 };
34
34
 
35
35
  if (!fs.existsSync(srcDir)) {
@@ -40,14 +40,19 @@ function copyDir(srcDir, destDir, force = false) {
40
40
  for (const entry of entries) {
41
41
  const srcPath = path.join(srcDir, entry.name);
42
42
  const destPath = path.join(destDir, entry.name);
43
+ const overridePath = overridesDir ? path.join(overridesDir, entry.name) : null;
43
44
 
44
45
  if (entry.isDirectory()) {
45
- const sub = copyDir(srcPath, destPath, force);
46
+ const subOverrides = overridePath && fs.existsSync(overridePath) ? overridePath : null;
47
+ const sub = copyDir(srcPath, destPath, force, subOverrides);
46
48
  results.created += sub.created;
47
49
  results.skipped += sub.skipped;
48
50
  results.overwritten += sub.overwritten;
49
51
  } else {
50
- const status = copyFile(srcPath, destPath, force);
52
+ // Override wins: copy from override path so dest reflects user customization.
53
+ // Always force-copy overrides so a manual edit to overrides/X.md propagates to templates/X.md on next update.
54
+ const effectiveSrc = overridePath && fs.existsSync(overridePath) ? overridePath : srcPath;
55
+ const status = copyFile(effectiveSrc, destPath, effectiveSrc === overridePath ? true : force);
51
56
  results[status]++;
52
57
  }
53
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brunosps00/dev-workflow",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
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"
@@ -705,6 +705,67 @@ packages/auth → packages/db
705
705
  6. {apps/web} — depends on ui, db, auth
706
706
  ```
707
707
 
708
+ ### Step 8: Constitution Generation (Optional but Recommended)
709
+
710
+ After `.dw/rules/` is written, offer to generate `.dw/constitution.md` — the declarative principles the team wants enforced on PRDs, TechSpecs, and Code Reviews.
711
+
712
+ **Difference from `.dw/rules/`:**
713
+ - `.dw/rules/` is **analytical** — what the code IS (observed patterns, anti-patterns, conventions).
714
+ - `.dw/constitution.md` is **declarative** — what the code SHOULD BE (rules the team commits to).
715
+
716
+ **Behavior:**
717
+
718
+ If `.dw/constitution.md` already exists, print "Constitution already present at `.dw/constitution.md` — skipping (edit it manually if you want to update)" and finish.
719
+
720
+ Otherwise, present 3 options in the chat (use the user's preferred question UI when available; otherwise plain text):
721
+
722
+ ```
723
+ A constitution would help PRDs/TechSpecs/PRs stay aligned with project standards.
724
+ Three options:
725
+
726
+ A) Synthesize from observed patterns (recommended)
727
+ I read `.dw/rules/` and propose 5–8 principles grounded in real code,
728
+ each with `Why:` linked to evidence and `severity: info` (won't block).
729
+ You review and approve before anything is written.
730
+
731
+ B) Install defaults template
732
+ Copy `templates/constitution-template.md` to `.dw/constitution.md` with
733
+ 5 canonical principles (Code Quality, Testing, UX, Performance, Security)
734
+ pre-filled at `severity: info`. You customize manually.
735
+
736
+ C) Skip
737
+ No constitution. Downstream commands will operate without the gate.
738
+ You can run this step again later by re-running `/dw-analyze-project`.
739
+ ```
740
+
741
+ **Option A — Synthesize:**
742
+
743
+ 1. Read `.dw/rules/index.md` + each `.dw/rules/{module}.md`.
744
+ 2. Propose 5–8 principles. Each must:
745
+ - Have a unique `P-NNN` ID.
746
+ - Map to an observation in `.dw/rules/` (cite the rule file + section).
747
+ - Start at `severity: info` (never propose `high`/`critical` automatically — that's the team's call).
748
+ - Follow the format: `**P-NNN — <name>** (severity: info): <rule>. **Why:** <ground in evidence>. **Enforcement:** <how to check>.`
749
+ 3. **Show the proposed principles in the chat as a markdown list** (do not write the file yet). Include the evidence citation for each.
750
+ 4. Ask: "Edit any of these before I write the file? Reply with the IDs to drop/edit, or 'approve' to write as-is."
751
+ 5. After user approves (with edits applied), write to `.dw/constitution.md` using the same template structure as `templates/constitution-template.md`.
752
+ 6. Set frontmatter `mode: custom` and `last_updated: <today's ISO date>`.
753
+
754
+ **Option B — Defaults:**
755
+
756
+ 1. Locate `templates/constitution-template.md` (project-local at `.dw/templates/constitution-template.md`, falling back to the bundled scaffold).
757
+ 2. Copy to `.dw/constitution.md` verbatim. Set frontmatter `mode: defaults`.
758
+ 3. Print: "Installed defaults constitution at `.dw/constitution.md`. All 10 principles start at `severity: info` — they report but don't block. Edit the file to customize, then promote severities to `high`/`critical` when you trust the project enforces them."
759
+
760
+ **Option C — Skip:**
761
+
762
+ 1. Do nothing.
763
+ 2. Print: "Skipped. PRD/TechSpec/CodeReview will run without the constitution gate. Re-run `/dw-analyze-project` later if you want to enable it."
764
+
765
+ **No matter which option:**
766
+ - Never write `.dw/constitution.md` without explicit user approval (option A) or explicit choice (options B/C).
767
+ - Constitution file is committed to the repository like any other project artifact — never gitignored.
768
+
708
769
  ## Quality Checklist
709
770
 
710
771
  Before declaring the analysis complete, verify:
@@ -26,7 +26,7 @@ A step that invokes a `/dw-xxx` command is ONLY considered complete when the art
26
26
  ## When to Use
27
27
  - Use when you want to go from an idea to a PR with minimal manual intervention
28
28
  - Use for complete features that go through the entire pipeline (research, planning, execution, quality)
29
- - Do NOT use for one-off changes (use `/dw-quick`)
29
+ - Do NOT use for small, well-scoped one-off tasks use `/dw-run-task` directly with a quick PRD instead
30
30
  - Do NOT use to fix bugs (use `/dw-bugfix`)
31
31
  - Do NOT use when you want manual control between each phase (use individual commands)
32
32
 
@@ -56,7 +56,7 @@ The autopilot stops ONLY at these 3 moments:
56
56
 
57
57
  ## Session Resumption
58
58
 
59
- If this command is invoked to resume an interrupted autopilot (via `/dw-resume`):
59
+ If this command is re-invoked on the same PRD after interruption:
60
60
 
61
61
  <critical>Read the `autopilot-state.json` file in the PRD directory. Skip ALL steps listed in `completed_steps`. Resume execution from `current_step`. Gates already passed (listed in `gates_passed`) MUST NOT be re-presented.</critical>
62
62
 
@@ -149,7 +149,7 @@ Evaluate whether tasks involve frontend:
149
149
  ### Step 8: Execution
150
150
 
151
151
  Run `/dw-run-plan` with the PRD path.
152
- - Follow ALL command instructions, including the native plan-checker gate (PASS required) and wave-based parallel execution via `/dw-execute-phase`
152
+ - Follow ALL command instructions, including the native plan-checker gate (PASS required) and wave-based parallel execution via the bundled `dw-execute-phase` skill agents
153
153
  - Each task follows `/dw-run-task` with Level 1 validation
154
154
 
155
155
  ### Step 9: Implementation Review (Loop)
@@ -250,11 +250,11 @@ Ask the user: **"Commits completed. Do you want to generate the Pull Request?"**
250
250
 
251
251
  ## Native Engine
252
252
 
253
- The autopilot relies on dev-workflow-native infrastructure for codebase intelligence (`/dw-map-codebase` + `/dw-intel`), plan verification (`/dw-plan-checker`), and parallel execution (`/dw-execute-phase`). All four are bundled and require no external dependencies. See the `dw-codebase-intel` and `dw-execute-phase` bundled skills under `.agents/skills/` for details.
253
+ The autopilot relies on dev-workflow-native infrastructure for codebase intelligence (`/dw-map-codebase` + `/dw-intel`) and bundled phase execution agents (plan-checker + executor in `.agents/skills/dw-execute-phase/agents/`). All bundled and require no external dependencies. See the `dw-codebase-intel` and `dw-execute-phase` bundled skills under `.agents/skills/` for details.
254
254
 
255
255
  ## State Persistence
256
256
 
257
- <critical>The autopilot MUST save its state after each completed step to allow resumption via `/dw-resume` in case of interruption.</critical>
257
+ <critical>The autopilot MUST save its state after each completed step to allow re-invocation on the same PRD after interruption.</critical>
258
258
 
259
259
  Save the file `.dw/spec/prd-[name]/autopilot-state.json` with the following format:
260
260
 
@@ -286,7 +286,7 @@ Save the file `.dw/spec/prd-[name]/autopilot-state.json` with the following form
286
286
 
287
287
  - Update `current_step`, `completed_steps`, and `step_artifacts` BEFORE moving to the next step
288
288
  - A step ONLY moves to `completed_steps` after verifying its artifacts exist on disk
289
- - If the session drops, `/dw-resume` will read this file and continue from the correct step and revalidate artifacts before trusting `completed_steps`
289
+ - If the session drops, re-invoke `/dw-autopilot` on the same PRD; the command reads `autopilot-state.json` and continues from the correct step, revalidating artifacts before trusting `completed_steps`
290
290
  - When the pipeline finishes (after commit or PR), remove the file or mark `"status": "completed"`
291
291
 
292
292
  <critical>After EACH completed step, display the updated progress block to the user. This is MANDATORY — the user MUST see what was done and what comes next. If a step was skipped, the reason MUST appear in the progress block.</critical>
@@ -109,7 +109,7 @@ Use this command when the user wants to:
109
109
  - Short and actionable list
110
110
  - If appropriate, suggest which command to use next:
111
111
  - `/dw-create-prd` (main successor; accepts the one-pager as input, reducing clarification questions)
112
- - `/dw-quick` (if it's a small IMPROVES that fits in a single task, ≤3 files)
112
+ - `/dw-run-task` (if it's a small IMPROVES that fits in a single task with a quick PRD)
113
113
  - `/dw-create-techspec`
114
114
  - `/dw-create-tasks`
115
115
  - `/dw-bugfix`
@@ -15,6 +15,7 @@
15
15
 
16
16
  When available in the project at `./.agents/skills/`, use these skills as contextual support without replacing this command:
17
17
 
18
+ - `dw-debug-protocol`: **ALWAYS** — runs the bug through the six-step triage (Reproduce → Localize → Reduce → Fix Root Cause → Guard → Verify End-to-End). Stop-the-line discipline; root-cause over symptom; regression test committed in the same atomic commit. Non-reproducible bugs follow the instrument-first sub-protocol — no guess fixes without explicit acknowledgement.
18
19
  - `dw-verify`: **ALWAYS** — in Direct mode, invoked before committing the fix. The VERIFICATION REPORT must show the original bug symptom no longer reproduces (not just that tests pass).
19
20
  - `vercel-react-best-practices`: use when the bug affects React/Next.js and there is suspicion of render, hydration, fetching, waterfall, bundle, or re-render issues
20
21
  - `webapp-testing`: use when the fix requires a reproducible E2E/retest flow in a web app
@@ -24,6 +24,7 @@ When available in the project under `./.agents/skills/`, use these skills as ana
24
24
  - `dw-review-rigor`: **ALWAYS** — applies de-duplication (same pattern in N files = 1 finding), severity ordering (critical → high → medium → low), verify-before-flag, skip-what-linter-catches, and signal-over-volume. The report's "Issues Found" table follows this discipline.
25
25
  - `dw-verify`: **ALWAYS** — invoked before emitting an `APPROVED` or `APPROVED WITH CAVEATS` verdict. Without a VERIFICATION REPORT PASS (test + lint + build), the verdict cannot be APPROVED.
26
26
  - `/dw-security-check`: **ALWAYS for TS/Python/C#/Rust projects** — invoked as step 6.7 (Security Layer) before emitting a verdict. If the project uses a supported language and `security-check.md` is missing OR has REJECTED status, the verdict is **REJECTED** — no exception.
27
+ - `dw-simplification`: use when the diff touches dense or twisty code — applies Chesterton's Fence (understand WHY before flagging removal), behavior-preserving refactor protocol (test gate before/after), and complexity metrics (cyclomatic, cognitive, depth, fan-out) so that "simplify this" findings are concrete, not vibes-based.
27
28
  - `security-review`: use when auth, authorization, external input, upload, SQL, external integration, secrets, SSRF, XSS, or sensitive surfaces are present
28
29
  - `vercel-react-best-practices`: use when the diff touches React/Next.js to review rendering, fetching, bundle, hydration, and performance patterns
29
30
 
@@ -165,6 +166,34 @@ For each impacted project, verify project-specific rules from `.dw/rules/`:
165
166
  - [ ] API calls use project fetch utilities
166
167
  - [ ] UI follows project design system
167
168
 
169
+ ### 4.1. Constitution Compliance (Required when `.dw/constitution.md` exists)
170
+
171
+ <critical>**Auto-create if missing**: if `.dw/constitution.md` does NOT exist, copy `templates/constitution-template.md` (project-local `.dw/templates/constitution-template.md` first, falling back to bundled scaffold) verbatim with frontmatter `mode: defaults`. Print in chat: "Installed defaults constitution at `.dw/constitution.md` (all principles at `severity: info` — reported but not blocking this review). Continuing." Then proceed.</critical>
172
+
173
+ For each principle in `.dw/constitution.md`, check the diff for violations:
174
+
175
+ 1. **Parse principles**: read each `**P-NNN — <name>** (severity: <S>)` entry; capture `P-NNN`, `severity`, and the `Enforcement` description.
176
+ 2. **Apply enforcement**: for each principle, run the enforcement check against the diff (grep, file inspection, or pattern match per the Enforcement line).
177
+ 3. **Classify violations**:
178
+ - Principle severity `info` → add row to "Issues Found" table with severity `low`. **Does not block** the verdict.
179
+ - Principle severity `high` → add row with severity `critical`. **Blocks** the verdict to `REJECTED` UNLESS an ADR in the same PRD's `adrs/` directory documents the deviation (look for `Deviates: P-NNN` in any ADR body).
180
+ - Principle severity `critical` → add row with severity `critical` AND require the ADR to have a non-empty `Approved by:` field. Missing field = still `REJECTED`.
181
+ 4. **No silent skips**: if the diff is too large to analyze every principle, report which were checked and which were skipped due to scope.
182
+
183
+ **Output format in the report:**
184
+
185
+ ```markdown
186
+ ## Constitution Compliance
187
+
188
+ | Principle | Severity | Status | Evidence | ADR escape |
189
+ |-----------|----------|--------|----------|------------|
190
+ | P-001 — No `any` casts | info | VIOLATED | src/foo.ts:42 | n/a |
191
+ | P-009 — Server-side auth | high | VIOLATED | src/api/order.ts:18 missing auth middleware | none → BLOCKS |
192
+ | P-010 — Secrets in repo | critical | PASS | — | — |
193
+ ```
194
+
195
+ If any `high`/`critical` violation has no ADR escape: append to the verdict line "REJECTED — constitution violation(s) without ADR (see Constitution Compliance section)".
196
+
168
197
  ### 5. Code Quality Analysis (Required)
169
198
 
170
199
  | Aspect | Verification |
@@ -9,6 +9,12 @@
9
9
  ## Pipeline Position
10
10
  **Predecessor:** `/dw-run-task` or `/dw-bugfix` | **Successor:** `/dw-generate-pr`
11
11
 
12
+ ## Complementary Skills
13
+
14
+ When available in the project under `./.agents/skills/`, use these skills as operational support without replacing this command:
15
+
16
+ - `dw-git-discipline`: **ALWAYS** — enforces atomic commits (one logical intent per commit; refactor separate from feature), Conventional Commits format, lint+tests+build green BEFORE the commit, and bans bypassing pre-commit hooks (`--no-verify`) or amending pushed commits. When mixed changes are detected, splits via `git add -p`.
17
+
12
18
  ## Input Variables
13
19
 
14
20
  | Variable | Description | Example |
@@ -50,6 +50,22 @@
50
50
  - Use `.dw/rules/` as context, falling back to grep
51
51
  - Suggest running `/dw-map-codebase` for richer downstream context
52
52
 
53
+ ## Constitution Gate
54
+
55
+ <critical>BEFORE the clarification questions, check `.dw/constitution.md`:
56
+
57
+ **If MISSING**: copy `templates/constitution-template.md` (project-local at `.dw/templates/constitution-template.md`, falling back to bundled scaffold) verbatim to `.dw/constitution.md`. Set frontmatter `mode: defaults` and `last_updated` to today's ISO date. Print in chat:
58
+
59
+ > "I noticed `.dw/constitution.md` was missing. Installed defaults at `.dw/constitution.md` (10 canonical principles, all `severity: info` — they report but don't block). You can customize anytime — or re-run `/dw-analyze-project` for a tailored version. Continuing with PRD."
60
+
61
+ Then proceed normally, treating the new file as the constitution.
62
+
63
+ **If PRESENT**: read it before drafting requirements. Each FR in the PRD MUST include a "Constitution Alignment" line mapping to ≥1 relevant principle (`Respects: P-001, P-009`) OR explicitly declaring "no applicable principle" with a one-line reason. Missing alignment = the FR is incomplete.
64
+
65
+ **Severity rules** (applied by downstream commands, not enforced here):
66
+ - `severity: info` violations → reported, never block.
67
+ - `severity: high` / `critical` violations → block in `dw-create-techspec` and `dw-code-review` unless an ADR justifies the deviation.</critical>
68
+
53
69
  ## Multi-Project Features
54
70
 
55
71
  Many features may involve more than one project in the workspace (e.g., a feature may impact both frontend and backend, or multiple services).
@@ -149,5 +149,47 @@
149
149
  3. Create PR when all tasks are completed
150
150
  ```
151
151
 
152
+ ## Final Consistency Check (Auto-invoked before user approval)
153
+
154
+ <critical>BEFORE presenting tasks to the user, run a 5-dimension consistency check. This is mandatory; do not skip even if you're confident the tasks are clean.</critical>
155
+
156
+ Run these 5 checks against the generated PRD + TechSpec + tasks set:
157
+
158
+ 1. **FR coverage** — every numbered FR in the PRD maps to ≥1 task. Orphan FRs (PRD has it; no task covers it) are a FAIL.
159
+ 2. **Task grounding** — every generated task body references ≥1 FR (`Covers: FR-N.M`). Tasks without FR reference signal scope creep.
160
+ 3. **Test coverage** — every FR with user-facing behavior (UI, API endpoint, data mutation) has ≥1 task that adds a test (subtask containing "test", "spec", "e2e", or equivalent).
161
+ 4. **Dependency graph** — task dependencies (X.0 → Y.0 declared as "Depends on") form a DAG. No cycles. Topological order valid.
162
+ 5. **Constitution alignment** (only if `.dw/constitution.md` exists) — every task lists `Constitution: respects P-NNN, P-MMM` OR `Constitution: deviates P-NNN — ADR planned: <slug>` OR `Constitution: n/a — reason: <one-liner>`. Missing line = FAIL.
163
+
164
+ Write findings to `.dw/spec/prd-[feature-name]/tasks-validation.md` with this exact structure:
165
+
166
+ ```markdown
167
+ # Tasks Validation Report
168
+
169
+ Generated by /dw-create-tasks on YYYY-MM-DD.
170
+
171
+ | Dimension | Status | Findings |
172
+ |-----------|--------|----------|
173
+ | 1. FR coverage | PASS / FAIL | <orphan FR list or "all FRs covered"> |
174
+ | 2. Task grounding | PASS / FAIL | <ungrounded task list or "all tasks reference FRs"> |
175
+ | 3. Test coverage | PASS / FAIL | <FRs missing tests or "all user-facing FRs covered"> |
176
+ | 4. Dependency graph | PASS / FAIL | <cycles or "DAG valid"> |
177
+ | 5. Constitution alignment | PASS / FAIL / N/A | <unaligned tasks or "all aligned" or "no constitution"> |
178
+
179
+ ## Detailed Findings
180
+
181
+ <one section per FAILing dimension with concrete fixes; empty if all PASS>
182
+ ```
183
+
184
+ **Gate behavior:**
185
+
186
+ - **All 5 dimensions PASS (or N/A)** → present tasks to the user normally and ask for approval.
187
+ - **Any dimension FAIL** → STOP. Show the table in chat as markdown (do NOT bury it in the validation file; the user must see it before approving). Then ask the user:
188
+ - "(a) Want me to fix tasks automatically?" → regenerate the affected tasks, re-run the check.
189
+ - "(b) Will you edit tasks.md manually?" → wait for the user to signal completion, re-run the check.
190
+ - "(c) Override and proceed despite FAIL?" → require an explicit override message ("override: I accept the gap because <reason>"). Persist the override in `tasks-validation.md` so it's auditable.
191
+
192
+ The `tasks-validation.md` file is committed alongside `tasks.md`. Downstream commands (`/dw-run-plan`, `/dw-code-review`, `/dw-review-implementation`) may reference it.
193
+
152
194
  After completing the analysis and generating all necessary files, present the results to the user and wait for confirmation to proceed with implementation.
153
195
  </system_instructions>