kakaroto-config 1.0.4 → 1.0.6

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 (47) hide show
  1. package/config/ARCHITECTURE.md +5 -7
  2. package/config/CLAUDE.md +11 -0
  3. package/config/agents/code-reviewer.md +66 -230
  4. package/config/agents/code-simplifier.md +70 -116
  5. package/config/agents/{visual-validator.md → functional-validator.md} +118 -92
  6. package/config/agents/memory-sync.md +193 -134
  7. package/config/commands/debug/02-investigate.md +3 -3
  8. package/config/commands/debug/03-fix.md +28 -6
  9. package/config/commands/debug/05-commit.md +1 -1
  10. package/config/commands/debug/validators/fix-permanence.md +1 -1
  11. package/config/commands/feature/01-understand.md +217 -0
  12. package/config/commands/feature/02-analyze.md +168 -0
  13. package/config/commands/feature/03-strategy.md +300 -0
  14. package/config/commands/feature/04-red.md +160 -0
  15. package/config/commands/feature/05-green.md +179 -0
  16. package/config/commands/feature/06-quality.md +109 -0
  17. package/config/commands/feature/07-validation.md +168 -0
  18. package/config/commands/feature/08-delivery.md +86 -0
  19. package/config/commands/feature/09-evaluate.md +140 -0
  20. package/config/commands/feature/playbooks/_e2e-base.md +39 -0
  21. package/config/commands/feature/playbooks/api/analyze.md +20 -0
  22. package/config/commands/feature/playbooks/api/e2e.md +29 -0
  23. package/config/commands/feature/playbooks/api/red.md +66 -0
  24. package/config/commands/feature/playbooks/job/analyze.md +29 -0
  25. package/config/commands/feature/playbooks/job/e2e.md +30 -0
  26. package/config/commands/feature/playbooks/job/red.md +77 -0
  27. package/config/commands/feature/playbooks/service/analyze.md +28 -0
  28. package/config/commands/feature/playbooks/service/e2e.md +25 -0
  29. package/config/commands/feature/playbooks/service/red.md +75 -0
  30. package/config/commands/feature/playbooks/ui/analyze.md +26 -0
  31. package/config/commands/feature/playbooks/ui/e2e.md +61 -0
  32. package/config/commands/feature/playbooks/ui/red.md +71 -0
  33. package/config/commands/feature.md +37 -4
  34. package/config/commands/gate.md +11 -23
  35. package/config/templates/spec-template.md +82 -68
  36. package/package.json +3 -3
  37. package/config/agents/dry-enforcer.md +0 -227
  38. package/config/commands/debug/techniques/flow-tracing.md +0 -75
  39. package/config/commands/debug/techniques/hypothesis-generation.md +0 -30
  40. package/config/commands/debug/techniques/sequential-thinking-config.md +0 -79
  41. package/config/commands/feature/01-interview.md +0 -143
  42. package/config/commands/feature/02-spec.md +0 -98
  43. package/config/commands/feature/03-planner.md +0 -200
  44. package/config/commands/feature/04-implement.md +0 -81
  45. package/config/commands/feature/05-quality.md +0 -140
  46. package/config/commands/feature/06-commit.md +0 -91
  47. package/config/commands/feature/07-evaluate.md +0 -129
