@brunosps00/dev-workflow 1.0.1 → 1.0.2

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 (32) hide show
  1. package/README.md +16 -9
  2. package/lib/constants.js +10 -6
  3. package/lib/init.js +28 -0
  4. package/package.json +1 -1
  5. package/scaffold/en/agent-instructions.md +21 -0
  6. package/scaffold/en/commands/dw-analyze-project.md +64 -0
  7. package/scaffold/en/commands/dw-autopilot.md +64 -5
  8. package/scaffold/en/commands/dw-bugfix.md +124 -26
  9. package/scaffold/en/commands/dw-intel.md +30 -3
  10. package/scaffold/en/commands/dw-pause.md +92 -0
  11. package/scaffold/en/commands/dw-qa.md +87 -11
  12. package/scaffold/en/commands/dw-resume.md +90 -0
  13. package/scaffold/en/commands/dw-review.md +22 -12
  14. package/scaffold/en/templates/bugfix-summary-template.md +66 -0
  15. package/scaffold/en/templates/concerns-template.md +59 -0
  16. package/scaffold/en/templates/state-template.md +59 -0
  17. package/scaffold/pt-br/agent-instructions.md +21 -0
  18. package/scaffold/pt-br/commands/dw-analyze-project.md +64 -0
  19. package/scaffold/pt-br/commands/dw-autopilot.md +64 -5
  20. package/scaffold/pt-br/commands/dw-bugfix.md +134 -18
  21. package/scaffold/pt-br/commands/dw-intel.md +30 -3
  22. package/scaffold/pt-br/commands/dw-pause.md +92 -0
  23. package/scaffold/pt-br/commands/dw-qa.md +87 -11
  24. package/scaffold/pt-br/commands/dw-resume.md +90 -0
  25. package/scaffold/pt-br/commands/dw-review.md +22 -12
  26. package/scaffold/pt-br/templates/bugfix-summary-template.md +66 -0
  27. package/scaffold/pt-br/templates/concerns-template.md +59 -0
  28. package/scaffold/pt-br/templates/state-template.md +59 -0
  29. package/scaffold/skills/dw-codebase-intel/SKILL.md +9 -5
  30. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +52 -0
  31. package/scaffold/skills/dw-memory/SKILL.md +26 -1
  32. package/scaffold/skills/dw-memory/references/context-budget.md +63 -0
package/README.md CHANGED
@@ -26,13 +26,13 @@ npx @brunosps00/dev-workflow install-deps
26
26
 
27
27
  ## Commands
28
28
 
29
- dev-workflow v1.0.0 ships **20 commands** organized into four tiers. Most users only invoke Tier 1 + Tier 2.
29
+ dev-workflow v1.0.2 ships **22 commands** organized into four tiers. Most users only invoke Tier 1 + Tier 2.
30
30
 
31
31
  ### Tier 1 — Gateway (3)
32
32
 
33
33
  | Command | When |
34
34
  |---------|------|
35
- | **`/dw-autopilot "wish"`** | Default entry point. Full pipeline (PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR) with 3 approval gates. |
35
+ | **`/dw-autopilot "wish"`** | Default entry point. Full pipeline (PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR) with 3 approval gates. Use `--from-prd <slug>` to resume from an existing PRD (e.g., after a `/dw-bugfix` safety-valve escalation): skips Steps 1–4 and starts at GATE 1. |
36
36
  | **`/dw-bugfix "description"`** | A bug report or pasted error. Triages bug-vs-feature-vs-scope, surgical fix or routes to a PRD. |
37
37
  | **`/dw-help [keyword]`** | Discover commands. Pass a keyword for shortcuts; `--advanced` reveals internal commands. |
38
38
 
@@ -45,8 +45,10 @@ Use these when you want step-by-step control instead of `/dw-autopilot`.
45
45
  | **`/dw-brainstorm "idea"`** | Refine an idea before PRD. Flags: `--onepager` (durable artifact), `--council` (multi-advisor debate), `--research` (multi-source cited research), `--refactor` (Fowler code-smell catalog). |
46
46
  | **`/dw-plan "feature"`** | PRD → TechSpec → Tasks sequentially with checkpoints. Stages: `prd`, `techspec`, `tasks`. Mandatory clarification questions, source-grounding, constitution gate, final consistency check. |
47
47
  | **`/dw-run [task-id]`** | Execute tasks. Default: all pending in dependency order with wave-based parallel dispatch. Single-task: pass an ID. `--resume` continues an interrupted plan. |
48
- | **`/dw-review`** | Level 2 (PRD coverage mapping) + Level 3 (code quality). Hard gates on dw-verify PASS, secure-audit, constitution violations. Flags: `--coverage-only`, `--code-only`. |
49
- | **`/dw-qa`** | Mode-aware QA. Auto-detects UI vs API. Flags: `--fix` (iterative QA + fix-retest loop), `--api`, `--ai` (run AI eval against reference dataset). |
48
+ | **`/dw-review`** | Level 2 (PRD coverage mapping) + Level 3 (code quality). Hard gates on dw-verify PASS, secure-audit, constitution violations. Flags: `--coverage-only`, `--code-only`, `--bugfix <slug>` (review a bugfix at `.dw/bugfixes/<slug>/`). |
49
+ | **`/dw-qa`** | Mode-aware QA. Auto-detects UI vs API. Flags: `--fix` (iterative QA + fix-retest loop), `--api`, `--ai` (AI eval against reference dataset), `--uat` (human-in-the-loop walkthrough), `--bugfix <slug>` (QA a bugfix). |
50
+ | **`/dw-pause`** | Consolidate the current session's mental state into `.dw/STATE.md` (Decisions, Blockers, Todos, Deferred, Lessons, Open Loops). Used before long breaks or context-window compactions. |
51
+ | **`/dw-resume`** | Read `.dw/STATE.md`, present a TLDR of where work left off, and suggest the next `dw-*` command. Never auto-executes. |
50
52
  | **`/dw-commit`** | Atomic Conventional Commits for pending changes. Applies `dw-git-discipline` (one intent per commit, lint+tests+build green before). |
