| name | systematic-debugging |
| description | Investigar bugs com processo estruturado de 4 fases |
| triggers | ["debug","bug","erro","não funciona"] |
| globs | ["**/*.php","**/*.js","**/*.log"] |
systematic-debugging - Investigação de Bugs
Regra de Ouro: Não chute, prove
Fases
Phase 1: REPRODUCE
- Descrever o bug claramente
- Identificar passos exatos para reproduzir
- Confirmar que bug existe consistentemente
- Isolar o ambiente (mesma versão, mesmo estado)
Phase 2: ISOLATE
- Binary search no código (comment half, test, repeat)
- Identificar a linha/classe específica que causa
- Minimizar reprodução ao mínimo viável
- Descartar variáveis não relacionadas
Phase 3: ROOT CAUSE (5 Whys)
Por que falhou? [resposta 1]
Por que isso aconteceu? [resposta 2]
Por que isso? [resposta 3]
...
Perguntar 5 vezes até chegar na causa raiz real
Phase 4: FIX & PREVENT
- Implementar correção mínima
- Verificar que bug não existe mais
- Adicionar teste para evitar regressão
- Documentar em /learned-lesson
Ferramentas
php artisan tinker
tail -f storage/logs/laravel.log
php -d xdebug.mode=debug ...
node --inspect
console.log (minimal)
Regra: Usar /learned-lesson para documentar bugs recorrentes