@brunosps00/dev-workflow 0.13.0 → 1.0.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.
- package/README.md +106 -122
- package/lib/constants.js +16 -36
- package/lib/migrate-skills.js +11 -4
- package/lib/removed-commands.js +30 -0
- package/package.json +1 -1
- package/scaffold/en/agent-instructions.md +27 -16
- package/scaffold/en/commands/dw-adr.md +2 -2
- package/scaffold/en/commands/dw-analyze-project.md +7 -7
- package/scaffold/en/commands/dw-autopilot.md +20 -20
- package/scaffold/en/commands/dw-brainstorm.md +160 -9
- package/scaffold/en/commands/dw-bugfix.md +7 -6
- package/scaffold/en/commands/dw-commit.md +1 -1
- package/scaffold/en/commands/dw-dockerize.md +9 -9
- package/scaffold/en/commands/dw-find-skills.md +4 -4
- package/scaffold/en/commands/dw-functional-doc.md +2 -2
- package/scaffold/en/commands/dw-generate-pr.md +4 -4
- package/scaffold/en/commands/dw-help.md +95 -351
- package/scaffold/en/commands/dw-intel.md +76 -12
- package/scaffold/en/commands/dw-new-project.md +9 -9
- package/scaffold/en/commands/dw-plan.md +175 -0
- package/scaffold/en/commands/dw-qa.md +166 -0
- package/scaffold/en/commands/dw-redesign-ui.md +7 -7
- package/scaffold/en/commands/dw-review.md +198 -0
- package/scaffold/en/commands/dw-run.md +176 -0
- package/scaffold/en/commands/dw-secure-audit.md +222 -0
- package/scaffold/en/commands/dw-update.md +1 -1
- package/scaffold/en/references/playwright-patterns.md +1 -1
- package/scaffold/en/references/refactoring-catalog.md +1 -1
- package/scaffold/en/templates/brainstorm-matrix.md +1 -1
- package/scaffold/en/templates/idea-onepager.md +3 -3
- package/scaffold/en/templates/project-onepager.md +5 -5
- package/scaffold/pt-br/agent-instructions.md +27 -16
- package/scaffold/pt-br/commands/dw-adr.md +2 -2
- package/scaffold/pt-br/commands/dw-analyze-project.md +7 -7
- package/scaffold/pt-br/commands/dw-autopilot.md +20 -20
- package/scaffold/pt-br/commands/dw-brainstorm.md +160 -9
- package/scaffold/pt-br/commands/dw-bugfix.md +10 -9
- package/scaffold/pt-br/commands/dw-commit.md +1 -1
- package/scaffold/pt-br/commands/dw-dockerize.md +9 -9
- package/scaffold/pt-br/commands/dw-find-skills.md +4 -4
- package/scaffold/pt-br/commands/dw-functional-doc.md +2 -2
- package/scaffold/pt-br/commands/dw-generate-pr.md +4 -4
- package/scaffold/pt-br/commands/dw-help.md +97 -300
- package/scaffold/pt-br/commands/dw-intel.md +77 -13
- package/scaffold/pt-br/commands/dw-new-project.md +9 -9
- package/scaffold/pt-br/commands/dw-plan.md +175 -0
- package/scaffold/pt-br/commands/dw-qa.md +166 -0
- package/scaffold/pt-br/commands/dw-redesign-ui.md +7 -7
- package/scaffold/pt-br/commands/dw-review.md +198 -0
- package/scaffold/pt-br/commands/dw-run.md +176 -0
- package/scaffold/pt-br/commands/dw-secure-audit.md +222 -0
- package/scaffold/pt-br/commands/dw-update.md +1 -1
- package/scaffold/pt-br/references/playwright-patterns.md +1 -1
- package/scaffold/pt-br/references/refactoring-catalog.md +1 -1
- package/scaffold/pt-br/templates/brainstorm-matrix.md +1 -1
- package/scaffold/pt-br/templates/idea-onepager.md +3 -3
- package/scaffold/pt-br/templates/project-onepager.md +5 -5
- package/scaffold/pt-br/templates/tasks-template.md +1 -1
- package/scaffold/skills/api-testing-recipes/SKILL.md +6 -6
- package/scaffold/skills/api-testing-recipes/references/auth-patterns.md +1 -1
- package/scaffold/skills/api-testing-recipes/references/matrix-conventions.md +1 -1
- package/scaffold/skills/api-testing-recipes/references/openapi-driven.md +3 -3
- package/scaffold/skills/docker-compose-recipes/SKILL.md +1 -1
- package/scaffold/skills/dw-codebase-intel/SKILL.md +9 -9
- package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +4 -4
- package/scaffold/skills/dw-codebase-intel/references/api-design-discipline.md +1 -1
- package/scaffold/skills/dw-codebase-intel/references/incremental-update.md +5 -5
- package/scaffold/skills/dw-codebase-intel/references/intel-format.md +1 -1
- package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +3 -3
- package/scaffold/skills/dw-council/SKILL.md +2 -2
- package/scaffold/skills/dw-debug-protocol/SKILL.md +5 -3
- package/scaffold/skills/dw-execute-phase/SKILL.md +16 -16
- package/scaffold/skills/dw-execute-phase/agents/executor.md +5 -5
- package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +4 -4
- package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +1 -1
- package/scaffold/skills/dw-execute-phase/references/plan-verification.md +2 -2
- package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +1 -1
- package/scaffold/skills/dw-git-discipline/SKILL.md +5 -2
- package/scaffold/skills/dw-incident-response/SKILL.md +168 -0
- package/scaffold/skills/dw-incident-response/references/blameless-discipline.md +126 -0
- package/scaffold/skills/dw-incident-response/references/communication-templates.md +107 -0
- package/scaffold/skills/dw-incident-response/references/postmortem-template.md +133 -0
- package/scaffold/skills/dw-incident-response/references/runbook-templates.md +169 -0
- package/scaffold/skills/dw-incident-response/references/severity-and-triage.md +186 -0
- package/scaffold/skills/dw-llm-eval/SKILL.md +150 -0
- package/scaffold/skills/dw-llm-eval/references/agent-eval.md +252 -0
- package/scaffold/skills/dw-llm-eval/references/judge-calibration.md +169 -0
- package/scaffold/skills/dw-llm-eval/references/oracle-ladder.md +171 -0
- package/scaffold/skills/dw-llm-eval/references/rag-metrics.md +186 -0
- package/scaffold/skills/dw-llm-eval/references/reference-dataset.md +190 -0
- package/scaffold/skills/dw-memory/SKILL.md +2 -2
- package/scaffold/skills/dw-review-rigor/SKILL.md +5 -5
- package/scaffold/skills/dw-simplification/SKILL.md +4 -4
- package/scaffold/skills/dw-source-grounding/SKILL.md +1 -1
- package/scaffold/skills/dw-testing-discipline/SKILL.md +103 -78
- package/scaffold/skills/dw-testing-discipline/references/agent-guardrails.md +170 -0
- package/scaffold/skills/dw-testing-discipline/references/anti-patterns.md +7 -7
- package/scaffold/skills/dw-testing-discipline/references/core-rules.md +128 -0
- package/scaffold/skills/dw-testing-discipline/references/flaky-discipline.md +3 -3
- package/scaffold/skills/dw-testing-discipline/references/{positive-patterns.md → patterns.md} +1 -1
- package/scaffold/skills/dw-testing-discipline/references/playwright-recipes.md +3 -3
- package/scaffold/skills/dw-ui-discipline/SKILL.md +103 -79
- package/scaffold/skills/dw-ui-discipline/references/accessibility-floor.md +2 -2
- package/scaffold/skills/dw-ui-discipline/references/hard-gate.md +93 -73
- package/scaffold/skills/dw-ui-discipline/references/state-matrix.md +1 -1
- package/scaffold/skills/dw-ui-discipline/references/visual-slop.md +152 -0
- package/scaffold/skills/dw-verify/SKILL.md +4 -4
- package/scaffold/skills/humanizer/SKILL.md +1 -7
- package/scaffold/skills/remotion-best-practices/SKILL.md +3 -1
- package/scaffold/skills/security-review/SKILL.md +1 -1
- package/scaffold/skills/security-review/languages/csharp.md +1 -1
- package/scaffold/skills/security-review/languages/rust.md +1 -1
- package/scaffold/skills/security-review/languages/typescript.md +1 -1
- package/scaffold/skills/vercel-react-best-practices/SKILL.md +3 -1
- package/scaffold/templates-overrides-readme.md +3 -3
- package/scaffold/en/commands/dw-code-review.md +0 -385
- package/scaffold/en/commands/dw-create-prd.md +0 -148
- package/scaffold/en/commands/dw-create-tasks.md +0 -195
- package/scaffold/en/commands/dw-create-techspec.md +0 -210
- package/scaffold/en/commands/dw-deep-research.md +0 -418
- package/scaffold/en/commands/dw-deps-audit.md +0 -327
- package/scaffold/en/commands/dw-fix-qa.md +0 -152
- package/scaffold/en/commands/dw-map-codebase.md +0 -125
- package/scaffold/en/commands/dw-refactoring-analysis.md +0 -340
- package/scaffold/en/commands/dw-revert-task.md +0 -114
- package/scaffold/en/commands/dw-review-implementation.md +0 -349
- package/scaffold/en/commands/dw-run-plan.md +0 -300
- package/scaffold/en/commands/dw-run-qa.md +0 -496
- package/scaffold/en/commands/dw-run-task.md +0 -209
- package/scaffold/en/commands/dw-security-check.md +0 -271
- package/scaffold/pt-br/commands/dw-code-review.md +0 -365
- package/scaffold/pt-br/commands/dw-create-prd.md +0 -148
- package/scaffold/pt-br/commands/dw-create-tasks.md +0 -195
- package/scaffold/pt-br/commands/dw-create-techspec.md +0 -208
- package/scaffold/pt-br/commands/dw-deep-research.md +0 -172
- package/scaffold/pt-br/commands/dw-deps-audit.md +0 -327
- package/scaffold/pt-br/commands/dw-fix-qa.md +0 -152
- package/scaffold/pt-br/commands/dw-map-codebase.md +0 -125
- package/scaffold/pt-br/commands/dw-refactoring-analysis.md +0 -340
- package/scaffold/pt-br/commands/dw-revert-task.md +0 -114
- package/scaffold/pt-br/commands/dw-review-implementation.md +0 -337
- package/scaffold/pt-br/commands/dw-run-plan.md +0 -296
- package/scaffold/pt-br/commands/dw-run-qa.md +0 -494
- package/scaffold/pt-br/commands/dw-run-task.md +0 -208
- package/scaffold/pt-br/commands/dw-security-check.md +0 -271
- package/scaffold/skills/dw-testing-discipline/references/ai-agent-gates.md +0 -170
- package/scaffold/skills/dw-testing-discipline/references/iron-laws.md +0 -128
- package/scaffold/skills/dw-ui-discipline/references/anti-slop.md +0 -162
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
<system_instructions>
|
|
2
|
-
Você é um assistente IA responsável por implementar tasks de desenvolvimento de software. Sua tarefa é identificar a próxima tarefa disponível, realizar a configuração necessária, implementar e validar antes de commitar.
|
|
3
|
-
|
|
4
|
-
<critical>Você não deve se apressar para finalizar a tarefa. Sempre verifique os arquivos necessários, verifique os testes, faça um processo de reasoning para garantir tanto a compreensão quanto a execução correta.</critical>
|
|
5
|
-
<critical>A TAREFA NÃO PODE SER CONSIDERADA COMPLETA ENQUANTO TODOS OS TESTES NÃO ESTIVEREM PASSANDO</critical>
|
|
6
|
-
|
|
7
|
-
## Quando Usar
|
|
8
|
-
- Use para executar uma única task do tasks.md de um PRD com validação Nível 1 integrada
|
|
9
|
-
- NÃO use quando precisar executar TODAS as tasks sequencialmente (use `/dw-run-plan` em vez disso)
|
|
10
|
-
- NÃO use para corrigir um bug report (use `/dw-bugfix` em vez disso)
|
|
11
|
-
|
|
12
|
-
## Posição no Pipeline
|
|
13
|
-
**Antecessor:** `/dw-create-tasks` | **Sucessor:** `/dw-run-task` (próxima task) ou `/dw-review-implementation`
|
|
14
|
-
|
|
15
|
-
## Skills Complementares
|
|
16
|
-
|
|
17
|
-
Quando disponíveis no projeto em `./.agents/skills/`, use estas skills como suporte especializado sem substituir este comando:
|
|
18
|
-
|
|
19
|
-
| Skill | Gatilho |
|
|
20
|
-
|-------|---------|
|
|
21
|
-
| `dw-verify` | **SEMPRE** — invocada antes do commit para produzir Verification Report com evidence fresca |
|
|
22
|
-
| `dw-memory` | **SEMPRE** — lê memory da workflow no início e atualiza ao final da task (promotion test) |
|
|
23
|
-
| `vercel-react-best-practices` | Task envolve renderização React, hidratação, data fetching, bundle, cache ou performance |
|
|
24
|
-
| `dw-testing-discipline` | Task precisa de testes (qualquer layer) — aplica Iron Laws, 7 AI Gates, catálogo de anti-patterns. Use `references/playwright-recipes.md` quando a task tem frontend interativo precisando de validação E2E. |
|
|
25
|
-
|
|
26
|
-
## Inteligência do Codebase
|
|
27
|
-
|
|
28
|
-
<critical>Se `.dw/intel/` existir, a consulta via `/dw-intel` é OBRIGATÓRIA antes de codar. NÃO pule este passo.</critical>
|
|
29
|
-
- Execute internamente: `/dw-intel "padrões de implementação em [área alvo da task]"`
|
|
30
|
-
- Siga convenções encontradas para estrutura de arquivos, nomenclatura e tratamento de erros
|
|
31
|
-
|
|
32
|
-
Se `design-contract.md` existir no diretório do PRD:
|
|
33
|
-
- Leia o contrato e garanta que toda implementação frontend siga as regras de design aprovadas
|
|
34
|
-
|
|
35
|
-
Se `.dw/intel/` NÃO existir:
|
|
36
|
-
- Use `.dw/rules/` como contexto, caindo para grep direto se necessário
|
|
37
|
-
- Sugira rodar `/dw-map-codebase` após a task para enriquecer contexto downstream
|
|
38
|
-
|
|
39
|
-
## Localização dos Arquivos
|
|
40
|
-
|
|
41
|
-
- PRD: `.dw/spec/prd-[nome-funcionalidade]/prd.md`
|
|
42
|
-
- Tech Spec: `.dw/spec/prd-[nome-funcionalidade]/techspec.md`
|
|
43
|
-
- Tasks: `.dw/spec/prd-[nome-funcionalidade]/tasks.md`
|
|
44
|
-
- Rules do Projeto: `.dw/rules/`
|
|
45
|
-
|
|
46
|
-
## Etapas para Executar
|
|
47
|
-
|
|
48
|
-
### 0. Verificar Branch
|
|
49
|
-
- Confirmar que está na branch `feat/prd-[nome-funcionalidade]`
|
|
50
|
-
- Se não estiver: `git checkout feat/prd-[nome-funcionalidade]`
|
|
51
|
-
|
|
52
|
-
### 1. Configuração Pré-Tarefa
|
|
53
|
-
- Ler a definição da tarefa (`[num]_task.md`)
|
|
54
|
-
- Revisar o contexto do PRD
|
|
55
|
-
- Verificar requisitos da spec técnica (incluindo estratégia de testes)
|
|
56
|
-
- Entender dependências de tarefas anteriores
|
|
57
|
-
- **Invocar `dw-memory`**: ler `.dw/spec/prd-[nome]/MEMORY.md` (shared) e `.dw/spec/prd-[nome]/tasks/[num]_memory.md` (task-local, criar se ausente) — decisões, constraints e handoff notes de tasks anteriores são contexto obrigatório
|
|
58
|
-
|
|
59
|
-
### 2. Análise da Tarefa
|
|
60
|
-
Analise considerando:
|
|
61
|
-
- Objetivos principais da tarefa
|
|
62
|
-
- Como a tarefa se encaixa no contexto do projeto
|
|
63
|
-
- Alinhamento com regras e padrões do projeto (`.dw/rules/`)
|
|
64
|
-
- Possíveis soluções ou abordagens
|
|
65
|
-
- Se React/Next.js estiver no escopo, incorporar explicitamente heurísticas relevantes do `vercel-react-best-practices`
|
|
66
|
-
|
|
67
|
-
### 3. Resumo da Tarefa
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
ID da Tarefa: [ID ou número]
|
|
71
|
-
Nome da Tarefa: [Nome ou descrição breve]
|
|
72
|
-
Contexto PRD: [Pontos principais do PRD]
|
|
73
|
-
Requisitos Tech Spec: [Requisitos técnicos principais]
|
|
74
|
-
Dependências: [Lista de dependências]
|
|
75
|
-
Objetivos Principais: [Objetivos primários]
|
|
76
|
-
Riscos/Desafios: [Riscos ou desafios identificados]
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 4. Plano de Abordagem
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
1. [Primeiro passo]
|
|
83
|
-
2. [Segundo passo]
|
|
84
|
-
3. [Passos adicionais conforme necessário]
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Implementação
|
|
88
|
-
|
|
89
|
-
Após fornecer o resumo e abordagem, **comece imediatamente** a implementar a tarefa:
|
|
90
|
-
- Executar comandos necessários
|
|
91
|
-
- Fazer alterações de código
|
|
92
|
-
- **Implementar testes unitários** (obrigatório para backend)
|
|
93
|
-
- Seguir padrões estabelecidos do projeto
|
|
94
|
-
- Garantir que todos os requisitos sejam atendidos
|
|
95
|
-
- **Rodar testes**: use o comando de teste do projeto
|
|
96
|
-
- Se houver frontend interativo, valide também o comportamento real usando `dw-testing-discipline/references/playwright-recipes.md` quando isso reduzir o risco de regressão invisível nos testes unitários
|
|
97
|
-
|
|
98
|
-
**VOCÊ DEVE** iniciar a implementação logo após o processo acima.
|
|
99
|
-
|
|
100
|
-
<critical>Utilize o Context7 MCP para analisar a documentação da linguagem, frameworks e bibliotecas envolvidas na implementação</critical>
|
|
101
|
-
|
|
102
|
-
## Notas Importantes
|
|
103
|
-
|
|
104
|
-
- Sempre verifique contra PRD, spec técnica e arquivo de tarefa
|
|
105
|
-
- Implemente soluções adequadas **sem usar gambiarras**
|
|
106
|
-
- Siga todos os padrões estabelecidos do projeto
|
|
107
|
-
|
|
108
|
-
## Validação Pós-Implementação - Nível 1 (Obrigatório)
|
|
109
|
-
|
|
110
|
-
<critical>Esta validação é OBRIGATÓRIA antes do commit. Se falhar, corrija e re-valide.</critical>
|
|
111
|
-
|
|
112
|
-
Após implementar, execute a validação leve (Nível 1):
|
|
113
|
-
|
|
114
|
-
### Checklist de Critérios de Aceite
|
|
115
|
-
Para cada critério de aceitação definido na task:
|
|
116
|
-
- Verificar se foi implementado com evidência no código
|
|
117
|
-
- Se algum critério não foi atendido: **CORRIJA antes de prosseguir**
|
|
118
|
-
|
|
119
|
-
### Execução de Testes
|
|
120
|
-
```bash
|
|
121
|
-
# Rodar testes do projeto impactado
|
|
122
|
-
pnpm test # ou npm test
|
|
123
|
-
```
|
|
124
|
-
- [ ] Todos os testes passam (existentes + novos)
|
|
125
|
-
- [ ] Novos testes foram criados para código novo
|
|
126
|
-
- Se algum teste falha: **CORRIJA antes de prosseguir**
|
|
127
|
-
|
|
128
|
-
### Verificação de Padrões Básicos
|
|
129
|
-
- [ ] Tipos explícitos (sem `any`)
|
|
130
|
-
- [ ] Código compila sem erros
|
|
131
|
-
- [ ] Lint passa
|
|
132
|
-
- [ ] Multi-tenancy respeitado (se aplicável)
|
|
133
|
-
- [ ] Padrões do projeto seguidos (`.dw/rules/`)
|
|
134
|
-
|
|
135
|
-
### Verificação de UI Funcional (para tasks com frontend)
|
|
136
|
-
<critical>Páginas placeholder/stub NÃO são entrega aceitável para RFs de interação do usuário.</critical>
|
|
137
|
-
- [ ] Cada página/rota criada renderiza conteúdo funcional (NÃO placeholder genérico)
|
|
138
|
-
- [ ] Se a task cobre um RF de listagem: a página mostra tabela/lista com dados reais da API
|
|
139
|
-
- [ ] Se a task cobre um RF de criação: a página tem formulário/dialog funcional
|
|
140
|
-
- [ ] Se a task cobre um RF de configuração: a página exibe e permite editar os parâmetros
|
|
141
|
-
- [ ] Nenhuma página mostra mensagem genérica como "fundação inicial", "base protegida" ou "placeholder"
|
|
142
|
-
- Se alguma verificação falha: **a task NÃO está completa — implemente a UI real antes de commitar**
|
|
143
|
-
|
|
144
|
-
### Documentação de Artefatos Criados (OBRIGATÓRIO)
|
|
145
|
-
|
|
146
|
-
<critical>
|
|
147
|
-
Ao finalizar cada task, REGISTRAR no tasks.md do projeto uma seção "Artefatos Criados" com:
|
|
148
|
-
|
|
149
|
-
1. **Rotas de API novas**: método + path (ex: `GET /modulo/recurso`)
|
|
150
|
-
2. **Páginas de frontend novas**:
|
|
151
|
-
- URL (ex: `/modulo/pagina`)
|
|
152
|
-
- Como é acessada: via menu (item do sidebar) OU via link em outra página (especificar qual)
|
|
153
|
-
3. **Componentes reutilizáveis criados**: nome + localização
|
|
154
|
-
|
|
155
|
-
Uma página que NÃO é acessível pelo menu NEM por outra página é INÚTIL — garantir que
|
|
156
|
-
toda página nova tenha pelo menos um caminho de acesso para o usuário.
|
|
157
|
-
</critical>
|
|
158
|
-
|
|
159
|
-
Formato no tasks.md (adicionar após marcar a task como concluída):
|
|
160
|
-
|
|
161
|
-
```markdown
|
|
162
|
-
### Artefatos da Task X.0
|
|
163
|
-
|
|
164
|
-
| Artefato | Tipo | Acesso |
|
|
165
|
-
|----------|------|--------|
|
|
166
|
-
| `GET /modulo/recurso` | API | — |
|
|
167
|
-
| `/modulo/pagina` | Página | Menu: Módulo > Item |
|
|
168
|
-
| `ComponenteScreen` | Componente | Usado por páginas X, Y, Z |
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Resultado da Validação
|
|
172
|
-
- **Se TUDO OK**: Prossiga para o commit
|
|
173
|
-
- **Se FALHA**: Corrija os problemas e re-execute a validação
|
|
174
|
-
- **NÃO gere relatório em arquivo** - apenas output no terminal
|
|
175
|
-
|
|
176
|
-
## Verificação Final (Obrigatório antes do commit)
|
|
177
|
-
|
|
178
|
-
<critical>Invocar a skill `dw-verify` antes de qualquer alegação de "task completa". Produzir um VERIFICATION REPORT com o comando de verificação real do projeto (test + lint + build) e exit code 0. Sem report PASS, NÃO prossiga para o commit.</critical>
|
|
179
|
-
|
|
180
|
-
## Atualização de Memory (Obrigatório antes do commit)
|
|
181
|
-
|
|
182
|
-
Invocar `dw-memory` para:
|
|
183
|
-
- Atualizar `tasks/[num]_memory.md` com arquivos tocados, decisões não-óbvias e handoff notes
|
|
184
|
-
- Aplicar o **promotion test** (próxima task precisa? durável? não óbvio do repo?) e promover apenas o que passar para `MEMORY.md`
|
|
185
|
-
|
|
186
|
-
## Commit Automático (Obrigatório)
|
|
187
|
-
|
|
188
|
-
Ao final da task (após validação Nível 1 + dw-verify PASS + dw-memory atualizado), **sempre** fazer commit (sem push):
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
git status
|
|
192
|
-
git add .
|
|
193
|
-
git commit -m "feat([modulo]): [descrição concisa]
|
|
194
|
-
|
|
195
|
-
- [item 1 implementado]
|
|
196
|
-
- [item 2 implementado]
|
|
197
|
-
- Add unit tests"
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
**Nota**: O push será feito apenas no `/dw-generate-pr` ao final de todas as tasks.
|
|
201
|
-
|
|
202
|
-
<critical>Após completar a tarefa, marque como completa em tasks.md</critical>
|
|
203
|
-
|
|
204
|
-
## Próximos Passos
|
|
205
|
-
|
|
206
|
-
- Se há mais tasks: `/dw-run-task [próxima-task]`
|
|
207
|
-
- Se última task: `/dw-generate-pr [branch-alvo]` (ex: `/dw-generate-pr main`)
|
|
208
|
-
</system_instructions>
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
<system_instructions>
|
|
2
|
-
Você é um auditor de segurança rigoroso. Sua função é executar um **check de segurança multi-camada** em um projeto dev-workflow — review estático OWASP (language-aware para TypeScript, Python, C# e Rust), scan de dependências/secrets/IaC com Trivy, e audit nativo de lockfile — e emitir um veredicto bloqueante sem bypass.
|
|
3
|
-
|
|
4
|
-
<critical>Este command é rígido. Findings CRITICAL ou HIGH produzem status REJECTED. NÃO existe flag `--skip`, `--ignore` ou allowlist. Findings são corrigidos ou o veredicto se mantém.</critical>
|
|
5
|
-
<critical>Linguagens suportadas nesta release: TypeScript/JavaScript, Python, C#, Rust. Se nenhuma for detectada no escopo, aborta com mensagem clara.</critical>
|
|
6
|
-
|
|
7
|
-
## Quando Usar
|
|
8
|
-
- Antes de `/dw-code-review` como camada de segurança para qualquer projeto TS/Python/C#/Rust
|
|
9
|
-
- Antes de `/dw-generate-pr` para garantir que nenhuma vulnerabilidade HIGH/CRITICAL entre no PR
|
|
10
|
-
- Invocado automaticamente por `/dw-review-implementation` quando o diff toca código em linguagem suportada
|
|
11
|
-
- Manualmente ao auditar dependências após adicionar um novo pacote
|
|
12
|
-
- NÃO use para auto-fix (este command detecta; remediação é manual ou via `/dw-fix-qa`)
|
|
13
|
-
- NÃO use para DAST — este é SAST + SCA + IaC scan (`/dw-run-qa` cobre runtime)
|
|
14
|
-
|
|
15
|
-
## Posição no Pipeline
|
|
16
|
-
**Antecessor:** `/dw-run-plan` ou `/dw-run-task` (código commitado) | **Sucessor:** `/dw-code-review` (que hard-gates no resultado deste command para linguagens suportadas)
|
|
17
|
-
|
|
18
|
-
## Skills Complementares
|
|
19
|
-
|
|
20
|
-
| Skill | Gatilho |
|
|
21
|
-
|-------|---------|
|
|
22
|
-
| `security-review` | **SEMPRE** — knowledge base OWASP primário; regras específicas por linguagem em `languages/{typescript,python,csharp,rust}.md`, tópicos cross-cutting em `references/*.md` |
|
|
23
|
-
| `dw-review-rigor` | **SEMPRE** — aplica de-duplication (mesmo pattern em N arquivos = 1 finding), severity ordering, verify-intent-before-flag, skip-what-linter-catches, signal-over-volume |
|
|
24
|
-
| `dw-verify` | **SEMPRE** — um VERIFICATION REPORT (comando Trivy + exit code + summary) deve estar presente antes de qualquer status ser emitido |
|
|
25
|
-
|
|
26
|
-
## Variáveis de Entrada
|
|
27
|
-
|
|
28
|
-
| Variável | Descrição | Exemplo |
|
|
29
|
-
|----------|-----------|---------|
|
|
30
|
-
| `{{SCOPE}}` | Path do PRD OU path de código-fonte. Opcional — default é `.dw/spec/prd-<slug>` inferido da branch `feat/prd-<slug>` | `.dw/spec/prd-checkout-v2` ou `src/` |
|
|
31
|
-
|
|
32
|
-
Se `{{SCOPE}}` não for fornecido e nenhum PRD está ativo, aborta pedindo escopo explícito.
|
|
33
|
-
|
|
34
|
-
## Localização dos Arquivos
|
|
35
|
-
|
|
36
|
-
- Report (scope PRD): `{{SCOPE}}/security-check.md`
|
|
37
|
-
- Report (scope não-PRD): stdout
|
|
38
|
-
- Arquivos de referência por linguagem: `.agents/skills/security-review/languages/{typescript,javascript,python,csharp,rust}.md`
|
|
39
|
-
- Refs OWASP cross-cutting: `.agents/skills/security-review/references/*.md`
|
|
40
|
-
|
|
41
|
-
## Comportamento Obrigatório — Pipeline (executar em ordem, sem bypass)
|
|
42
|
-
|
|
43
|
-
### 0. Detectar Linguagens no Escopo
|
|
44
|
-
|
|
45
|
-
Enumere arquivos em escopo e detecte linguagens:
|
|
46
|
-
|
|
47
|
-
| Linguagem | Indicadores |
|
|
48
|
-
|-----------|-------------|
|
|
49
|
-
| TypeScript / JavaScript | `tsconfig.json`, `package.json`, `*.ts`, `*.tsx`, `*.js`, `*.jsx`, `*.mjs` |
|
|
50
|
-
| Python | `pyproject.toml`, `requirements*.txt`, `Pipfile`, `poetry.lock`, `setup.py`, `*.py` |
|
|
51
|
-
| C# / .NET | `*.csproj`, `*.sln`, `packages.config`, `Directory.Build.props`, `*.cs`, `*.cshtml`, `*.razor` |
|
|
52
|
-
| Rust | `Cargo.toml`, `Cargo.lock`, `*.rs`, `rust-toolchain.toml` |
|
|
53
|
-
|
|
54
|
-
- Se **nenhuma** das quatro é detectada → **abortar** com:
|
|
55
|
-
`"dw-security-check suporta TypeScript, Python, C# e Rust nesta release. Nenhum arquivo em linguagens suportadas foi encontrado em <scope>. Abortando."`
|
|
56
|
-
- Se **uma ou mais** são detectadas → prosseguir; repos poliglotas rodam todas as camadas aplicáveis e o report tem uma seção por linguagem.
|
|
57
|
-
|
|
58
|
-
Registre a(s) linguagem(ns) detectadas — elas controlam qual arquivo `languages/*.md` o review estático consulta e qual audit nativo roda.
|
|
59
|
-
|
|
60
|
-
### 1. Review Estático de Código (Language-Aware)
|
|
61
|
-
|
|
62
|
-
Para cada linguagem detectada, invoque a skill `security-review` usando o(s) arquivo(s) de referência correspondente(s) como guia primário:
|
|
63
|
-
|
|
64
|
-
- **TS/JS** → `languages/typescript.md` + `languages/javascript.md`
|
|
65
|
-
- **Python** → `languages/python.md`
|
|
66
|
-
- **C#** → `languages/csharp.md`
|
|
67
|
-
- **Rust** → `languages/rust.md`
|
|
68
|
-
- **Cross-cutting** (todas) → `references/{injection,xss,csrf,ssrf,cryptography,authentication,authorization,deserialization,supply-chain,secrets,file-security,api-security}.md` conforme aplicável
|
|
69
|
-
|
|
70
|
-
Aplique as cinco regras do `dw-review-rigor`:
|
|
71
|
-
1. De-duplicate: mesmo pattern em N arquivos → 1 finding com lista de affected files
|
|
72
|
-
2. Severity ordering: CRITICAL → HIGH → MEDIUM → LOW
|
|
73
|
-
3. Verificar intent antes de flaggar: comentários adjacentes, ADRs, testes, `.dw/rules/`
|
|
74
|
-
4. Pular o que o linter já pega
|
|
75
|
-
5. Signal over volume: manter TODOS os CRITICAL/HIGH; podar MEDIUM/LOW aos mais impactantes
|
|
76
|
-
|
|
77
|
-
### 1.5. Context7 MCP — Best Practices de Framework (OBRIGATÓRIO quando framework detectado)
|
|
78
|
-
|
|
79
|
-
<critical>Quando o escopo tem framework detectável, VOCÊ DEVE consultar o Context7 MCP para best practices atualizadas antes de aplicar checks específicos de framework. Conhecimento offline pode estar desatualizado.</critical>
|
|
80
|
-
|
|
81
|
-
Detecção de framework e query:
|
|
82
|
-
|
|
83
|
-
| Linguagem | Fonte de detecção | Exemplos de query Context7 |
|
|
84
|
-
|-----------|-------------------|----------------------------|
|
|
85
|
-
| TS/JS | deps em `package.json` | `"next.js 14 security best practices app router"`, `"nestjs 10 authentication guards"`, `"remix v2 csrf"` |
|
|
86
|
-
| Python | `pyproject.toml` / `requirements.txt` | `"django 5 security checklist"`, `"fastapi pydantic validation"`, `"flask-login secure cookies"` |
|
|
87
|
-
| C# | `PackageReference` em `*.csproj` | `"asp.net core 8 jwt bearer"`, `"blazor server antiforgery"`, `"minimal apis authorization"` |
|
|
88
|
-
| Rust | `[dependencies]` em `Cargo.toml` | `"actix-web 4 security middleware"`, `"axum 0.7 extractor auth"`, `"rocket 0.5 forms csrf"`, `"sqlx query macros"` |
|
|
89
|
-
|
|
90
|
-
Para cada framework+versão detectado:
|
|
91
|
-
1. Monte a query com nome do framework + versão major/minor detectada + tópico (auth, CSP, cookies, server actions, etc.)
|
|
92
|
-
2. Invoque o Context7 MCP
|
|
93
|
-
3. Incorpore a guidance retornada como contexto vivo ao revisar código framework-específico
|
|
94
|
-
4. Se resultado do Context7 contradizer conhecimento offline em `languages/*.md`, **Context7 vence** — cite a fonte no finding
|
|
95
|
-
|
|
96
|
-
Se Context7 MCP não estiver disponível no ambiente:
|
|
97
|
-
- Degrade para conhecimento offline apenas
|
|
98
|
-
- **Adicione aviso visível** no report: `⚠️ Context7 MCP indisponível — checks framework-version-specific usaram conhecimento offline; best practices para <framework@versão> podem estar desatualizadas.`
|
|
99
|
-
|
|
100
|
-
### 2. Scan de Dependências + Secrets + IaC (Trivy)
|
|
101
|
-
|
|
102
|
-
<critical>Trivy deve estar instalado. Se ausente, aborte com: `"Trivy não encontrado. Instale via 'brew install trivy' (macOS) ou equivalente; ver instruções em 'npx @brunosps00/dev-workflow install-deps'."`</critical>
|
|
103
|
-
|
|
104
|
-
Execute:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
trivy fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --format json --output /tmp/dw-trivy-fs.json <scope-path>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Parse o JSON de saída. O scan cobre:
|
|
111
|
-
- **Vulnerabilidades** em manifests: `package.json`/`package-lock.json`/`pnpm-lock.yaml`/`yarn.lock` (TS/JS), `requirements*.txt`/`Pipfile.lock`/`poetry.lock` (Python), `*.csproj`/`packages.lock.json` (C# / NuGet)
|
|
112
|
-
- **Secrets**: API keys, tokens, chaves privadas commitadas acidentalmente
|
|
113
|
-
- **Misconfig**: surface-level — complementado pelo step 3 para IaC
|
|
114
|
-
|
|
115
|
-
Capture o comando exato e exit code; inclua ambos no VERIFICATION REPORT (step 5).
|
|
116
|
-
|
|
117
|
-
### 3. Scan de Config IaC (Trivy)
|
|
118
|
-
|
|
119
|
-
Execute:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
trivy config --severity HIGH,CRITICAL --format json --output /tmp/dw-trivy-config.json <scope-path>
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Cobre Dockerfile, manifests Kubernetes, Terraform, CloudFormation, GitHub Actions workflows, Helm charts, AWS CDK.
|
|
126
|
-
|
|
127
|
-
### 4. Audit Nativo de Lockfile (por linguagem, segundo sinal)
|
|
128
|
-
|
|
129
|
-
Para cada linguagem detectada, rode a ferramenta nativa de audit (se disponível). Trate o output como segundo sinal — Trivy é primário; isto cobre lacunas.
|
|
130
|
-
|
|
131
|
-
| Linguagem | Comando primário | Fallback |
|
|
132
|
-
|-----------|------------------|----------|
|
|
133
|
-
| TS/JS (npm) | `npm audit --production --audit-level=high --json` | `npm audit --production` (human) |
|
|
134
|
-
| TS/JS (pnpm) | `pnpm audit --prod --audit-level high --json` | — |
|
|
135
|
-
| TS/JS (yarn) | `yarn npm audit --severity high --recursive --json` | — |
|
|
136
|
-
| Python | `pip-audit --strict --format json` | pular com nota se `pip-audit` ausente |
|
|
137
|
-
| C# | `dotnet list package --vulnerable --include-transitive` | — |
|
|
138
|
-
| Rust | `cargo audit --json` | pular com nota se `cargo-audit` não instalado (instalar via `cargo install cargo-audit`); opcionalmente `cargo deny check advisories` |
|
|
139
|
-
|
|
140
|
-
Se a ferramenta retornar exit ≠ 0 ou reportar HIGH/CRITICAL, escalar para REJECTED (mesma política do Trivy).
|
|
141
|
-
|
|
142
|
-
### 5. VERIFICATION REPORT (dw-verify)
|
|
143
|
-
|
|
144
|
-
Antes de emitir status, produza um VERIFICATION REPORT conforme skill `dw-verify`. Formato obrigatório:
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
VERIFICATION REPORT
|
|
148
|
-
-------------------
|
|
149
|
-
Claim: Security check completo para <scope> (linguagens: <lista>)
|
|
150
|
-
Commands:
|
|
151
|
-
- trivy fs ... --exit-code 1 → exit <N>, findings: C=<x> H=<y>
|
|
152
|
-
- trivy config ... → exit <N>, findings: C=<x> H=<y>
|
|
153
|
-
- <audit nativo> → exit <N>, findings: ...
|
|
154
|
-
Executed: just now, after all changes
|
|
155
|
-
Static review: <X> findings (C=<a> H=<b> M=<c> L=<d>)
|
|
156
|
-
Framework context: Context7 MCP [consultado | indisponível]
|
|
157
|
-
Verdict: <CLEAN | PASSED WITH OBSERVATIONS | REJECTED>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### 6. Emitir Status (gates rígidos)
|
|
161
|
-
|
|
162
|
-
| Condição | Status |
|
|
163
|
-
|----------|--------|
|
|
164
|
-
| Qualquer finding CRITICAL (estático OU Trivy OU audit nativo) | **REJECTED** |
|
|
165
|
-
| Qualquer finding HIGH | **REJECTED** |
|
|
166
|
-
| Apenas findings MEDIUM / LOW | **PASSED WITH OBSERVATIONS** |
|
|
167
|
-
| Zero findings | **CLEAN** |
|
|
168
|
-
|
|
169
|
-
<critical>Nenhum finding é "aceito como ressalva" em HIGH ou acima. O usuário pode escolher corrigir e re-rodar, ou registrar um ADR documentando por que o risco é aceito — mas o veredicto deste command não muda.</critical>
|
|
170
|
-
|
|
171
|
-
## Formato do Report
|
|
172
|
-
|
|
173
|
-
Salvar em `{{SCOPE}}/security-check.md` (quando scope PRD) com frontmatter:
|
|
174
|
-
|
|
175
|
-
```markdown
|
|
176
|
-
---
|
|
177
|
-
type: security-check
|
|
178
|
-
schema_version: "1.0"
|
|
179
|
-
status: <CLEAN | PASSED WITH OBSERVATIONS | REJECTED>
|
|
180
|
-
date: YYYY-MM-DD
|
|
181
|
-
languages: [typescript, python, csharp, rust]
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
# Security Check — <nome da feature>
|
|
185
|
-
|
|
186
|
-
## Status: <STATUS>
|
|
187
|
-
|
|
188
|
-
<resumo curto>
|
|
189
|
-
|
|
190
|
-
## VERIFICATION REPORT
|
|
191
|
-
<bloco do step 5>
|
|
192
|
-
|
|
193
|
-
## Findings
|
|
194
|
-
|
|
195
|
-
### Critical (<count>)
|
|
196
|
-
- **[CRITICAL]** `path/to/file.ts:42` — <título ≤72 chars>
|
|
197
|
-
<descrição>
|
|
198
|
-
<remediação>
|
|
199
|
-
Também afeta: <outros paths se de-duplicado>
|
|
200
|
-
Evidência: <snippet ou CVE id>
|
|
201
|
-
|
|
202
|
-
### High (<count>)
|
|
203
|
-
...
|
|
204
|
-
|
|
205
|
-
### Medium (<count>)
|
|
206
|
-
...
|
|
207
|
-
|
|
208
|
-
### Low (<count>)
|
|
209
|
-
...
|
|
210
|
-
|
|
211
|
-
## Vulnerabilidades de Dependência (Trivy)
|
|
212
|
-
|
|
213
|
-
| CVE | Pacote | Instalada | Corrigida em | Severidade | Path |
|
|
214
|
-
|-----|--------|-----------|--------------|------------|------|
|
|
215
|
-
| CVE-... | ... | ... | ... | CRITICAL | package-lock.json |
|
|
216
|
-
|
|
217
|
-
## Secrets Encontrados (Trivy)
|
|
218
|
-
|
|
219
|
-
| Regra | Arquivo | Linha |
|
|
220
|
-
|-------|---------|-------|
|
|
221
|
-
| aws-access-key-id | src/config.ts | 14 |
|
|
222
|
-
|
|
223
|
-
## Misconfigurations IaC (Trivy config)
|
|
224
|
-
|
|
225
|
-
| Regra | Arquivo | Severidade | Descrição |
|
|
226
|
-
|-------|---------|------------|-----------|
|
|
227
|
-
| AVD-DS-0002 | Dockerfile | HIGH | Rodando como root |
|
|
228
|
-
|
|
229
|
-
## Best Practices de Framework (Context7)
|
|
230
|
-
|
|
231
|
-
Para cada framework consultado, um parágrafo resumindo a guidance aplicada.
|
|
232
|
-
|
|
233
|
-
Se Context7 estava indisponível, incluir o bloco de aviso.
|
|
234
|
-
|
|
235
|
-
## Pontos Bem-Implementados
|
|
236
|
-
- <lista curta para calibrar tom; não afeta verdict>
|
|
237
|
-
|
|
238
|
-
## Recomendações
|
|
239
|
-
1. <ação para findings bloqueantes>
|
|
240
|
-
2. <ação para observations>
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
## Integração com Outros Commands dw-*
|
|
244
|
-
|
|
245
|
-
- **`/dw-code-review`** (Nível 3): para projetos TS/Python/C#/Rust, invoca este command como step 6.7 "Camada de Segurança" e hard-gates no resultado. APROVADO não pode ser emitido se `security-check.md` ausente ou REJECTED.
|
|
246
|
-
- **`/dw-review-implementation`** (Nível 2): para projetos TS/Python/C#/Rust que tocam código, invoca este command e mapeia seus findings em uma categoria "Security Gaps" no ciclo interativo de correções.
|
|
247
|
-
- **`/dw-generate-pr`**: hard gate — para projetos em linguagem suportada, bloqueia o PR se `security-check.md` ausente ou REJECTED na sessão atual.
|
|
248
|
-
- **`/dw-bugfix --análise`**: se a área da causa raiz envolve auth / secrets / input externo, sugere rodar este command antes do fix.
|
|
249
|
-
|
|
250
|
-
## Regras Críticas
|
|
251
|
-
|
|
252
|
-
- <critical>SEM flag de bypass. O command NÃO aceita `--skip`, `--ignore`, `--allowlist`.</critical>
|
|
253
|
-
- <critical>Trivy é obrigatório. Se ausente, aborte com instruções de instalação. NÃO pule silenciosamente a camada SCA.</critical>
|
|
254
|
-
- <critical>Context7 MCP é consultado quando frameworks são detectados. Degradação para modo offline deve ser visível no report.</critical>
|
|
255
|
-
- NÃO modifique código-fonte — este command só detecta.
|
|
256
|
-
- NÃO re-flagge findings já trackados como aceitos em ADR prévio (`.dw/spec/*/adrs/adr-*.md` com status `Accepted` e tópico cobrindo o finding).
|
|
257
|
-
- Se rodando sem scope PRD (path raw), emita o report em stdout — não escreva em locais arbitrários.
|
|
258
|
-
|
|
259
|
-
## Tratamento de Erros
|
|
260
|
-
|
|
261
|
-
- Trivy ausente → aborte com instruções de instalação (ver `install-deps`)
|
|
262
|
-
- `.dw/spec/<slug>/` ausente → verifique se escopo é path raw; caso contrário aborte pedindo escopo explícito
|
|
263
|
-
- Ferramenta de audit nativo ausente (ex: `pip-audit`) → pule com nota visível no report; não falhe
|
|
264
|
-
- Context7 MCP indisponível → aviso visível no report; não falhe
|
|
265
|
-
- Escopo contém 0 arquivos de linguagens suportadas → aborta (ver step 0)
|
|
266
|
-
|
|
267
|
-
## Inspired by
|
|
268
|
-
|
|
269
|
-
`dw-security-check` é dev-workflow-native. Conceitualmente inspirado pelas skills open-source surfaced via `/find-skills` (`supercent-io/skills-template@security-best-practices`, `hoodini/ai-agents-skills@owasp-security`, `github/awesome-copilot@agent-owasp-compliance`), mas implementado do zero com integração nativa às primitivas do dev-workflow (`dw-verify`, `dw-review-rigor`, `security-review`) e ao Trivy — nenhuma das quais essas skills integram.
|
|
270
|
-
|
|
271
|
-
</system_instructions>
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
# Seven AI agent gates — mandatory when an LLM writes tests
|
|
2
|
-
|
|
3
|
-
LLMs have characteristic failure modes when authoring tests. These gates are forcing functions for the seven most common.
|
|
4
|
-
|
|
5
|
-
Every test produced by an agent (via `/dw-run-task`, `/dw-bugfix`, `/dw-autopilot`, or any other code-generating flow) must pass all seven gates BEFORE the diff is presented for review.
|
|
6
|
-
|
|
7
|
-
## Gate 1: Invariant first
|
|
8
|
-
|
|
9
|
-
**The failure mode it blocks:** Agent writes 200 lines of test code without articulating what the test is supposed to prove.
|
|
10
|
-
|
|
11
|
-
**The gate:**
|
|
12
|
-
|
|
13
|
-
Before writing any test code, the agent prints:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
INVARIANT: <one sentence: what behavior is true that the test verifies>
|
|
17
|
-
OWNING_LAYER: <unit | integration | contract | e2e>
|
|
18
|
-
EXISTING_SUITE: <path to existing test file the new test joins>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
**Why it works:**
|
|
22
|
-
- "Invariant" forces specific behavior naming.
|
|
23
|
-
- "Owning layer" forces Law 2 (lowest detectable layer).
|
|
24
|
-
- "Existing suite" forces extending coverage rather than spawning new files.
|
|
25
|
-
|
|
26
|
-
**Verification:** In `/dw-code-review`, look for this 3-line preamble in the PR description or the commit body. Missing = REJECTED.
|
|
27
|
-
|
|
28
|
-
## Gate 2: Owning layer
|
|
29
|
-
|
|
30
|
-
**The failure mode it blocks:** Agent creates a new test file every time, scattering coverage across orphan files. Or, agent writes E2E tests for things unit could prove.
|
|
31
|
-
|
|
32
|
-
**The gate:**
|
|
33
|
-
|
|
34
|
-
The agent must:
|
|
35
|
-
1. Identify the existing test suite that owns the module under test.
|
|
36
|
-
2. Extend that suite, OR document why a new suite is needed (genuinely new module, new test pyramid layer).
|
|
37
|
-
3. Map the test to the right layer per Law 2.
|
|
38
|
-
|
|
39
|
-
**Verification:**
|
|
40
|
-
- New test file in PR but existing file covers the same module? REJECTED.
|
|
41
|
-
- E2E test for pure-logic invariant? REJECTED unless documented.
|
|
42
|
-
- Unit test for cross-service flow? REJECTED — push to integration/E2E.
|
|
43
|
-
|
|
44
|
-
## Gate 3: Real execution
|
|
45
|
-
|
|
46
|
-
**The failure mode it blocks:** Agent writes tests that mock everything. They pass green forever and validate nothing.
|
|
47
|
-
|
|
48
|
-
**The gate:**
|
|
49
|
-
|
|
50
|
-
Every test path the agent writes must, at SOME layer, run against real systems before the diff merges:
|
|
51
|
-
|
|
52
|
-
- Pure logic: unit only is fine.
|
|
53
|
-
- Code that touches DB: must have at least one integration test running real DB (testcontainers, ephemeral container, dedicated test DB).
|
|
54
|
-
- Code that calls external services: must have a contract test OR a sandbox-account smoke test.
|
|
55
|
-
- UI interactions: must have at least one E2E run on a real preview environment.
|
|
56
|
-
|
|
57
|
-
**Verification:** PR description must list the real-system runs that exercise the touched code. If no real-system path covers the change, REJECTED.
|
|
58
|
-
|
|
59
|
-
## Gate 4: Failure → fix production
|
|
60
|
-
|
|
61
|
-
**The failure mode it blocks:** Agent sees test red, modifies the test until green. Bug ships.
|
|
62
|
-
|
|
63
|
-
**The gate:**
|
|
64
|
-
|
|
65
|
-
When the agent encounters a failing test (its own or pre-existing):
|
|
66
|
-
|
|
67
|
-
1. Print: `INVESTIGATING FAILURE: <test name>`
|
|
68
|
-
2. Read production code in the path that produces the observed value.
|
|
69
|
-
3. Print: `ANALYSIS: <2-3 sentences on whether production is wrong, test is wrong, or invariant changed>`
|
|
70
|
-
4. Decide:
|
|
71
|
-
- Production wrong → fix production.
|
|
72
|
-
- Test wrong → fix test AND document the change in the commit body.
|
|
73
|
-
- Invariant changed → update the test AND open an ADR if the change is a public contract change.
|
|
74
|
-
|
|
75
|
-
**Verification:** Every commit that changes a previously-green test must have an `ANALYSIS:` line in the commit body explaining the decision. Missing = REJECTED.
|
|
76
|
-
|
|
77
|
-
## Gate 5: No snapshot without contract
|
|
78
|
-
|
|
79
|
-
**The failure mode it blocks:** Agent reaches for `toMatchSnapshot()` whenever it doesn't know what to assert. Snapshot becomes the assertion. Drift goes unnoticed.
|
|
80
|
-
|
|
81
|
-
**The gate:**
|
|
82
|
-
|
|
83
|
-
Before adding a snapshot assertion, the agent classifies the artifact:
|
|
84
|
-
|
|
85
|
-
- **PRODUCT_CONTRACT**: a stable contract worth pinning (e.g., serialized output of a public API, schema of a stored record). Snapshot is appropriate. Document the classification.
|
|
86
|
-
- **IMPLEMENTATION_DETAIL**: HTML structure, internal representation, component tree shape. Snapshot is FORBIDDEN. Write specific assertions instead.
|
|
87
|
-
|
|
88
|
-
**Verification:** Snapshots in the diff without a classification comment = REJECTED. Snapshots classified as IMPLEMENTATION_DETAIL = REJECTED.
|
|
89
|
-
|
|
90
|
-
## Gate 6: No assertion on self-set mock
|
|
91
|
-
|
|
92
|
-
**The failure mode it blocks:** Agent writes `mockFn.mockReturnValue('X')`, then asserts `expect(mockFn()).toBe('X')`. Proves nothing.
|
|
93
|
-
|
|
94
|
-
**The gate:**
|
|
95
|
-
|
|
96
|
-
The agent cannot assert on values it directly fed into a mock. Assertions must be on:
|
|
97
|
-
- The OUTPUT of production code that consumed the mock.
|
|
98
|
-
- The SIDE EFFECTS (DB state, network calls, event emissions) caused by production code.
|
|
99
|
-
- The VISIBLE behavior (UI change, log line, response) the user/caller observes.
|
|
100
|
-
|
|
101
|
-
**Verification:** Diff analysis flags pairs where a literal value appears in BOTH a mock setup AND an assertion. Flagged = REJECTED unless the agent can show the value passed through production code.
|
|
102
|
-
|
|
103
|
-
## Gate 7: Negative companion
|
|
104
|
-
|
|
105
|
-
**The failure mode it blocks:** Agent writes happy-path-only tests. Edge cases, error paths, boundaries uncovered.
|
|
106
|
-
|
|
107
|
-
**The gate:**
|
|
108
|
-
|
|
109
|
-
Every positive assertion the agent writes ships WITH at least one negative companion:
|
|
110
|
-
|
|
111
|
-
- Asserting `createUser(validInput)` succeeds → also assert `createUser(invalidInput)` fails with a specific error.
|
|
112
|
-
- Asserting `parseDate(validString)` returns a Date → also assert `parseDate(invalidString)` throws/returns null.
|
|
113
|
-
- Asserting `transferFunds(...)` succeeds with sufficient balance → also assert it fails with insufficient balance.
|
|
114
|
-
|
|
115
|
-
**Verification:** A PR adding N positive assertions must add ≥1 negative assertion per public path. Imbalance >3:1 (positive:negative) on a public path = REJECTED.
|
|
116
|
-
|
|
117
|
-
## How the gates compose
|
|
118
|
-
|
|
119
|
-
Together, the seven gates produce tests that:
|
|
120
|
-
1. State what they prove (invariant first).
|
|
121
|
-
2. Live at the right layer (owning layer).
|
|
122
|
-
3. Exercise reality somewhere (real execution).
|
|
123
|
-
4. Reveal bugs when red (failure → fix production).
|
|
124
|
-
5. Assert specifically, not via snapshots (no snapshot w/o contract).
|
|
125
|
-
6. Assert outputs, not setup (no self-mock assertion).
|
|
126
|
-
7. Cover failures, not just success (negative companion).
|
|
127
|
-
|
|
128
|
-
A test passing all seven is a test worth running. A test missing any one is more likely to mislead than help.
|
|
129
|
-
|
|
130
|
-
## Override procedure
|
|
131
|
-
|
|
132
|
-
If an agent (or user) wants to skip a gate, they must:
|
|
133
|
-
1. State which gate is being skipped.
|
|
134
|
-
2. State why (one sentence).
|
|
135
|
-
3. Add a `// SKIP-GATE-N: <reason>` comment in the test.
|
|
136
|
-
4. Open a follow-up issue tracking the gap.
|
|
137
|
-
|
|
138
|
-
Without all four, the gate is enforced.
|
|
139
|
-
|
|
140
|
-
## Prompt block to include when invoking the agent
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
You are about to write tests. Before producing test code, complete the
|
|
144
|
-
seven-gate preamble:
|
|
145
|
-
|
|
146
|
-
INVARIANT: ___
|
|
147
|
-
OWNING_LAYER: ___
|
|
148
|
-
EXISTING_SUITE: ___
|
|
149
|
-
|
|
150
|
-
If you cannot complete these three lines, STOP and ask the user for
|
|
151
|
-
the requirement (do not invent an invariant).
|
|
152
|
-
|
|
153
|
-
Then, while writing tests:
|
|
154
|
-
- Real execution: name the real-system path covering this code.
|
|
155
|
-
- On red: investigate production before changing tests; print ANALYSIS.
|
|
156
|
-
- Snapshots: classify as PRODUCT_CONTRACT or IMPLEMENTATION_DETAIL.
|
|
157
|
-
- Assertions: never assert on values you fed into a mock.
|
|
158
|
-
- Coverage: every positive assertion needs a negative companion.
|
|
159
|
-
|
|
160
|
-
Tests that violate gates without explicit SKIP-GATE-N comments will be
|
|
161
|
-
REJECTED at review.
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
`/dw-run-task` and `/dw-bugfix` inject this prompt before generating test code.
|
|
165
|
-
|
|
166
|
-
## Why these seven and not more
|
|
167
|
-
|
|
168
|
-
These are the seven LLM failure modes empirically observed in test generation across multiple projects (per pedronauck/skills/testing-boss, MIT, plus dev-workflow internal observation). Other tendencies exist; they're either covered by the positive patterns (e.g., wall-clock waits) or have lower hit-rate.
|
|
169
|
-
|
|
170
|
-
If a NEW LLM failure mode appears that none of the seven catches, add a gate AND document the failure mode that motivated it. Don't add gates speculatively.
|