51
53
  | **`/dw-generate-pr [target]`** | Push the branch, draft a PR body with summary + test plan, open the browser. Hard gates: dw-verify PASS + secure-audit. |
52
54
 
@@ -54,7 +56,7 @@ Use these when you want step-by-step control instead of `/dw-autopilot`.
54
56
 
55
57
  | Command | What |
56
58
  |---------|------|
57
- | **`/dw-analyze-project`** | Scans the repo, writes `.dw/rules/` (per-module conventions, anti-patterns, naming). Step 8 offers to generate `.dw/constitution.md` (declarative principles the team commits to). Run once per project; refresh after major refactors. |
59
+ | **`/dw-analyze-project`** | Scans the repo, writes `.dw/rules/` (per-module conventions, anti-patterns, naming). Step 8 offers to generate `.dw/constitution.md` (declarative principles the team commits to). Step 9 generates `.dw/rules/concerns.md` (risk map: hot spots, fragile integrations, hostile code, bug history). Run once per project; refresh after major refactors. |
58
60
  | **`/dw-redesign-ui "target"`** | Audits a frontend page, runs the `dw-ui-discipline` 4-question grounding, proposes 2-3 design directions, ships the redesign. WCAG 2.2 AA accessibility floor is non-negotiable. |
59
61
  | **`/dw-functional-doc`** | Maps screens + user flows into a functional doc, validated end-to-end with Playwright. |
60
62
  | **`/dw-new-project`** | Bootstrap a new project from empty directory. Stack interview, wraps official `create-*` tools, composes docker-compose for dev, seeds `.env`, scripts, CI, `.dw/rules/`. |
@@ -163,15 +165,18 @@ All wrappers point to `.dw/commands/` as the single source of truth.
163
165
  ```
164
166
  your-project/
165
167
  ├── .dw/
166
- │ ├── commands/ # 20 workflow command files (v1.0.0)
167
- │ ├── templates/ # Document templates (PRD, TechSpec, etc.)
168
+ │ ├── commands/ # 22 workflow command files (v1.0.2)
169
+ │ ├── templates/ # Document templates (PRD, TechSpec, state, concerns, bugfix-summary, etc.)
168
170
  │ │ └── overrides/ # Project-local template customizations (override > core)
169
171
  │ ├── rules/ # Project-specific rules (run /dw-analyze-project)
172
+ │ │ └── concerns.md # Risk map: hot spots, fragile integrations, bug history (Step 9 of /dw-analyze-project)
170
173
  │ ├── constitution.md # Declarative principles (auto-installed when missing)
171
174
  │ ├── references/ # Reference documentation
172
175
  │ ├── scripts/ # Utility scripts
173
- └── spec/ # PRD directories — each contains tasks-validation.md
174
- ├── CLAUDE.md # Auto-trigger decision tree for Claude Code (merge-aware)
176
+ ├── spec/ # PRD directories — each contains tasks-validation.md
177
+ ├── bugfixes/ # Persistent bugfix records: NNN-<slug>/{TASK.md, SUMMARY.md, fix-report.md} + review/, QA/
178
+ │ └── STATE.md # Session state: Decisions, Blockers, Todos, Open Loops, Deferred Ideas, Lessons, Preferences (managed by /dw-pause + /dw-resume)
179
+ ├── CLAUDE.md # Auto-trigger decision tree for Claude Code (merge-aware, includes Auto-Sizing Matrix)
175
180
  ├── AGENTS.md # Same content for Codex / Copilot / OpenCode
176
181
  ├── .claude/
177
182
  │ ├── skills/ # Claude Code wrappers
@@ -262,6 +267,8 @@ Incident response (`dw-incident-response`) adapted from [`wilsto/claude-code-sta
262
267
 