@@ -0,0 +1,217 @@
1
+ # Fase 1: Understand
2
+
3
+ ## Responsabilidade
4
+ Coletar requisitos com o USER.
5
+
6
+ ---
7
+
8
+ ## Passo 0: Detectar Workflow Existente
9
+
10
+ ```bash
11
+ if [ -f .claude/workflow-state.json ]; then
12
+ phase=$(jq -r '.currentPhase' .claude/workflow-state.json 2>/dev/null)
13
+ if [ "$phase" != "COMPLETED" ]; then
14
+ echo "Workflow existente: $phase"
15
+ echo "Para continuar: Read arquivo em currentPhaseFile"
16
+ echo "Para novo: prossiga (state sera sobrescrito)"
17
+ fi
18
+ fi
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Passo 1: Analisar Request
24
+
25
+ Identificar em $ARGUMENTS:
26
+ - Feature solicitada
27
+ - Termos-chave para busca
28
+ - Area provavel (api/, components/, services/)
29
+
30
+ ---
31
+
32
+ ## Passo 2: Buscar Contexto
33
+
34
+ ### 2.1 Memory (sob demanda)
35
+ ```
36
+ mcp__memory__search_nodes({ query: "<termos-da-feature>" })
37
+ ```
38
+
39
+ ### 2.2 Codebase
40
+ ```
41
+ Grep: termos em <area>/
42
+ Read: arquivos diretamente relacionados
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Passo 3: Reflexao (ST)
48
+
49
+ Usar `mcp__sequential-thinking__sequentialthinking`:
50
+
51
+ 1. **O que descobri** - Sintese do contexto
52
+ 2. **O que ainda posso descobrir** - Gaps que consigo preencher
53
+ 3. **Qual o MVP?** - Escopo MINIMO que resolve
54
+ 4. **O que APENAS o user sabe** - Decisoes de produto
55
+ 5. **Perguntas minimas para o user** - So o essencial
56
+
57
+ `totalThoughts`: 5
58
+
59
+ ---
60
+
61
+ ## Passo 4: Perguntas ao User (AUQ)
62
+
63
+ Usar `AskUserQuestion` com 2-4 perguntas consolidadas.
64
+
65
+ **Perguntas tipicas (adaptar):**
66
+ - **Problema**: Qual problema resolve? (Eficiencia/Funcionalidade/UX)
67
+ - **Escopo**: MVP ou feature completa?
68
+ - **Design**: Referencia ou patterns existentes?
69
+ - **Prioridade**: O que e mais importante?
70
+
71
+ ```javascript
72
+ AskUserQuestion({
73
+ questions: [
74
+ {
75
+ question: "Qual problema principal esta feature resolve?",
76
+ header: "Problema",
77
+ options: [
78
+ { label: "Eficiencia", description: "Automatizar/acelerar processo" },
79
+ { label: "Funcionalidade", description: "Adicionar capacidade nova" },
80
+ { label: "UX", description: "Melhorar experiencia existente" }
81
+ ],
82
+ multiSelect: false
83
+ },
84
+ // ... outras perguntas
85
+ ]
86
+ })
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Passo 5: Criterios de Aceite (AUQ)
92
+
93
+ Coletar do user como validar sucesso/falha:
94
+
95
+ ```javascript
96
+ AskUserQuestion({
97
+ questions: [
98
+ {
99
+ question: "Como voce saberia que esta funcionando?",
100
+ header: "Validacao",
101
+ options: [
102
+ { label: "Output especifico", description: "Retorna X, exibe Y na tela" },
103
+ { label: "Side effect", description: "Salva no DB, posta na rede social" },
104
+ { label: "Ausencia de erro", description: "Nao quebra, nao loga erro" }
105
+ ],
106
+ multiSelect: true
107
+ },
108
+ {
109
+ question: "O que seria uma falha inaceitavel?",
110
+ header: "Falha Critica",
111
+ options: [
112
+ { label: "Dados corrompidos", description: "Salva errado, perde dados" },
113
+ { label: "Erro silencioso", description: "Falha sem avisar user" },
114
+ { label: "Acao duplicada", description: "Posta 2x, cobra 2x" }
115
+ ],
116
+ multiSelect: true
117
+ }
118
+ ]
119
+ })
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Passo 6: Persistir Interview
125
+
126
+ ### 6.1 Gerar slug
127
+ `{primeira-palavra}-{YYYY-MM-DD}.md`
128
+
129
+ ### 6.2 Salvar
130
+ ```
131
+ Write .claude/interviews/{slug}.md
132
+ ```
133
+
134
+ ### 6.3 Formato
135
+ ```markdown
136
+ # Interview: {feature}
137
+
138
+ ## Request (Passo 1)
139
+ - **Feature:** {$ARGUMENTS}
140
+ - **Area:** {api/components/services}
141
+ - **Termos-chave:** {lista}
142
+
143
+ ## Descoberta (Passo 2)
144
+ - **Services:** {lista}
145
+ - **Patterns:** {lista}
146
+ - **Memory:** {entidades relevantes ou "N/A"}
147
+
148
+ ## Reflexao (Passo 3)
149
+ - **Escopo:** {MVP | Completo}
150
+ - **Decisoes Implicitas:**
151
+ | Decisao | Justificativa |
152
+ |---------|---------------|
153
+ | {o que assumiu} | {por que} |
154
+
155
+ ## Perguntas e Respostas (Passo 4)
156
+ | # | Pergunta | Resposta | Impacto |
157
+ |---|----------|----------|---------|
158
+
159
+ ## Criterios de Aceite do User (Passo 5)
160
+ | # | Criterio | Tipo | Verificacao |
161
+ |---|----------|------|-------------|
162
+ | U1 | "{criterio especifico}" | SUCESSO | {output/side-effect/ausencia} |
163
+ | U2 | "{criterio especifico}" | FALHA | {o que NAO pode acontecer} |
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Gate (BLOQUEANTE)
169
+
170
+ ```bash
171
+ SLUG=$(jq -r '.feature' .claude/workflow-state.json 2>/dev/null)
172
+ [ -z "$SLUG" ] || [ "$SLUG" = "null" ] && { echo "❌ workflow-state.json sem feature definida"; exit 1; }
173
+
174
+ INTERVIEW=".claude/interviews/${SLUG}.md"
175
+
176
+ test -f "$INTERVIEW" || { echo "❌ Interview não encontrada: $INTERVIEW"; exit 1; }
177
+
178
+ # Seções obrigatórias (ordem do fluxo)
179
+ grep -q "## Request" "$INTERVIEW" || { echo "❌ Interview sem Request"; exit 1; }
180
+ grep -q "## Descoberta" "$INTERVIEW" || { echo "❌ Interview sem Descoberta"; exit 1; }
181
+ grep -q "## Perguntas e Respostas" "$INTERVIEW" || { echo "❌ Interview sem Q&A"; exit 1; }
182
+ grep -q "## Criterios de Aceite do User" "$INTERVIEW" || { echo "❌ Interview sem Criterios"; exit 1; }
183
+
184
+ # Validar que Critérios tem conteúdo (não apenas header)
185
+ grep -A1 "## Criterios de Aceite do User" "$INTERVIEW" | grep -q "| U" || { echo "❌ Criterios sem entradas (precisa U1, U2...)"; exit 1; }
186
+
187
+ echo "✅ Gate 01-understand passou"
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Passo 7: Persistir Estado do Workflow
193
+
194
+ ```bash
195
+ mkdir -p .claude
196
+ cat > .claude/workflow-state.json << 'EOF'
197
+ {
198
+ "workflow": "feature",
199
+ "feature": "${FEATURE_SLUG}",
200
+ "currentPhase": "02-analyze",
201
+ "completedPhases": ["01-understand"],
202
+ "startedAt": "${TIMESTAMP}",
203
+ "resumeHint": "Interview coletada. Prox: triage tipo (api/ui/service/job) e carregar playbook",
204
+ "lastStep": "Passo 7: Persistir Estado",
205
+ "interview": ".claude/interviews/${FEATURE_SLUG}.md",
206
+ "analysis": null,
207
+ "contract": null
208
+ }
209
+ EOF
210
+ ```
211
+
212
+ **Nota:** Substituir `${FEATURE_SLUG}` pelo slug real e `${TIMESTAMP}` por `date -u +%Y-%m-%dT%H:%M:%SZ`
213
+
214
+ ---
215
+
216
+ ## PROXIMA FASE
217
+ ACAO OBRIGATORIA: Read ~/.claude/commands/feature/02-analyze.md
@@ -0,0 +1,168 @@
1
+ # Fase 2: Analyze
2
+
3
+ ## Responsabilidade
4
+ Explorar codebase e determinar estrategia de teste. Fase INTERNA (sem interacao com user).
5
+
6
+ ---
7
+
8
+ ## Passo 1: Triage de Tipo
9
+
10
+ Analisar feature e classificar:
11
+
12
+ | Keyword | Tipo | Playbook |
13
+ |---------|------|----------|
14
+ | endpoint, handler, route, API | api | playbooks/api/ |
15
+ | component, page, form, modal, hook | ui | playbooks/ui/ |
16
+ | service, util, transform, validate | service | playbooks/service/ |
17
+ | cron, job, scheduler, executor | job | playbooks/job/ |
18
+
19
+ **SE multiplos tipos:** Escolher o DOMINANTE (onde maior parte do codigo ficara).
20
+
21
+ ---
22
+
23
+ ## Passo 2: Carregar Playbook
24
+
25
+ ```
26
+ Read ~/.claude/commands/feature/playbooks/{tipo}/analyze.md
27
+ ```
28
+
29
+ O playbook define:
30
+ - Onde codigo fica
31
+ - Pattern de producao
32
+ - Criterios de testabilidade
33
+
34
+ ---
35
+
36
+ ## Passo 3: Buscar Codigo Existente
37
+
38
+ ### 3.1 Patterns Similares
39
+ ```
40
+ Grep: termos em {localizacao-do-playbook}/
41
+ ```
42
+
43
+ ### 3.2 Codigo Reutilizavel
44
+ | Necessidade | Codigo Existente | Acao |
45
+ |-------------|------------------|------|
46
+ | [o que precisa] | [arquivo:linha] | Reutilizar/Estender/Criar |
47
+
48
+ ---
49
+
50
+ ## Passo 4: Mapear Mocks
51
+
52
+ ### 4.1 Consultar Existentes
53
+ ```
54
+ Read test-utils/mocks/README.md
55
+ ```
56
+
57
+ ### 4.2 Verificar Disponibilidade
58
+ | Servico | Mock Existe? | Acao |
59
+ |---------|--------------|------|
60
+ | Database | Verificar | - |
61
+ | [externo] | Verificar | Criar se necessario |
62
+
63
+ ---
64
+
65
+ ## Passo 5: Avaliar Testabilidade
66
+
67
+ Baseado no playbook carregado:
68
+
69
+ | Tipo Teste | Requerido? | Motivo |
70
+ |------------|------------|--------|
71
+ | Unit | {do playbook} | {motivo} |
72
+ | Integration | {do playbook} | {motivo} |
73
+ | E2E | {do playbook} | {motivo} |
74
+
75
+ ---
76
+
77
+ ## Passo 6: Cenarios Tecnicos Descobertos
78
+
79
+ Baseado na exploracao (Passos 3-5), identificar cenarios de falha EVIDENTES no codigo.
80
+
81
+ ### 6.1 Analise do Codigo Existente
82
+
83
+ Para cada dependencia/input encontrado, verificar:
84
+ - Existe tratamento de erro? (try/catch, .catch, fallback)
85
+ - Existe validacao? (Zod, type guards)
86
+ - Existe retry/circuit breaker?
87
+
88
+ ### 6.2 Documentar Cenarios
89
+
90
+ | # | Cenario | Categoria | Fonte | Tratado? |
91
+ |---|---------|-----------|-------|----------|
92
+ | T1 | {cenario evidente} | {INPUT/DEPENDENCY/STATE} | {arquivo:linha} | Sim/Nao |
93
+
94
+ **Categorias**: INPUT, DEPENDENCY, STATE, ENVIRONMENT
95
+
96
+ > **Regra:** Documentar APENAS cenarios EVIDENTES do codigo.
97
+
98
+ ---
99
+
100
+ ## Passo 7: Persistir Analise
101
+
102
+ ### 7.1 Salvar
103
+ ```
104
+ Write .claude/analysis/{slug}.md
105
+ ```
106
+
107
+ ### 7.2 Formato
108
+ ```markdown
109
+ # Analise: {feature}
110
+
111
+ ## Metadata
112
+ - **Tipo:** {api/ui/service/job}
113
+ - **Playbook:** {arquivo}
114
+
115
+ ## Mocks Mapeados
116
+ | Servico | Existe? | Acao |
117
+ |---------|---------|------|
118
+
119
+ ## Testes Existentes
120
+ | Pattern | Arquivos |
121
+ |---------|----------|
122
+
123
+ ## Cenarios Tecnicos Descobertos
124
+ | # | Cenario | Categoria | Fonte | Tratado? |
125
+ |---|---------|-----------|-------|----------|
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Gate (BLOQUEANTE)
131
+
132
+ ```bash
133
+ SLUG=$(jq -r '.feature' .claude/workflow-state.json 2>/dev/null)
134
+
135
+ # Pré-condição
136
+ test -f ".claude/interviews/${SLUG}.md" || { echo "❌ Pré-condição falhou: interview não existe"; exit 1; }
137
+
138
+ # Pós-condição
139
+ test -f ".claude/analysis/${SLUG}.md" || { echo "❌ Análise não encontrada: .claude/analysis/${SLUG}.md"; exit 1; }
140
+ grep -q "## Metadata" ".claude/analysis/${SLUG}.md" || { echo "❌ Análise incompleta (falta Metadata)"; exit 1; }
141
+
142
+ echo "✅ Gate 02-analyze passou"
143
+ ```
144
+
145
+ **Nota:** Esta fase NAO para. Execução automática para 03-strategy.
146
+
147
+ ---
148
+
149
+ ## Passo 8: Atualizar Estado do Workflow
150
+
151
+ ```bash
152
+ if command -v jq &> /dev/null; then
153
+ jq '
154
+ .currentPhase = "03-strategy" |
155
+ .completedPhases += ["02-analyze"] |
156
+ .resumeHint = "Analise completa. Prox: apresentar testes propostos para aprovacao (UNICA parada)" |
157
+ .lastStep = "Passo 8: Atualizar Estado" |
158
+ .analysis = (".claude/analysis/" + .feature + ".md")
159
+ ' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
160
+ else
161
+ echo "Atualizar .claude/workflow-state.json: currentPhase=03-strategy, add 02-analyze to completedPhases"
162
+ fi
163
+ ```
164
+
165
+ ---
166
+
167
+ ## PROXIMA FASE
168
+ ACAO OBRIGATORIA: Read ~/.claude/commands/feature/03-strategy.md
@@ -0,0 +1,300 @@
1
+ # Fase 3: Strategy
2
+
3
+ ## Responsabilidade
4
+ Aprovar estrategia de testes. **UNICA APROVACAO** do workflow.
5
+
6
+ ---
7
+
8
+ ## Passo 1: Carregar Inputs
9
+
10
+ ### 1.1 Criterios do User (01-understand)
11
+ ```
12
+ Read .claude/interviews/${SLUG}.md → secao "## Criterios de Aceite do User"
13
+ ```
14
+
15
+ ### 1.2 Cenarios Tecnicos (02-analyze)
16
+ ```
17
+ Read .claude/analysis/${SLUG}.md → secao "## Cenarios Tecnicos Descobertos"
18
+ ```
19
+
20
+ ### 1.3 Tipo da Feature
21
+ ```
22
+ Read .claude/workflow-state.json → campo "featureType" (api/ui/service/job)
23
+ ```
24
+
25
+ > **Razao:** Garante que dados estao em contexto antes de qualquer processamento.
26
+
27
+ ---
28
+
29
+ ## Passo 2: Transformar Criterios do User
30
+
31
+ Converter criterios em cenarios testaveis:
32
+
33
+ | Criterio User | Cenario Derivado | Tipo |
34
+ |---------------|------------------|------|
35
+ | "funciona se X" | "X acontece" | SUCESSO |
36
+ | "falha se Y" | "Y nao acontece" | FALHA |
37
+
38
+ > **Razao:** Normaliza linguagem do user para linguagem de teste.
39
+
40
+ ---
41
+
42
+ ## Passo 3: Complementar com Failure Analysis
43
+
44
+ ```
45
+ Read ~/.claude/techniques/failure-analysis.md
46
+ ```
47
+
48
+ Executar APENAS para categorias NAO cobertas por interview + analysis.
49
+ Budget: max 3-5 cenarios ADICIONAIS.
50
+
51
+ > **Razao:** Pega edge cases que user e analise tecnica podem ter perdido.
52
+
53
+ ---
54
+
55
+ ## Passo 4: Opcoes de Validacao E2E
56
+
57
+ Baseado no tipo da feature, identificar opcoes viaveis:
58
+
59
+ | Tipo Feature | E2E Padrao | Alternativa |
60
+ |--------------|------------|-------------|
61
+ | ui | Playwright (auto) | hybrid |
62
+ | api | API script (semi-auto) | hybrid |
63
+ | service | Integration test (auto) | hybrid |
64
+ | job | hybrid | semi-auto |
65
+
66
+ Registrar:
67
+ - **Opcao recomendada:** {tipo}
68
+ - **Opcoes alternativas:** {lista}
69
+ - **Custo/beneficio de cada:** {breve}
70
+
71
+ > **Razao:** ST precisa conhecer opcoes E2E para decidir se vale incluir.
72
+ > Ver: `~/.claude/commands/feature/playbooks/_e2e-base.md` + `playbooks/{tipo}/e2e.md`
73
+
74
+ ---
75
+
76
+ ## Passo 5: Tabela Unificada de Cenarios
77
+
78
+ Consolidar TODOS os cenarios com fonte e score:
79
+
80
+ | # | Cenario | Fonte | Nivel | Score | Decisao |
81
+ |---|---------|-------|-------|-------|---------|
82
+ | U1 | "{do user}" | interview | Integration | - | TESTAR |
83
+ | T1 | "{do codigo}" | analysis | Unit | {PxI} | ? |
84
+ | FA1 | "{failure analysis}" | technique | Unit | {PxI} | ? |
85
+ | E2E1 | "{fluxo completo}" | e2e-option | E2E | - | ? |
86
+
87
+ **Coluna Nivel:** Unit | Integration | E2E
88
+ **Coluna Decisao:** Preenchida no Passo 6 (ST)
89
+
90
+ **Regras:**
91
+ - Fonte "interview" → SEMPRE TESTAR (criterio do user)
92
+ - Fonte "analysis/technique" → Aplicar P×I (Score >= 6 = TESTAR)
93
+ - Fonte "e2e-option" → Decidido no Passo 6
94
+
95
+ > **Razao:** Visao completa de TODAS as opcoes de teste antes da reflexao.
96
+
97
+ ---
98
+
99
+ ## Passo 6: Reflexao e Decisao (ST)
100
+
101
+ Usar `mcp__sequential-thinking__sequentialthinking`:
102
+
103
+ 1. **Inventario completo** - Quantos cenarios tenho? De que fontes?
104
+ 2. **Cobertura por nivel** - Quantos Unit vs Integration vs E2E?
105
+ 3. **Criterios do user** - Todos estao cobertos? Como?
106
+ 4. **Cenarios tecnicos** - Quais tem Score >= 6? Quais < 6?
107
+ 5. **E2E vale a pena?** - Custo vs beneficio para esta feature
108
+ 6. **Decisao final** - Para cada cenario: TESTAR ou NAO TESTAR
109
+ 7. **Justificativa** - Por que cada decisao? Mitigacao para excluidos?
110
+
111
+ `totalThoughts`: 7
112
+
113
+ **Output:** Tabela Unificada com coluna "Decisao" preenchida
114
+
115
+ > **Razao:** ST agora tem TODOS os dados para decidir estrategia completa.
116
+
117
+ ---
118
+
119
+ ## Passo 7: Montar Proposta Unica
120
+
121
+ Apresentar decisao consolidada:
122
+
123
+ ```markdown
124
+ ### Testes que serao implementados
125
+
126
+ | # | Cenario | Fonte | Nivel | Teste |
127
+ |---|---------|-------|-------|-------|
128
+ | U1 | "{criterio user}" | interview | Integration | `it('...')` |
129
+ | T1 | "{cenario tecnico}" | analysis | Unit | `it('...')` |
130
+ | E2E1 | "{fluxo completo}" | e2e-option | E2E | `test('...')` |
131
+
132
+ ### Cenarios NAO testados (com justificativa)
133
+
134
+ | # | Cenario | Score | Justificativa | Mitigacao | Arquivo |
135
+ |---|---------|-------|---------------|-----------|---------|
136
+ | FA2 | "{edge case}" | 4 | Baixa probabilidade | try/catch | handler.ts:45 |
137
+
138
+ ### E2E Validation Spec
139
+
140
+ **Tipo:** {auto | semi-auto | hybrid}
141
+
142
+ {SE auto}
143
+ **Script/Ferramenta:** {playwright | functional-validator | integration test}
144
+ **Cenario:** {Given/When/Then}
145
+ **Comando:** `{npm run test:e2e ou similar}`
146
+
147
+ {SE semi-auto}
148
+ **Trigger:** {POST /api/endpoint ou comando}
149
+ **Verificacoes do Claude:**
150
+ - [ ] Response status/body esperado
151
+ - [ ] Query DB: `{collection}.where(...)`
152
+ - [ ] Verificar logs: `grep "{pattern}"`
153
+
154
+ {SE hybrid}
155
+ **Acao do User:**
156
+ - [ ] {descricao detalhada do que user deve fazer}
157
+
158
+ **Verificacoes do Claude:**
159
+ - [ ] Query DB: `{collection/table}.where(...)`
160
+ - [ ] Verificar logs: `grep "{pattern}"`
161
+ - [ ] Confirmar side effect: `GET /api/{endpoint}`
162
+
163
+ **Criterio de Sucesso:**
164
+ - [ ] {condicao verificavel}
165
+
166
+ ### Resumo da Estrategia
167
+
168
+ - **Unit tests:** {N} cenarios
169
+ - **Integration tests:** {N} cenarios
170
+ - **E2E:** {SIM/NAO} - {justificativa}
171
+ - **Cobertura dos criterios do user:** 100%
172
+ ```
173
+
174
+ > **Razao:** User ve proposta unica e completa, nao fragmentada.
175
+
176
+ ---
177
+
178
+ ## Passo 8: Aprovacao (AUQ)
179
+
180
+ ```javascript
181
+ AskUserQuestion({
182
+ questions: [{
183
+ question: "Esses testes cobrem suas necessidades?",
184
+ header: "Aprovacao",
185
+ options: [
186
+ { label: "Sim, cobrem", description: "Prosseguir com implementacao autonoma" },
187
+ { label: "Falta cenario", description: "Vou descrever o que falta" },
188
+ { label: "Mudar E2E", description: "Quero mudar a estrategia E2E" },
189
+ { label: "Mudar tipo", description: "Prefiro outro tipo de teste" }
190
+ ],
191
+ multiSelect: false
192
+ }]
193
+ })
194
+ ```
195
+
196
+ ### SE "Falta cenario" ou "Mudar tipo":
197
+ 1. Coletar feedback
198
+ 2. Ajustar proposta
199
+ 3. Repetir aprovacao
200
+
201
+ ### SE "Mudar E2E":
202
+ 1. Apresentar alternativas E2E do Passo 4
203
+ 2. Ajustar spec E2E
204
+ 3. Confirmar e prosseguir
205
+
206
+ ---
207
+
208
+ ## Passo 9: Gerar Contract Lock
209
+
210
+ Apos aprovacao, gerar contrato IMUTAVEL.
211
+
212
+ ### 9.1 Salvar Contract
213
+ ```
214
+ Write .claude/contracts/{slug}.md
215
+ ```
216
+
217
+ ### 9.2 Formato
218
+ ```markdown
219
+ # Contract: {feature}
220
+
221
+ **Status:** LOCKED
222
+ **Aprovado em:** {YYYY-MM-DD HH:MM}
223
+
224
+ ## Cenarios de Falha (Brainstorm)
225
+
226
+ | # | Cenario | Categoria | P | I | Score | Decisao |
227
+ |---|---------|-----------|---|---|-------|---------|
228
+ | 1 | {cenario} | INPUT | Alta | Alto | 9 | TESTAR |
229
+ | 2 | {cenario} | DEPENDENCY | Média | Alto | 6 | TESTAR |
230
+ | 3 | {cenario} | STATE | Baixa | Alto | 3 | MITIGAR |
231
+
232
+ ## Criterios Aprovados (Testes)
233
+
234
+ | # | Criterio | Fonte | Nivel | Cenario Ref | Teste | Status |
235
+ |---|----------|-------|-------|-------------|-------|--------|
236
+ | 1 | "[criterio do user]" | interview | Integration | - | `it('...')` | LOCKED |
237
+ | 2 | "[cenario tecnico]" | analysis | Unit | #T1 | `it('...')` | LOCKED |
238
+
239
+ ## Cenarios Excluidos (com Justificativa)
240
+
241
+ | # | Cenario Ref | Score | Por que NAO testar | Mitigacao | Arquivo |
242
+ |---|-------------|-------|--------------------|-----------|---------|
243
+ | 3 | #3 | 3 | {justificativa} | {mitigacao} | {arquivo:linha} |
244
+
245
+ ## E2E Validation
246
+
247
+ **Tipo:** {auto | semi-auto | hybrid}
248
+ **Status:** PENDING
249
+
250
+ {spec completa conforme Passo 7}
251
+
252
+ ## IMUTABILIDADE
253
+
254
+ > Mudanca de escopo requer nova aprovacao e re-geracao do contract.
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Gate (BLOQUEANTE)
260
+
261
+ ```bash
262
+ SLUG=$(jq -r '.feature' .claude/workflow-state.json 2>/dev/null)
263
+
264
+ # Pré-condições
265
+ test -f ".claude/interviews/${SLUG}.md" || { echo "❌ Pré: interview não existe"; exit 1; }
266
+ test -f ".claude/analysis/${SLUG}.md" || { echo "❌ Pré: analysis não existe"; exit 1; }
267
+
268
+ # Pós-condição: Contract
269
+ test -f ".claude/contracts/${SLUG}.md" || { echo "❌ Contract não encontrado: .claude/contracts/${SLUG}.md"; exit 1; }
270
+ grep -q "## Criterios Aprovados" ".claude/contracts/${SLUG}.md" || { echo "❌ Contract sem critérios aprovados"; exit 1; }
271
+ grep -q "## E2E Validation" ".claude/contracts/${SLUG}.md" || { echo "❌ Contract sem E2E Validation spec"; exit 1; }
272
+ grep -q "**Status:** LOCKED" ".claude/contracts/${SLUG}.md" || { echo "❌ Contract não está LOCKED"; exit 1; }
273
+
274
+ echo "✅ Gate 03-strategy passou"
275
+ ```
276
+
277
+ **IMPORTANTE:** Esta é a ÚNICA parada do workflow. Após aqui, execução é AUTÔNOMA.
278
+
279
+ ---
280
+
281
+ ## Passo 10: Atualizar Estado do Workflow
282
+
283
+ ```bash
284
+ if command -v jq &> /dev/null; then
285
+ jq '
286
+ .currentPhase = "04-red" |
287
+ .completedPhases += ["03-strategy"] |
288
+ .resumeHint = "Testes APROVADOS. Prox: escrever testes RED, executar autonomamente" |
289
+ .lastStep = "Passo 10: Atualizar Estado" |
290
+ .contract = (".claude/contracts/" + .feature + ".md")
291
+ ' .claude/workflow-state.json > .claude/workflow-state.tmp && mv .claude/workflow-state.tmp .claude/workflow-state.json
292
+ else
293
+ echo "Atualizar .claude/workflow-state.json: currentPhase=04-red, add 03-strategy to completedPhases"
294
+ fi
295
+ ```
296
+
297
+ ---
298
+
299
+ ## PROXIMA FASE
300
+ ACAO OBRIGATORIA: Read ~/.claude/commands/feature/04-red.md