kakaroto-config 1.0.0 → 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.
- package/README.md +122 -16
- package/bin/install.js +27 -5
- package/bin/release.js +255 -0
- package/config/ARCHITECTURE.md +3 -1
- package/config/CLAUDE.md +4 -0
- package/config/agents/memory-sync.md +87 -19
- package/config/agents/test-fixer.md +24 -0
- package/config/agents/visual-validator.md +17 -0
- package/config/commands/debug/01-reproduce.md +120 -0
- package/config/commands/debug/02-investigate.md +93 -0
- package/config/commands/debug/03-fix.md +110 -0
- package/config/commands/debug/04-verify.md +155 -0
- package/config/commands/debug/05-commit.md +106 -0
- package/config/commands/debug/06-evaluate.md +137 -0
- package/config/commands/debug/playbooks/api.md +21 -0
- package/config/commands/debug/playbooks/backend.md +19 -0
- package/config/commands/debug/playbooks/infra.md +130 -0
- package/config/commands/debug/playbooks/integration.md +16 -0
- package/config/commands/debug/playbooks/job.md +19 -0
- package/config/commands/debug/playbooks/test.md +14 -0
- package/config/commands/debug/playbooks/ui.md +24 -0
- package/config/commands/debug/self-healing.md +99 -0
- package/config/commands/debug/techniques/flow-tracing.md +75 -0
- package/config/commands/debug/techniques/hypothesis-generation.md +30 -0
- package/config/commands/debug/techniques/sequential-thinking-config.md +79 -0
- package/config/commands/debug/templates/diagnosis-script.md +72 -0
- package/config/commands/debug/templates/reproduction-doc.md +60 -0
- package/config/commands/debug/templates/root-cause-doc.md +46 -0
- package/config/commands/debug/validators/criticality-gate.md +40 -0
- package/config/commands/debug/validators/evidence-requirements.md +48 -0
- package/config/commands/debug/validators/fix-permanence.md +56 -0
- package/config/commands/debug/validators/root-cause-validation.md +50 -0
- package/config/commands/debug.md +3 -3
- package/config/commands/feature/01-interview.md +82 -90
- package/config/commands/feature/02-spec.md +22 -98
- package/config/commands/feature/03-planner.md +81 -4
- package/config/commands/feature/04-implement.md +15 -8
- package/config/commands/feature/05-quality.md +23 -5
- package/config/commands/feature/06-commit.md +91 -0
- package/config/commands/feature/07-evaluate.md +129 -0
- package/config/commands/feature.md +1 -7
- package/config/templates/spec-template.md +92 -0
- package/package.json +4 -1
- package/config/commands/debug/01-investigate.md +0 -119
- package/config/commands/debug/02-fix.md +0 -108
- package/config/commands/debug/03-verify.md +0 -66
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Fase 6: Auto-Avaliacao
|
|
2
|
+
|
|
3
|
+
## Contexto
|
|
4
|
+
Fix commitado. Avaliar workflow de debug e propor melhorias ao config.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Passo 1: Coletar Metricas
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
git diff --stat HEAD~1
|
|
12
|
+
git log -1 --format="%s"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Ler (se existirem):
|
|
16
|
+
- .claude/debug/reproduction.md (como bug foi reproduzido)
|
|
17
|
+
- Arquivos modificados pelo fix
|
|
18
|
+
|
|
19
|
+
Coletar:
|
|
20
|
+
- Arquivos modificados
|
|
21
|
+
- Linhas adicionadas/removidas
|
|
22
|
+
- Testes de regressao criados
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Passo 2: Sequential Thinking #1 - DIAGNOSTICO
|
|
27
|
+
|
|
28
|
+
Usar mcp__sequential-thinking__sequentialthinking para:
|
|
29
|
+
|
|
30
|
+
**Objetivo:** Identificar problemas no processo de debug
|
|
31
|
+
|
|
32
|
+
### 2.1 Avaliar Criterios (0-100%)
|
|
33
|
+
|
|
34
|
+
| Criterio | Peso | Como Medir |
|
|
35
|
+
|----------|------|------------|
|
|
36
|
+
| Reproducao | 25% | Bug foi reproduzido de forma confiavel? |
|
|
37
|
+
| Root Cause | 25% | 5 Whys chegou na causa raiz real? |
|
|
38
|
+
| Fix Minimal | 20% | Fix foi minimo e cirurgico? Sem over-engineering? |
|
|
39
|
+
| Regressao | 15% | Teste de regressao foi criado? |
|
|
40
|
+
| Permanencia | 10% | Fix sobrevive restart/deploy? |
|
|
41
|
+
| Autonomia | 5% | Quantas perguntas ao user? (ideal: <=2) |
|
|
42
|
+
|
|
43
|
+
### 2.2 Para Criterios < 80%: Aplicar 5 Whys
|
|
44
|
+
|
|
45
|
+
1. Por que o score foi baixo?
|
|
46
|
+
2. Qual foi a causa raiz do problema no processo?
|
|
47
|
+
3. O que poderia ter prevenido?
|
|
48
|
+
4. Que informacao/regra faltou no skill?
|
|
49
|
+
5. Onde essa informacao deveria estar?
|
|
50
|
+
|
|
51
|
+
**Output esperado:** Lista de {problema, causa_raiz, local_ideal}
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Passo 3: Sequential Thinking #2 - SINTESE
|
|
56
|
+
|
|
57
|
+
Usar mcp__sequential-thinking__sequentialthinking novamente:
|
|
58
|
+
|
|
59
|
+
**Objetivo:** Transformar diagnosticos em mudancas acionaveis
|
|
60
|
+
|
|
61
|
+
Para cada problema identificado no Passo 2:
|
|
62
|
+
|
|
63
|
+
1. **Tipo de mudanca?**
|
|
64
|
+
- Config: Regra no CLAUDE.md
|
|
65
|
+
- Skill: Gate/validacao em fase de debug
|
|
66
|
+
- Playbook: Adicionar ao playbook de categoria
|
|
67
|
+
|
|
68
|
+
2. **Qual arquivo editar?**
|
|
69
|
+
- ~/.claude/CLAUDE.md
|
|
70
|
+
- ~/.claude/commands/debug/*.md
|
|
71
|
+
|
|
72
|
+
3. **Diff exato da mudanca?**
|
|
73
|
+
- Escrever o texto exato a adicionar
|
|
74
|
+
|
|
75
|
+
4. **Efeitos colaterais?**
|
|
76
|
+
- Vai afetar outros tipos de bug?
|
|
77
|
+
- Pode causar falsos positivos?
|
|
78
|
+
|
|
79
|
+
5. **Prioridade?**
|
|
80
|
+
- Alta: Bug similar pode acontecer novamente
|
|
81
|
+
- Media: Melhoria de processo
|
|
82
|
+
- Baixa: Nice-to-have
|
|
83
|
+
|
|
84
|
+
**Output esperado:** Lista de {tipo, arquivo, diff_sugerido, prioridade}
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Passo 4: Propor Melhorias ao Usuario
|
|
89
|
+
|
|
90
|
+
Para cada melhoria identificada (MAXIMO 3 por execucao):
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
AskUserQuestion({
|
|
94
|
+
questions: [{
|
|
95
|
+
question: "Detectei: {problema no processo}. Causa: {causa_raiz}. Sugiro adicionar em {arquivo}: '{diff}'. Aplicar?",
|
|
96
|
+
header: "Melhoria",
|
|
97
|
+
options: [
|
|
98
|
+
{ label: "Aplicar", description: "Editar {arquivo} com a mudanca sugerida" },
|
|
99
|
+
{ label: "Ignorar", description: "Pular desta vez, pode sugerir novamente" },
|
|
100
|
+
{ label: "Nunca sugerir", description: "Adicionar excecao permanente" }
|
|
101
|
+
],
|
|
102
|
+
multiSelect: false
|
|
103
|
+
}]
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Acoes por Resposta:
|
|
108
|
+
- **Aplicar:** Usar Edit tool para modificar arquivo
|
|
109
|
+
- **Ignorar:** Prosseguir sem acao
|
|
110
|
+
- **Nunca sugerir:** Adicionar em ~/.claude/evaluation-exceptions.json
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Passo 5: Finalizar
|
|
115
|
+
|
|
116
|
+
Reportar ao user:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
## Avaliacao do Workflow de Debug
|
|
120
|
+
|
|
121
|
+
**Score Final:** X% (Reproducao: X%, Root Cause: X%, Fix: X%, Regressao: X%, Permanencia: X%, Autonomia: X%)
|
|
122
|
+
|
|
123
|
+
**Melhorias Aplicadas:** N
|
|
124
|
+
- [lista de mudancas aplicadas]
|
|
125
|
+
|
|
126
|
+
**Workflow /debug concluido.**
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Regras Inviolaveis
|
|
132
|
+
|
|
133
|
+
1. **SEMPRE** executar apos commit bem-sucedido
|
|
134
|
+
2. **NUNCA** aplicar mudanca sem aprovacao explicita do user
|
|
135
|
+
3. **MAXIMO** 3 sugestoes por execucao (evitar decision fatigue)
|
|
136
|
+
4. **PRIORIZAR** problemas de alta prioridade primeiro
|
|
137
|
+
5. **NAO** sugerir mudancas se score >= 90% em todos criterios
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Playbook: API/Endpoint
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Identificar** handler em `api/handlers/` (ja feito em exploracao basica)
|
|
6
|
+
|
|
7
|
+
2. **Subir servidor** em background:
|
|
8
|
+
```bash
|
|
9
|
+
npm run dev &
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
3. **Request** com inputs do bug:
|
|
13
|
+
```bash
|
|
14
|
+
curl -X POST http://localhost:{port}/api/{endpoint} \
|
|
15
|
+
-H "Content-Type: application/json" \
|
|
16
|
+
-d '{"input": "valor"}'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
4. **Capturar** response completa (status, body)
|
|
20
|
+
|
|
21
|
+
5. **Evidencia**: Response mostrando erro ou comportamento incorreto
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Playbook: Backend/Service
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Identificar** service/funcao via Grep (ja feito em exploracao basica)
|
|
6
|
+
|
|
7
|
+
2. **Criar script** `scripts/debug-{descricao}.ts`:
|
|
8
|
+
```typescript
|
|
9
|
+
#!/usr/bin/env npx tsx
|
|
10
|
+
import { config } from 'dotenv';
|
|
11
|
+
config();
|
|
12
|
+
// Import do service
|
|
13
|
+
// Chamada com inputs do bug
|
|
14
|
+
// console.log do resultado
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. **Executar**: `npx tsx scripts/debug-{descricao}.ts`
|
|
18
|
+
|
|
19
|
+
4. **Evidencia**: Output mostrando comportamento incorreto
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Playbook: Infra/Deploy
|
|
2
|
+
|
|
3
|
+
## Fase: Reproduce
|
|
4
|
+
|
|
5
|
+
### Passos
|
|
6
|
+
|
|
7
|
+
1. **Ler arquivos de deploy ANTES de qualquer investigacao**:
|
|
8
|
+
```
|
|
9
|
+
Read terraform/deploy.sh
|
|
10
|
+
Read terraform/startup-script.sh (ou equivalente)
|
|
11
|
+
Read terraform/main.tf (locals e env vars)
|
|
12
|
+
Read terraform/modules/compute-instance/main.tf (lifecycle rules)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **Mapear ciclo de vida**:
|
|
16
|
+
- Como a VM inicia?
|
|
17
|
+
- Como env vars chegam no container?
|
|
18
|
+
- O que acontece em `/deploy`?
|
|
19
|
+
- O que acontece em `terraform apply`?
|
|
20
|
+
|
|
21
|
+
3. **Verificar logs da VM**:
|
|
22
|
+
```bash
|
|
23
|
+
gcloud compute ssh {instance} --command="sudo journalctl -u google-startup-scripts -n 100"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
4. **Verificar container**:
|
|
27
|
+
```bash
|
|
28
|
+
gcloud compute ssh {instance} --command="sudo docker logs social-medias --tail 50"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
5. **Evidencia**: Log mostrando erro de startup ou env var faltando
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Fase: Investigate
|
|
36
|
+
|
|
37
|
+
### Mapeamento de Ciclo de Vida
|
|
38
|
+
|
|
39
|
+
#### Diagrama de Fluxo
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
CICLO DE VIDA DO BUG:
|
|
43
|
+
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
44
|
+
│ terraform │ --> │ startup script │ --> │ container │
|
|
45
|
+
│ (define vars) │ │ (aplica vars) │ │ (usa vars) │
|
|
46
|
+
└─────────────────┘ └──────────────────┘ └─────────────────┘
|
|
47
|
+
│ │ │
|
|
48
|
+
v v v
|
|
49
|
+
Quando muda? Quando executa? Quando reinicia?
|
|
50
|
+
[resposta] [resposta] [resposta]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Perguntas Obrigatorias
|
|
54
|
+
|
|
55
|
+
1. **Onde o valor e definido?** (terraform, env, secret, hardcoded)
|
|
56
|
+
2. **Como o valor chega no destino?** (startup script, SCP, mount, API)
|
|
57
|
+
3. **O que dispara atualizacao?** (apply, deploy, restart, nada)
|
|
58
|
+
4. **Ha cache/ignore que bloqueia?** (ignore_changes, cache, stale)
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Fase: Verify
|
|
63
|
+
|
|
64
|
+
### Simulacao de Deploy
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Simular o que /deploy faria (sem executar de verdade)
|
|
68
|
+
cd terraform && ./deploy.sh update --dry-run
|
|
69
|
+
|
|
70
|
+
# OU se nao houver dry-run, verificar manualmente:
|
|
71
|
+
# 1. O que muda no startup script?
|
|
72
|
+
# 2. O que muda no container?
|
|
73
|
+
# 3. Env vars estao corretas?
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Teste de Permanencia
|
|
77
|
+
|
|
78
|
+
Executar UM dos seguintes (do menos ao mais destrutivo):
|
|
79
|
+
|
|
80
|
+
1. **Container restart** (rapido, sem downtime):
|
|
81
|
+
```bash
|
|
82
|
+
gcloud compute ssh {instance} --command="sudo docker restart social-medias"
|
|
83
|
+
# Verificar se bug nao retorna
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
2. **VM restart** (1-2 min downtime):
|
|
87
|
+
```bash
|
|
88
|
+
gcloud compute instances reset {instance} --zone={zone}
|
|
89
|
+
# Aguardar startup, verificar se bug nao retorna
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. **Deploy completo** (se mudancas em terraform):
|
|
93
|
+
```bash
|
|
94
|
+
./deploy.sh update
|
|
95
|
+
# Verificar se bug nao retorna
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Criterio de Sucesso
|
|
99
|
+
|
|
100
|
+
- [ ] Fix aplicado persiste apos restart escolhido
|
|
101
|
+
- [ ] Logs nao mostram o erro original
|
|
102
|
+
- [ ] Funcionalidade afetada opera normalmente
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Armadilhas de Portabilidade
|
|
107
|
+
|
|
108
|
+
Scripts podem ter comportamento diferente entre macOS e Linux.
|
|
109
|
+
|
|
110
|
+
### Padroes Problematicos (BSD vs GNU)
|
|
111
|
+
|
|
112
|
+
| GNU | BSD/POSIX | Afeta |
|
|
113
|
+
|-----|-----------|-------|
|
|
114
|
+
| `\s` | `[[:space:]]` | sed, grep |
|
|
115
|
+
| `\d` | `[0-9]` | sed, grep |
|
|
116
|
+
| `sed -i ''` (macOS) | `sed -i` (Linux) | in-place |
|
|
117
|
+
|
|
118
|
+
### Checklist de Portabilidade
|
|
119
|
+
|
|
120
|
+
SE bug envolve script executado em macOS:
|
|
121
|
+
- [ ] Scripts usam POSIX character classes?
|
|
122
|
+
- [ ] Regex funciona em GNU e BSD?
|
|
123
|
+
|
|
124
|
+
### Diagnostico
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Testar regex
|
|
128
|
+
echo "key = \"value\"" | sed 's/.*=\s*"\(.*\)"/\1/'
|
|
129
|
+
# Se retornar linha inteira: BSD nao entendeu \s
|
|
130
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Playbook: Integration
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Verificar credentials**:
|
|
6
|
+
```typescript
|
|
7
|
+
import { getSecret } from '../services/secretManagerService';
|
|
8
|
+
const token = await getSecret(accountSlug, '{type}');
|
|
9
|
+
console.log('Token existe:', !!token);
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. **Testar autenticacao** direta com API externa
|
|
13
|
+
|
|
14
|
+
3. **Verificar** token expiry, quota, rate limit
|
|
15
|
+
|
|
16
|
+
4. **Evidencia**: Erro da API externa ou credencial invalida/expirada
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Playbook: Job/Cron
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Verificar config** no Firestore:
|
|
6
|
+
```typescript
|
|
7
|
+
// Query job_configs para ver schedule
|
|
8
|
+
// Query analytics_job_executions para ver ultima execucao
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. **Criar script** ou usar existente:
|
|
12
|
+
```bash
|
|
13
|
+
npx tsx scripts/run-{job-name}.ts
|
|
14
|
+
```
|
|
15
|
+
**OU** criar `scripts/debug-{job}.ts` se nao existir
|
|
16
|
+
|
|
17
|
+
3. **SE** bug em producao: buscar logs via `.claude/debug-logs.json`
|
|
18
|
+
|
|
19
|
+
4. **Evidencia**: Logs ou output mostrando falha/comportamento incorreto
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Playbook: Test
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Rodar teste isolado**:
|
|
6
|
+
```bash
|
|
7
|
+
npm test -- --testPathPattern="{arquivo}"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Identificar** assertion que falha no output
|
|
11
|
+
|
|
12
|
+
3. **SE** necessario: adicionar console.logs temporarios
|
|
13
|
+
|
|
14
|
+
4. **Evidencia**: Stack trace com linha da assertion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Playbook: UI/Frontend
|
|
2
|
+
|
|
3
|
+
## Passos
|
|
4
|
+
|
|
5
|
+
1. **Identificar** componente (ja feito em exploracao basica)
|
|
6
|
+
|
|
7
|
+
2. **Subir dev server** em background:
|
|
8
|
+
```bash
|
|
9
|
+
npm run dev &
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
3. **Navegar** ate pagina/componente:
|
|
13
|
+
```
|
|
14
|
+
mcp__playwright__browser_navigate({ url: "http://localhost:{port}/{path}" })
|
|
15
|
+
mcp__playwright__browser_wait_for({ time: 3 })
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
4. **Capturar estado**:
|
|
19
|
+
```
|
|
20
|
+
mcp__playwright__browser_snapshot({})
|
|
21
|
+
mcp__playwright__browser_console_messages({ level: "error" })
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
5. **Evidencia**: Snapshot mostrando bug + console errors (se houver)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Self-Healing Loop
|
|
2
|
+
|
|
3
|
+
## Contexto
|
|
4
|
+
Ativado quando quality gates falham OU bug ainda reproduz OU fix nao e permanente.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Passo 1: Controle de Tentativas
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
TENTATIVA_ATUAL: {1/2/3}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**SE** tentativa > 3:
|
|
15
|
+
- PARAR imediatamente
|
|
16
|
+
- Reportar ao usuario com analise completa
|
|
17
|
+
- Documentar o que foi tentado e por que falhou
|
|
18
|
+
- NAO continuar autonomamente
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Passo 2: Analise de Falha (Sequential Thinking)
|
|
23
|
+
|
|
24
|
+
Antes de tentar corrigir, ENTENDER por que falhou:
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
mcp__sequential-thinking__sequentialthinking({
|
|
28
|
+
thought: "Analisando falha da verificacao...",
|
|
29
|
+
nextThoughtNeeded: true,
|
|
30
|
+
thoughtNumber: 1,
|
|
31
|
+
totalThoughts: 5
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Thoughts obrigatorios:
|
|
36
|
+
|
|
37
|
+
1. **"O que meu fix mudou exatamente?"**
|
|
38
|
+
- Listar arquivos e linhas modificados
|
|
39
|
+
|
|
40
|
+
2. **"O que a falha esta me dizendo?"**
|
|
41
|
+
- Se teste: qual assertion falhou?
|
|
42
|
+
- Se build: qual erro de compilacao?
|
|
43
|
+
- Se reproducao: qual sintoma persiste?
|
|
44
|
+
|
|
45
|
+
3. **"Minha causa raiz estava correta?"**
|
|
46
|
+
- Revisitar `.claude/debug/root-cause.md`
|
|
47
|
+
- A evidencia ainda se sustenta?
|
|
48
|
+
|
|
49
|
+
4. **"O que eu perdi na analise?"**
|
|
50
|
+
- Ha outro caminho de codigo afetado?
|
|
51
|
+
- Ha efeito colateral nao considerado?
|
|
52
|
+
|
|
53
|
+
5. **"Qual a proxima acao?"**
|
|
54
|
+
- Determinar para onde voltar
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Passo 3: Decision Gate
|
|
59
|
+
|
|
60
|
+
Baseado na analise, escolher UMA opcao:
|
|
61
|
+
|
|
62
|
+
| Situacao | Acao |
|
|
63
|
+
|----------|------|
|
|
64
|
+
| Fix incompleto (faltou parte) | Voltar para 03-fix, completar |
|
|
65
|
+
| Causa raiz parcial (faltou profundidade) | Voltar para 02-investigate Passo 5 |
|
|
66
|
+
| Causa raiz errada (hipotese refutada) | Voltar para 02-investigate Passo 4 |
|
|
67
|
+
| Reproducao insuficiente | Voltar para 01-reproduce |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Passo 4: Documentar Tentativa
|
|
72
|
+
|
|
73
|
+
Adicionar em `.claude/debug/attempts.md`:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
## Tentativa {N}
|
|
77
|
+
|
|
78
|
+
**Data:** {timestamp}
|
|
79
|
+
**Falha em:** Quality Gate / Reproducao / Permanencia
|
|
80
|
+
|
|
81
|
+
**O que foi tentado:**
|
|
82
|
+
{descricao do fix}
|
|
83
|
+
|
|
84
|
+
**Por que falhou:**
|
|
85
|
+
{analise via Sequential Thinking}
|
|
86
|
+
|
|
87
|
+
**Proxima acao:**
|
|
88
|
+
{para onde voltar e por que}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Passo 5: Incrementar e Continuar
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
TENTATIVA_ATUAL += 1
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Executar a acao definida no Decision Gate.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Tecnica: Rastreamento de Fluxo
|
|
2
|
+
|
|
3
|
+
Para bugs que envolvem **dados incorretos** (null, undefined, formato invalido, valor inesperado).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Passo 1: Identificar Valor Problematico
|
|
8
|
+
|
|
9
|
+
- Qual valor esta errado?
|
|
10
|
+
- Onde ele CAUSA o erro? (arquivo:linha)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Passo 2: Rastrear para Tras (Backward Tracing)
|
|
15
|
+
|
|
16
|
+
Seguir a call chain de volta ate a ORIGEM:
|
|
17
|
+
|
|
18
|
+
1. **ONDE e usado?** (ponto do erro) → arquivo:linha
|
|
19
|
+
2. **QUEM chama essa funcao?** → `Grep: "nomeDaFuncao("`
|
|
20
|
+
3. **DE ONDE vem o parametro?** → Subir na call chain
|
|
21
|
+
4. **ONDE o valor e definido/calculado?** → Continuar ate achar a ORIGEM
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Passo 3: Diagrama de Fluxo
|
|
26
|
+
|
|
27
|
+
Documentar o caminho completo:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
FLUXO DO VALOR:
|
|
31
|
+
[ORIGEM] → [transform 1] → [transform 2] → [USO/ERRO]
|
|
32
|
+
arquivo1:42 → arquivo2:108 → arquivo3:55 → arquivo4:23
|
|
33
|
+
| | | |
|
|
34
|
+
v v v v
|
|
35
|
+
[valor] [operacao] [operacao] [erro]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Passo 4: Classificacao do Bug
|
|
41
|
+
|
|
42
|
+
O bug esta em qual parte do fluxo?
|
|
43
|
+
|
|
44
|
+
- [ ] **ORIGEM**: Valor ja nasce errado (ex: input invalido, query errada)
|
|
45
|
+
- [ ] **TRANSFORMACAO**: Valor e corrompido no caminho (ex: parsing, conversao)
|
|
46
|
+
- [ ] **USO**: Valor correto usado incorretamente (ex: logica errada, condicao invertida)
|
|
47
|
+
|
|
48
|
+
**IMPORTANTE**: O fix deve ser aplicado onde o problema COMECA, nao onde ele APARECE.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Passo 4.1: SE Origem em Arquivo de Config Gerado
|
|
53
|
+
|
|
54
|
+
**SE** valor incorreto vem de arquivo de config (.env, .json, .yaml):
|
|
55
|
+
|
|
56
|
+
1. **O arquivo e GERADO ou EDITADO manualmente?**
|
|
57
|
+
- `Grep: ">.env" ou "generate_" ou "create.*config"`
|
|
58
|
+
|
|
59
|
+
2. **SE GERADO**: Rastrear processo gerador
|
|
60
|
+
- QUAL script gera o arquivo?
|
|
61
|
+
- ONDE no script o valor e definido?
|
|
62
|
+
|
|
63
|
+
3. **Diagrama Estendido**:
|
|
64
|
+
```
|
|
65
|
+
[PROCESSO] → [CONFIG] → [APP]
|
|
66
|
+
deploy.sh → .env → app.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. **Classificacao**:
|
|
70
|
+
- [ ] ORIGEM EM PROCESSO: Script gera valor errado
|
|
71
|
+
- [ ] ORIGEM EM TEMPLATE: Template tem erro
|
|
72
|
+
- [ ] TRANSFORMACAO: Script corrompe durante geracao
|
|
73
|
+
|
|
74
|
+
**IMPORTANTE**: Corrigir arquivo manualmente e PALIATIVO.
|
|
75
|
+
Fix DEVE corrigir o PROCESSO GERADOR.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Tecnica: Geracao de Hipoteses
|
|
2
|
+
|
|
3
|
+
Antes de investigar profundamente, listar MULTIPLAS causas possiveis.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Passo 1: Brainstorm (minimo 3 hipoteses)
|
|
8
|
+
|
|
9
|
+
| # | Hipotese | Probabilidade | Evidencia Inicial |
|
|
10
|
+
|---|----------|---------------|-------------------|
|
|
11
|
+
| 1 | [causa A] | Alta/Media/Baixa | [o que sugere isso] |
|
|
12
|
+
| 2 | [causa B] | Alta/Media/Baixa | [o que sugere isso] |
|
|
13
|
+
| 3 | [causa C] | Alta/Media/Baixa | [o que sugere isso] |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Passo 2: Ranking
|
|
18
|
+
|
|
19
|
+
Ordenar hipoteses por:
|
|
20
|
+
1. **Evidencia existente** (logs, reproducao, erros)
|
|
21
|
+
2. **Frequencia historica** (bugs similares ja resolvidos)
|
|
22
|
+
3. **Simplicidade** (Navalha de Occam)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Passo 3: Estrategia de Exploracao
|
|
27
|
+
|
|
28
|
+
- Comecar pela hipotese #1 no Sequential Thinking
|
|
29
|
+
- SE refutada: usar `branchFromThought` para explorar #2
|
|
30
|
+
- Registrar hipoteses descartadas e POR QUE (evita repetir)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Tecnica: Sequential Thinking para Causa Raiz
|
|
2
|
+
|
|
3
|
+
**OBRIGATORIO**: Usar `mcp__sequential-thinking__sequentialthinking` para analise profunda.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Configuracao Inicial
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
mcp__sequential-thinking__sequentialthinking({
|
|
11
|
+
thought: "[hipotese inicial baseada em evidencias]",
|
|
12
|
+
nextThoughtNeeded: true,
|
|
13
|
+
thoughtNumber: 1,
|
|
14
|
+
totalThoughts: 8 // MINIMO 8 thoughts
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Regras para Cada Thought
|
|
21
|
+
|
|
22
|
+
Cada thought DEVE conter:
|
|
23
|
+
|
|
24
|
+
1. **Hipotese especifica**: "Acredito que o bug acontece porque..."
|
|
25
|
+
2. **Busca de evidencia**: Usar Grep/Read para encontrar arquivo:linha
|
|
26
|
+
3. **Avaliacao**: A evidencia suporta ou refuta a hipotese?
|
|
27
|
+
4. **Proxima acao**:
|
|
28
|
+
- SE suporta: Ir mais fundo ("Por que isso acontece?")
|
|
29
|
+
- SE refuta: Marcar `isRevision: true` e tentar alternativa
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Parametros Especiais
|
|
34
|
+
|
|
35
|
+
| Parametro | Quando Usar |
|
|
36
|
+
|-----------|-------------|
|
|
37
|
+
| `isRevision: true` | Quando descartando hipotese anterior |
|
|
38
|
+
| `revisesThought: N` | Indicar qual thought esta sendo revisado |
|
|
39
|
+
| `branchFromThought: N` | Quando explorando caminho alternativo |
|
|
40
|
+
| `branchId: "hipotese-2"` | Identificar o branch atual |
|
|
41
|
+
| `needsMoreThoughts: true` | Se precisa ir mais fundo |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Criterios de Parada
|
|
46
|
+
|
|
47
|
+
Somente definir `nextThoughtNeeded: false` quando:
|
|
48
|
+
|
|
49
|
+
- [ ] Chegou em algo que PODE SER MUDADO no codigo
|
|
50
|
+
- [ ] Tem EVIDENCIA concreta (arquivo:linha + codigo)
|
|
51
|
+
- [ ] Nao ha mais "por que?" logico para perguntar
|
|
52
|
+
- [ ] A causa identificada explica TODOS os sintomas
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Exemplo de Fluxo
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Thought 1: "Hipotese: erro em validateInput()"
|
|
60
|
+
→ Grep encontra validacao em services/videoService.ts:45
|
|
61
|
+
→ Evidencia: funcao nao valida campo X
|
|
62
|
+
|
|
63
|
+
Thought 2: "Por que nao valida campo X?"
|
|
64
|
+
→ Read services/videoService.ts
|
|
65
|
+
→ Evidencia: schema Zod nao inclui X (linha 12)
|
|
66
|
+
|
|
67
|
+
Thought 3: "Por que schema nao inclui X?"
|
|
68
|
+
→ git log mostra: adicionado em commit abc123
|
|
69
|
+
→ Evidencia: campo X e novo, schema desatualizado
|
|
70
|
+
|
|
71
|
+
Thought 4 (isRevision=true): "Mas wait, X deveria ser opcional..."
|
|
72
|
+
→ Re-analisando: o problema e que X e required no destino
|
|
73
|
+
|
|
74
|
+
Thought 5: "Onde X e required?"
|
|
75
|
+
→ Grep encontra em api/handlers/upload.ts:78
|
|
76
|
+
→ Evidencia: handler espera X mas nao recebe
|
|
77
|
+
|
|
78
|
+
... continua ate causa raiz confirmada ...
|
|
79
|
+
```
|