263
268
  LLM evaluation (`dw-llm-eval`) trajectory-match modes (strict / unordered / subset / superset) and tool-argument matching strategies adapted from [`langchain-ai/agentevals`](https://github.com/langchain-ai/agentevals) (MIT). The broader oracle-ladder framing, judge-calibration discipline, and reference-dataset principle are distilled from the open evaluations literature (OpenAI evals cookbook, Anthropic evals guidance, the academic eval-of-LLM body of work) and rewritten in our voice.
264
269
 
270
+ Session continuity and adaptive routing patterns 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) by Felipe Rodrigues (CC-BY-4.0, v1.0.2). Eight patterns were absorbed selectively after a comparative analysis confirmed that the majority of the skill duplicates existing dev-workflow capabilities (PRD/TechSpec/Tasks pipeline, constitution discipline, source-grounding, two-tier memory, verify-before-complete, brownfield mapping, sub-agent delegation, atomic commits). Patterns adopted: (1) `STATE.md` cross-session working memory at `.dw/STATE.md` + new `/dw-pause` and `/dw-resume` commands; (2) Auto-Sizing Matrix (Small/Medium/Large/Complex) formalized in `CLAUDE.md`/`AGENTS.md` above the Trigger Map; (3) Concerns Map (`.dw/rules/concerns.md`) generated by a new Step 9 in `/dw-analyze-project` and consumed on-demand by `/dw-plan`, `/dw-run`, and `/dw-bugfix`; (4) Context Budget discipline as a new section in `dw-memory` with reference `dw-memory/references/context-budget.md`; (5) Interactive UAT walkthrough as `/dw-qa --uat`; (6) Quick-mode persistence — bugfixes now land in `.dw/bugfixes/NNN-<slug>/{TASK.md, SUMMARY.md, fix-report.md}` and remain queryable via `/dw-intel`; (7) Safety valve in `/dw-bugfix` Step 5.0 that forces escalation to `/dw-plan` when scope exceeds 5 tasks or has cross-dependencies; (8) Cross-skill awareness — `/dw-intel --build` now indexes `.dw/bugfixes/*/SUMMARY.md` into `bugfixes.json`, and `dw-codebase-intel` documents the new `bugfix-history` and `risk-area` query shapes. Patterns explicitly REJECTED: `.specs/` directory structure (dev-workflow uses `.dw/`), Knowledge Verification Chain (already covered by `dw-source-grounding`), Specify/Design/Tasks/Execute naming (dev-workflow keeps PRD/TechSpec/Tasks/Run), Skill Integrations pattern with mermaid-studio/codenavi delegation, and literal text copying (everything is clean-room reimplementation from the conceptual patterns; CC-BY-4.0 attribution is for derivative ideas, not borrowed prose).
271
+
265
272
  Four patterns from [`mattpocock/skills`](https://github.com/mattpocock/skills) by Matt Pocock (MIT) were integrated **without adding new commands or skills** — instead they fold into the existing surface as internal modes and inline guidance: (1) **grill-with-docs** → `/dw-brainstorm` `grill` mode (interview discipline that stress-tests plan vocabulary against `.dw/rules/`); (2) **prototype** → `/dw-brainstorm` `prototype` mode (LOGIC terminal app or UI variant dispatch); (3) **improve-codebase-architecture** → `dw-simplification/references/deep-modules.md` (deletion test, locality, leverage, seam, adapter diagnostic invoked by the `refactor-audit` mode); (4) **zoom-out** → one-paragraph guidance in `agent-instructions.md`. The same release also collapses `/dw-brainstorm`'s six legacy flags into a single full-flow entry point that auto-dispatches modes based on project signals.
266
273
 
267
274
  ## Migration from v0.x (1.0.0 is a consolidation release)
package/lib/constants.js CHANGED
@@ -2,7 +2,7 @@ const COMMANDS = {
2
2
  en: [
3
3
  { name: 'dw-adr', description: 'Records an architectural decision and the trade-offs accepted, before they get lost.' },
4
4
  { name: 'dw-analyze-project', description: 'Scans the repo to learn its stack and conventions, then writes the rules other commands rely on.' },
5
- { name: 'dw-autopilot', description: 'Trigger when user asks to implement, build, create, or add a feature non-trivially. Runs full PRD-to-PR pipeline with three gates.' },
5
+ { name: 'dw-autopilot', description: 'Trigger when user asks to implement, build, create, or add a feature non-trivially. Runs full PRD-to-PR pipeline with three gates. Use --from-prd <slug> to resume from an existing PRD (e.g., after a /dw-bugfix safety-valve escalation), skipping Steps 1-4 and starting at GATE 1.' },
6
6
  { name: 'dw-brainstorm', description: 'Refine an idea against the product\'s existing features. Modes: default ideation, --research (multi-source cited research), --refactor (Fowler code-smell catalog), --onepager, --council.' },
7
7
  { name: 'dw-bugfix', description: 'Trigger when user reports a bug, pastes an error, or describes broken behavior. Triages with three questions, then fixes or routes to PRD.' },
8
8
  { name: 'dw-commit', description: 'Trigger when implementation is complete and pending changes need to be committed. Atomic commits with Conventional Commits messages.' },
@@ -13,10 +13,12 @@ const COMMANDS = {
13
13
  { name: 'dw-help', description: 'Lists primary commands and the flows that connect them. Pass --advanced to see internal/hidden commands.' },
14
14
  { name: 'dw-intel', description: 'Codebase intelligence: query mode (default) answers questions citing .dw/intel/ + .dw/rules/; --build mode (re)builds the index.' },
15
15
  { 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.' },
16
+ { name: 'dw-pause', description: 'Trigger when user says "pause work", "end session", or "save where we are". Consolidates open loops, decisions, blockers, and todos into .dw/STATE.md so the next session can resume.' },
16
17
  { name: 'dw-plan', description: 'Trigger when user has a feature idea and needs spec + architecture + tasks. Runs PRD → TechSpec → Tasks sequentially. Stages: prd / techspec / tasks; --from techspec; --council.' },
17
- { name: 'dw-qa', description: 'Trigger when user wants to validate behavior beyond unit tests. Mode-aware (UI / API / --ai). --fix enters the iterative QA + fix-retest loop.' },
18
+ { name: 'dw-qa', description: 'Trigger when user wants to validate behavior beyond unit tests. Mode-aware (UI / API / --ai / --uat). --fix enters the iterative QA + fix-retest loop. --bugfix <slug> targets a .dw/bugfixes/ entry.' },
18
19
  { name: 'dw-redesign-ui', description: 'Audits a frontend page, proposes design directions you choose from, then ships the redesign.' },
19
- { name: 'dw-review', description: 'Trigger when user asks to review code, check quality, or verify PR readiness. Default runs L2 (PRD coverage) + L3 (code quality). Flags --coverage-only / --code-only.' },
20
+ { name: 'dw-resume', description: 'Trigger when user says "resume work", "where did we stop?", or starts a session in a project with an existing .dw/STATE.md. Reads STATE.md, presents a TLDR, and suggests the next dw-* command.' },
21
+ { name: 'dw-review', description: 'Trigger when user asks to review code, check quality, or verify PR readiness. Default runs L2 (PRD coverage) + L3 (code quality). Flags --coverage-only / --code-only / --bugfix <slug>.' },
20
22
  { name: 'dw-run', description: 'Trigger when user wants to execute tasks. Default runs all pending in dependency order; \'run <task-id>\' runs one; \'run --resume\' continues an interrupted plan.' },
21
23
  { name: 'dw-secure-audit', description: 'Unified security audit: OWASP + Trivy SCA/secret/IaC + lockfile + supply-chain compromise check. Hidden; auto-invoked by /dw-review and /dw-generate-pr.' },
22
24
  { name: 'dw-update', description: 'Updates dev-workflow to the latest npm release in-place, with a snapshot you can roll back to.' },
@@ -24,7 +26,7 @@ const COMMANDS = {
24
26
  'pt-br': [
25
27
  { name: 'dw-adr', description: 'Registra uma decisao arquitetural e os trade-offs aceitos, antes que se percam.' },
26
28
  { name: 'dw-analyze-project', description: 'Escaneia o repo para aprender stack e convencoes, e escreve as regras que os outros commands usam.' },
27
- { name: 'dw-autopilot', description: 'Trigger quando usuario pede pra implementar, criar ou adicionar uma feature nao-trivial. Roda pipeline completo PRD-ao-PR com tres gates.' },
29
+ { name: 'dw-autopilot', description: 'Trigger quando usuario pede pra implementar, criar ou adicionar uma feature nao-trivial. Roda pipeline completo PRD-ao-PR com tres gates. Use --from-prd <slug> para retomar de um PRD existente (ex: apos escalacao do safety valve do /dw-bugfix), pulando Etapas 1-4 e comecando no GATE 1.' },
28
30
  { name: 'dw-brainstorm', description: 'Refina uma ideia contra features existentes do produto. Modos: ideacao default, --research (research multi-fonte citada), --refactor (catalogo de code smells Fowler), --onepager, --council.' },
29
31
  { name: 'dw-bugfix', description: 'Trigger quando usuario reporta bug, cola erro ou descreve comportamento quebrado. Tria com tres perguntas, depois corrige ou roteia pra PRD.' },
30
32
  { name: 'dw-commit', description: 'Trigger quando implementacao esta completa e ha mudancas pendentes pra commit. Commits atomicos com mensagens Conventional Commits.' },
@@ -35,10 +37,12 @@ const COMMANDS = {
35
37
  { name: 'dw-help', description: 'Lista comandos primarios e fluxos que os conectam. Passe --advanced para ver comandos internos/escondidos.' },
36
38
  { name: 'dw-intel', description: 'Inteligencia do codebase: modo query (default) responde citando .dw/intel/ + .dw/rules/; modo --build (re)constroi indice.' },
37
39
  { 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.' },
40
+ { name: 'dw-pause', description: 'Trigger quando usuario diz "pausa o trabalho", "encerra a sessao" ou "salva onde paramos". Consolida pontas soltas, decisoes, bloqueios e todos em .dw/STATE.md para a proxima sessao retomar.' },
38
41
  { name: 'dw-plan', description: 'Trigger quando usuario tem ideia de feature e precisa spec + arquitetura + tasks. Roda PRD → TechSpec → Tasks sequencial. Stages: prd / techspec / tasks; --from techspec; --council.' },
39
- { name: 'dw-qa', description: 'Trigger quando usuario quer validar comportamento alem de unit tests. Mode-aware (UI / API / --ai). --fix entra no loop iterativo QA + fix-retest.' },
42
+ { name: 'dw-qa', description: 'Trigger quando usuario quer validar comportamento alem de unit tests. Mode-aware (UI / API / --ai / --uat). --fix entra no loop iterativo QA + fix-retest. --bugfix <slug> aponta para uma entrada em .dw/bugfixes/.' },
40
43
  { name: 'dw-redesign-ui', description: 'Audita uma pagina frontend, propoe direcoes de design que voce escolhe, e entrega o redesign.' },
41
- { name: 'dw-review', description: 'Trigger quando usuario pede pra revisar codigo, checar qualidade ou validar prontidao pra PR. Default roda L2 (cobertura PRD) + L3 (qualidade). Flags --coverage-only / --code-only.' },
44
+ { name: 'dw-resume', description: 'Trigger quando usuario diz "retoma", "onde paramos?" ou comeca sessao num projeto com .dw/STATE.md existente. Le STATE.md, apresenta TLDR e sugere proximo comando dw-*.' },
45
+ { name: 'dw-review', description: 'Trigger quando usuario pede pra revisar codigo, checar qualidade ou validar prontidao pra PR. Default roda L2 (cobertura PRD) + L3 (qualidade). Flags --coverage-only / --code-only / --bugfix <slug>.' },
42
46
  { name: 'dw-run', description: 'Trigger quando usuario quer executar tasks. Default roda todas pendentes em ordem de dependencia; \'run <task-id>\' roda uma; \'run --resume\' continua plan interrompido.' },
43
47
  { name: 'dw-secure-audit', description: 'Audit unificado de seguranca: OWASP + Trivy SCA/secret/IaC + lockfile + supply-chain compromise. Hidden; auto-invocado por /dw-review e /dw-generate-pr.' },
44
48
  { name: 'dw-update', description: 'Atualiza o dev-workflow para o release mais recente no npm, com snapshot para rollback.' },
package/lib/init.js CHANGED
@@ -132,6 +132,34 @@ async function run({ force = false, lang = null, mode = 'init' }) {
132
132
  ensureDir(path.join(projectRoot, '.dw', 'spec'));
133
133
  }
134
134
 
135
+ // 5.1. Seed .dw/STATE.md from template (init only; never overwritten on update)
136
+ if (!isUpdate) {
137
+ console.log(' Session state:');
138
+ const stateTemplatePath = path.join(langDir, 'templates', 'state-template.md');
139
+ const stateDestPath = path.join(projectRoot, '.dw', 'STATE.md');
140
+ if (require('fs').existsSync(stateTemplatePath)) {
141
+ const stateStatus = writeFile(
142
+ stateDestPath,
143
+ require('fs').readFileSync(stateTemplatePath, 'utf-8'),
144
+ false
145
+ );
146
+ log(stateStatus, stateDestPath);
147
+ if (stateStatus === 'created') totalCreated++;
148
+ else totalSkipped++;
149
+ }
150
+ console.log();
151
+ }
152
+
153
+ // 5.2. Create .dw/bugfixes/ with .gitkeep (init only; preserved on update)
154
+ if (!isUpdate) {
155
+ const bugfixesDir = path.join(projectRoot, '.dw', 'bugfixes');
156
+ ensureDir(bugfixesDir);
157
+ const gitkeepPath = path.join(bugfixesDir, '.gitkeep');
158
+ const gitkeepStatus = writeFile(gitkeepPath, '', false);
159
+ if (gitkeepStatus === 'created') totalCreated++;
160
+ else totalSkipped++;
161
+ }
162
+
135
163
  // 5.5. Copy bundled skills to .agents/skills/
136
164
  const skillsSrcDir = path.join(SCAFFOLD_DIR, 'skills');
137
165
  if (require('fs').existsSync(skillsSrcDir)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brunosps00/dev-workflow",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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"
@@ -5,11 +5,27 @@ This project uses [`@brunosps00/dev-workflow`](https://www.npmjs.com/package/@br
5
5
 
6
6
  **The whole point of this file:** when the user states an intent that matches the Trigger Map below, run the matching `dw-*` command **without asking permission first** — unless the change is genuinely trivial (see Escape Hatches).
7
7
 
8
+ ## Auto-Sizing Matrix
9
+
10
+ Before picking a command from the Trigger Map, gauge the change's actual scope. The same intent ("fix this", "add this") can mean very different amounts of work; the matrix names four sizes and routes each to a different entry point. **Pick the smallest one that fits — under-routing wastes ceremony, over-routing hides scope.**
11
+
12
+ | Size | What it looks like | Route to |
13
+ |------|---------------------|----------|
14
+ | **Small** | ≤3 files, no migration, no new endpoint, can be summarized in one sentence. Examples: typo, log message, single-line config, dependency bump, version pin. | Just do it inline. No `dw-*` command. |
15
+ | **Medium** | Clear feature or bug, <10 numbered tasks expected, single component or single service, no architectural decisions. Examples: add a form field with validation, fix a regression in a known module, wire a new API endpoint into an existing handler. | `/dw-bugfix` (for bugs) or `/dw-plan` (for features) — straight, not via `/dw-autopilot`. |
16
+ | **Large** | Multi-component feature, ≥10 tasks expected, touches multiple modules, has user-visible UX surface AND backend. Examples: add a new entity end-to-end (model + migration + API + UI), introduce a third-party integration, redesign a flow. | `/dw-autopilot "<wish>"` — full PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR pipeline with three gates. |
17
+ | **Complex** | New domain, ambiguous requirements, architectural decision required, regulatory or compliance surface, or scope that spans multiple PRDs. Examples: introduce event sourcing, rebuild auth, multi-tenancy, a new product line. | `/dw-brainstorm "<idea>"` first (auto-dispatches research/council modes), then `/dw-plan --council` so the techspec stage runs the multi-advisor debate. |
18
+
19
+ **Safety valve:** if you start in Small or Medium but the work reveals it's actually Large (the inline listing exceeds 5 steps, or `/dw-bugfix` triggers its `Step 5.0` valve), STOP and escalate. There is no flag to bypass. Escalation is the correct outcome.
20
+
21
+ **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). The four-size matrix is theirs; the mapping to `dw-*` commands is dev-workflow-specific.
22
+
8
23
  ## Trigger Map
9
24
 
10
25
  | User intent (literal or paraphrased) | Auto-trigger |
11
26
  |--------------------------------------|--------------|
12
27
  | "Implement X" / "Build Y" / "Add feature Z" / "I need ..." / "Create ..." | `/dw-autopilot "X"` |
28
+ | "Autopilot this PRD" / "Take this PRD to PR" / continue a bugfix escalation autonomously | `/dw-autopilot --from-prd <slug>` (existing PRD at `.dw/spec/<slug>/`) |
13
29
  | Pasted error / "X is broken" / "Bug in Y" / failing test screenshot | `/dw-bugfix "X"` |
14
30
  | "Plan this feature" / "Write a PRD + techspec + tasks" | `/dw-plan "X"` |
15
31
  | "Write a PRD for X" / "Spec out Y" | `/dw-plan prd "X"` |
@@ -18,9 +34,14 @@ This project uses [`@brunosps00/dev-workflow`](https://www.npmjs.com/package/@br
18
34
  | "Run this task" (with task ID) | `/dw-run <ID>` |
19
35
  | "Run all pending tasks" / "Execute the plan" | `/dw-run` |
20
36
  | "Continue where I left off" | `/dw-run --resume` |
37
+ | "Pause work" / "End the session" / "Save where we are" | `/dw-pause` |
38
+ | "Resume" / "Where did we stop?" / "Pick up where we left off" | `/dw-resume` |
21
39
  | "QA this feature" / "Run the test plan" | `/dw-qa` |
22
40
  | "Fix the QA bugs" | `/dw-qa --fix` |
23
41
  | "Evaluate the AI feature" / "Test the RAG / classifier" | `/dw-qa --ai` |
42
+ | "Walk me through this feature" / "UAT this with me" / "Let's do a manual run-through" | `/dw-qa --uat` |
43
+ | "Review this bugfix" / "Code-review fix `<slug>`" | `/dw-review --bugfix <slug>` |
44
+ | "QA this bugfix" / "Validate fix `<slug>`" | `/dw-qa --bugfix <slug>` |
24
45
  | "Review my PR" / "Check code quality" / "Is this ready to ship?" | `/dw-review` |
25
46
  | "Just the PRD coverage check" | `/dw-review --coverage-only` |
26
47
  | "Just the code quality review" | `/dw-review --code-only` |
@@ -766,6 +766,67 @@ Three options:
766
766
  - Never write `.dw/constitution.md` without explicit user approval (option A) or explicit choice (options B/C).
767
767
  - Constitution file is committed to the repository like any other project artifact — never gitignored.
768
768
 
769
+ ### Step 9: Concerns Map Generation (Risk Map)
770
+
771
+ After the constitution step, generate `.dw/rules/concerns.md` — the project's **risk map**. While `.dw/rules/` describes how the code IS and `.dw/constitution.md` describes what it SHOULD BE, the concerns map answers a third question: **where is it dangerous to mess around?**
772
+
773
+ **Difference from the other two:**
774
+ - `.dw/rules/*.md` — analytical (observed patterns).
775
+ - `.dw/constitution.md` — declarative (committed principles).
776
+ - `.dw/rules/concerns.md` — operational risk (load-bearing fragility, hot spots, hostile code).
777
+
778
+ **Behavior:**
779
+
780
+ If `.dw/rules/concerns.md` already exists with hand-edited entries between `<!-- preserved:start -->` and `<!-- preserved:end -->` markers, preserve those entries. Refresh the auto-generated sections (Hot Spots churn data, Known Bug History from `.dw/bugfixes/`).
781
+
782
+ Otherwise (first run), build the file from scratch using `.dw/templates/concerns-template.md` as the base.
783
+
784
+ **Data to collect:**
785
+
786
+ 1. **Hot Spots — churn analysis.** For each module discovered in Step 5, compute the count of commits touching files in that module over the last 90 days (`git log --since="90 days ago" --name-only -- <module-path> | wc -l`). Modules in the top 20% by churn are candidates. Cross-reference with `.dw/bugfixes/` (next item) — modules that also appear there are confirmed Hot Spots; the rest are flagged "high churn — verify with team."
787
+
788
+ 2. **Known Bug History — bugfix aggregation.** If `.dw/bugfixes/` exists, scan every `SUMMARY.md` in it. For each, parse the `Files Touched` table; aggregate file paths by their top-level module (e.g. `src/auth/session.ts` -> `src/auth/`). Any module with `>= 2` historical fixes lands in the Known Bug History section with the count and the recent bugfix slugs.
789
+
790
+ 3. **Fragile Integrations.** Look for telltale patterns in code and config:
791
+ - External SDK clients with retry/backoff scaffolding (suggests prior failures).
792
+ - Comments like `// FIXME: vendor returns 200 with empty body sometimes`, `// HACK: legacy API workaround`, `// TODO: handle vendor X edge case`.
793
+ - Hand-rolled retry loops around fetch/axios/HTTP clients.
794
+ - `.dw/incidents/` directory — every incident postmortem that names an external system goes in here.
795
+ List these candidates. Don't fabricate — only what you observe.
796
+
797
+ 4. **Hostile Code.** Heuristics for code that needs full understanding before modification:
798
+ - Regex literals longer than 80 characters with no explanatory comment.
799
+ - Functions over 100 lines with cyclomatic complexity that resists quick reading (rough heuristic: lots of nested `if`/`switch`/loops).
800
+ - Manual transaction/locking code outside an ORM's idiomatic layer.
801
+ - Custom serializers/parsers (e.g. hand-written JSON, CSV, binary formats) without a corresponding test file.
802
+ Flag candidates and let the user confirm.
803
+
804
+ 5. **Tech Debt — Acknowledged.** Scan README, CONTRIBUTING, docs/, and code comments for `TODO`, `FIXME`, `XXX`, `HACK`, `DEPRECATED` markers older than 90 days (use `git blame` to date them). Cluster by area. Present as candidates; the user decides which deserve acknowledgement (some are stale comments, some are real debt).
805
+
806
+ **Procedure:**
807
+
808
+ 1. **Show candidates in chat first** (do NOT write the file yet). Format as a markdown table per section with a count and the strongest evidence for each entry. Cap each section at 10 entries — if more, list "+N more (see full analysis)" and let the user request expansion.
809
+
810
+ 2. Ask: "Approve as-is, drop specific entries (give the row labels), or skip this step entirely?" Wait for explicit response.
811
+
812
+ 3. On approval, write `.dw/rules/concerns.md` using `.dw/templates/concerns-template.md`. Fill in:
813
+ - Frontmatter `last_refreshed: <today's ISO date>`.
814
+ - Hot Spots table.
815
+ - Fragile Integrations table.
816
+ - Hostile Code table.
817
+ - Known Bug History table.
818
+ - Tech Debt — Acknowledged table.
819
+
820
+ 4. If a `<!-- preserved:start --> ... <!-- preserved:end -->` block existed in a prior version, append it back at the end of the file (the team's hand-curated entries).
821
+
822
+ 5. Print: "Wrote `.dw/rules/concerns.md`. Loaded on-demand by `/dw-plan`, `/dw-run`, and `/dw-bugfix` when their target touches a listed area. Never blocks — it informs, surfaces, and suggests an ADR for deviations."
823
+
824
+ **Special case — no signals found:**
825
+
826
+ If after the heuristics nothing crosses the bar (small codebase, low churn, no incidents, no bugfix history), write a minimal `concerns.md` with all sections empty (just headers) and a note: "No risk signals at this time. Re-run after the project accumulates more history."
827
+
828
+ **Refresh cadence:** users re-run `/dw-analyze-project` whenever rules drift. Step 9 refreshes auto sections while keeping preserved entries. There is no separate refresh-only command.
829
+
769
830
  ## Quality Checklist
770
831
 
771
832
  Before declaring the analysis complete, verify:
@@ -787,6 +848,9 @@ Before declaring the analysis complete, verify:
787
848
  - [ ] Generated one `.dw/rules/{project}.md` per leaf project discovered
788
849
  - [ ] Generated `.dw/rules/integrations.md` (if 2+ projects)
789
850
  - [ ] All file paths in rules reference real, existing files
851
+ - [ ] Step 8 (constitution) offered and resolved (A/B/C)
852
+ - [ ] Step 9 (concerns map) presented candidates, awaited approval, wrote `.dw/rules/concerns.md` (or noted no signals)
853
+ - [ ] Preserved-marker blocks in concerns.md kept verbatim on refresh
790
854
  - [ ] Topology analysis completed (god nodes, coupling metrics, dependency graph)
791
855
  - [ ] Critical nodes table generated with Ca, Ce, instability
792
856
  - [ ] Circular dependencies identified and documented
@@ -44,13 +44,22 @@ A step that invokes a `/dw-xxx` command is ONLY considered complete when the art
44
44
 
45
45
  | Variable | Description | Example |
46
46
  |----------|-------------|---------|
47
- | `{{WISH}}` | Description of what the user wants to build | "push notification system with per-channel preferences" |
47
+ | `{{WISH}}` | Description of what the user wants to build (default mode) | "push notification system with per-channel preferences" |
48
+ | `{{PRD_SLUG}}` | Existing PRD slug to autopilot from (when `--from-prd` is used) | `prd-bugfix-stripe-webhook-retry` |
49
+ | `{{MODE}}` | Optional invocation flag | `--from-prd <slug>` |
50
+
51
+ ## Invocation Modes
52
+
53
+ | Invocation | Behavior |
54
+ |------------|----------|
55
+ | `/dw-autopilot "<wish>"` | **Default.** Full pipeline from scratch: Codebase Intelligence → Research → Brainstorm → PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR. |
56
+ | `/dw-autopilot --from-prd <slug>` | **Resume-from-PRD mode.** Skips Steps 1–4 (Intel, Research, Brainstorm, PRD). Starts at GATE 1 (presents the existing PRD for approval), then continues through TechSpec → Tasks → Run → QA → Review → Commit → PR. Used when `/dw-bugfix` has escalated via its safety valve and written a PRD to `.dw/spec/<slug>/`, or when the user previously authored a PRD by hand and wants the rest automated. |
48
57
 
49
58
  ## Approval Gates
50
59
 
51
60
  The autopilot stops ONLY at these 3 moments:
52
61
 
53
- 1. **GATE 1 — PRD**: Presents the generated PRD and awaits user approval before generating techspec/tasks
62
+ 1. **GATE 1 — PRD**: Presents the generated PRD (default mode) or the existing PRD (--from-prd mode) and awaits user approval before generating techspec/tasks
54
63
  2. **GATE 2 — Tasks**: Presents the task list and awaits approval before starting execution
55
64
  3. **GATE 3 — PR**: After automatic commit, asks if the user wants to generate the Pull Request
56
65
 
@@ -66,6 +75,22 @@ If this command is re-invoked on the same PRD after interruption:
66
75
 
67
76
  ## Full Pipeline
68
77
 
78
+ ### Step 0: Resolve invocation mode (MANDATORY first action)
79
+
80
+ Before Step 1, decide which mode is in effect:
81
+
82
+ 1. **If `--from-prd <slug>` is present in the invocation:**
83
+ - Resolve `{{PRD_SLUG}}` to `.dw/spec/<slug>/`.
84
+ - Verify the directory exists and contains a `prd.md`. If either is missing, STOP and report: `--from-prd target .dw/spec/<slug>/prd.md not found. Run /dw-plan prd or fix the slug.`
85
+ - Check whether `.dw/bugfixes/*/escalated.md` references this slug. If yes, note in the progress block: `Resuming from bugfix escalation: <NNN-bugfix-slug> → <slug>`.
86
+ - Set `mode: "from-prd"` in `autopilot-state.json` and `skipped_steps: [1, 2, 3, 4]` with `skip_reason: "from-prd-mode"`.
87
+ - Jump directly to **GATE 1** (PRD approval) using the existing `prd.md`.
88
+
89
+ 2. **Otherwise (default mode):**
90
+ - Set `mode: "autopilot"` and proceed to Step 1 normally.
91
+
92
+ <critical>In `--from-prd` mode, Steps 1–4 MUST be marked as `skipped_steps` with `skip_reason: "from-prd-mode"`. The pre-commit audit (Step 14) MUST honor this — a skipped step is not the same as a missing step.</critical>
93
+
69
94
  ### Step 1: Codebase Intelligence
70
95
 
71
96
  <critical>If `.dw/intel/` exists, querying it via `/dw-intel` is MANDATORY before starting. Falls back to `.dw/rules/` and direct grep if absent.</critical>
@@ -104,12 +129,15 @@ Run `/dw-plan prd` using brainstorm findings.
104
129
 
105
130
  ### === GATE 1: PRD Approval ===
106
131
 
132
+ **In default mode:** the PRD was just written in Step 4.
133
+ **In `--from-prd` mode:** the PRD already existed on disk before this autopilot run started (typically authored by `/dw-bugfix --analysis` or by a safety-valve escalation, or hand-edited).
134
+
107
135
  Present to the user:
108
136
  - Summary of functional requirements
109
- - Decisions made automatically
137
+ - Decisions made automatically (default mode) OR origin note: "PRD authored by /dw-bugfix escalation on <date>" / "PRD pre-existing on disk" (--from-prd mode)
110
138
  - Open questions (if any)
111
139
 
112
- **Wait for explicit approval.** If the user requests changes, adjust and re-present.
140
+ **Wait for explicit approval.** If the user requests changes, adjust and re-present. In `--from-prd` mode, edits go directly into the existing `.dw/spec/<slug>/prd.md` — there is no separate draft.
113
141
 
114
142
  ### Step 5: TechSpec (Interactive — 7+ Questions)
115
143
 
@@ -216,6 +244,34 @@ Run `/dw-review --coverage-only` again to confirm QA fixes did not break PRD com
216
244
  Run `/dw-review --code-only` (Level 3) for formal review.
217
245
  - Generate persisted report
218
246
 
247
+ ### Step 13.5: Close the bugfix loop (Conditional)
248
+
249
+ <critical>This step runs only when `mode == "from-prd"` AND the `prd_path` matches `.dw/spec/prd-bugfix-*`. Otherwise skip with `skip_reason: "not a bugfix escalation"`.</critical>
250
+
251
+ When the autopilot is finishing a bugfix that was escalated by `/dw-bugfix`, the index entry in `.dw/bugfixes/NNN-<slug>/` still has only `TASK.md` and `escalated.md` — no `SUMMARY.md` was written because the surgical bugfix flow never reached step 5.5 (the spec-driven flow did the work instead). Without `SUMMARY.md`, `/dw-intel --build` skips this bugfix forever, so `bugfix-history` queries never surface the lesson learned.
252
+
253
+ This step closes that loop **before** Step 14 (Commit) so the SUMMARY lands in the same commit as the fix.
254
+
255
+ **Procedure:**
256
+
257
+ 1. **Find the index entry.** Glob `.dw/bugfixes/*/escalated.md`. For each, read the one-line content and check whether it references the current PRD slug (e.g., `→ see .dw/spec/prd-bugfix-stripe-webhook-retry/` matches the active PRD `prd-bugfix-stripe-webhook-retry`). The match is the target `NNN-<slug>/` directory.
258
+ 2. **If no match is found:** the bugfix index doesn't expect a back-write. Skip silently and continue to Step 14.
259
+ 3. **If `SUMMARY.md` already exists in the matched directory:** do not overwrite. Continue to Step 14 — the human or a previous run already closed the loop.
260
+ 4. **Otherwise, write `SUMMARY.md`** using `.dw/templates/bugfix-summary-template.md`. Source fields from:
261
+ - **Symptom (verbatim):** the `Symptom` section of `<prd_path>/prd.md`, or the first paragraph of the original `TASK.md` if the PRD doesn't carry it.
262
+ - **Root Cause:** the original `TASK.md` Root Cause section.
263
+ - **Resolution (2–4 bullets):** distilled from `<prd_path>/techspec.md` decisions + actual `git diff <base>...HEAD --stat` summary.
264
+ - **Files Touched:** parsed from `git diff <base>...HEAD --name-only` (exclude `.dw/` paths). If >5 files, that's expected for an escalated bugfix — list them all and add a note "escalated from bugfix because of scope".
265
+ - **Verification:** point to `<prd_path>/QA/qa-report.md` and the verify report referenced in Step 9's session output.
266
+ - **Related — Concerns touched:** copy from the corresponding entries in `.dw/rules/concerns.md` if any rows reference modules in `Files Touched`.
267
+ - **Frontmatter:** `slug: NNN-<slug>`, `created: <today's ISO date>`, `status: Fixed`, `severity: <inferred from PRD priority or default Medium>`, `related_concerns: [list from above]`.
268
+ 5. **Append a final-line note** to `escalated.md`: `Closed by /dw-autopilot --from-prd on <YYYY-MM-DD>; SUMMARY.md written.` Preserve the original escalation line above it.
269
+ 6. **Record the artifact** in `autopilot-state.json` `step_artifacts["13.5"] = [".dw/bugfixes/NNN-<slug>/SUMMARY.md", ".dw/bugfixes/NNN-<slug>/escalated.md"]`.
270
+
271
+ <critical>NEVER fabricate verification evidence. If the QA report is empty or the diff is empty, do not invent files in `Files Touched`. Write the SUMMARY.md sections that are grounded and mark the rest as `_(not available — see <prd_path>/QA/ for details)_`.</critical>
272
+
273
+ After this step, the bugfix becomes visible to `/dw-intel "bugfix history in <module>"` on the next `/dw-intel --build` run.
274
+
219
275
  ### Step 14: Commit
220
276
 
221
277
  <critical>MANDATORY PRE-COMMIT AUDIT — execute BEFORE invoking `/dw-commit`:
@@ -230,7 +286,7 @@ Run `ls` on each path below and confirm existence. If ANY is missing, DO NOT com
230
286
  - Evidence of the last `/dw-review --coverage-only` run with RF-by-RF matrix (session output or reference in `autopilot-state.json`)
231
287
 
232
288
  Also verify `autopilot-state.json`:
233
- - Every step 1 through 13 that is NOT in `skipped_steps` must be in `completed_steps`
289
+ - Every step 1 through 13 (and 13.5 when in `--from-prd` mode against a `prd-bugfix-*` PRD) that is NOT in `skipped_steps` must be in `completed_steps`
234
290
  - Each completed step must have its artifacts listed in `step_artifacts`
235
291
 
236
292
  If any artifact or step is missing: STOP immediately. Report to the user: `Step N did not produce artifact X — re-running /dw-[command]`. Re-execute the command. Verify again. Only then proceed to `/dw-commit`.
@@ -263,9 +319,11 @@ Save the file `.dw/spec/prd-[name]/autopilot-state.json` with the following form
263
319
  "mode": "autopilot",
264
320
  "wish": "original user description",
265
321
  "prd_path": ".dw/spec/prd-[name]",
322
+ "from_prd_slug": null,
266
323
  "current_step": 8,
267
324
  "completed_steps": [1, 2, 3, 4, 5, 6, 7],
268
325
  "skipped_steps": [2],
326
+ "skip_reasons": {"2": "domain already mapped in .dw/rules/auth.md"},
269
327
  "gates_passed": ["prd", "tasks"],
270
328
  "step_artifacts": {
271
329
  "9": ["review-matrix-shown-in-session"],
@@ -288,6 +346,7 @@ Save the file `.dw/spec/prd-[name]/autopilot-state.json` with the following form
288
346
  - A step ONLY moves to `completed_steps` after verifying its artifacts exist on disk
289
347
  - 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
348
  - When the pipeline finishes (after commit or PR), remove the file or mark `"status": "completed"`
349
+ - In `--from-prd` mode, set `from_prd_slug: "<slug>"`, `mode: "from-prd"`, and include steps 1–4 in `skipped_steps` with `skip_reason: "from-prd-mode"` — this is what the pre-commit audit checks against (Step 14 verifies that every step NOT in `skipped_steps` is in `completed_steps`)
291
350
 
292
351
  <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>
293
352