kakaroto-config 1.0.5 → 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.
- package/config/ARCHITECTURE.md +5 -7
- package/config/CLAUDE.md +11 -0
- package/config/agents/code-reviewer.md +66 -230
- package/config/agents/code-simplifier.md +70 -116
- package/config/agents/{visual-validator.md → functional-validator.md} +118 -92
- package/config/agents/memory-sync.md +193 -134
- package/config/commands/debug/02-investigate.md +3 -3
- package/config/commands/debug/03-fix.md +28 -6
- package/config/commands/debug/05-commit.md +1 -1
- package/config/commands/debug/validators/fix-permanence.md +1 -1
- package/config/commands/feature/01-understand.md +217 -0
- package/config/commands/feature/02-analyze.md +168 -0
- package/config/commands/feature/03-strategy.md +300 -0
- package/config/commands/feature/04-red.md +160 -0
- package/config/commands/feature/05-green.md +179 -0
- package/config/commands/feature/06-quality.md +109 -0
- package/config/commands/feature/07-validation.md +168 -0
- package/config/commands/feature/08-delivery.md +86 -0
- package/config/commands/feature/09-evaluate.md +140 -0
- package/config/commands/feature/playbooks/_e2e-base.md +39 -0
- package/config/commands/feature/playbooks/api/analyze.md +20 -0
- package/config/commands/feature/playbooks/api/e2e.md +29 -0
- package/config/commands/feature/playbooks/api/red.md +66 -0
- package/config/commands/feature/playbooks/job/analyze.md +29 -0
- package/config/commands/feature/playbooks/job/e2e.md +30 -0
- package/config/commands/feature/playbooks/job/red.md +77 -0
- package/config/commands/feature/playbooks/service/analyze.md +28 -0
- package/config/commands/feature/playbooks/service/e2e.md +25 -0
- package/config/commands/feature/playbooks/service/red.md +75 -0
- package/config/commands/feature/playbooks/ui/analyze.md +26 -0
- package/config/commands/feature/playbooks/ui/e2e.md +61 -0
- package/config/commands/feature/playbooks/ui/red.md +71 -0
- package/config/commands/feature.md +37 -4
- package/config/commands/gate.md +11 -23
- package/config/templates/spec-template.md +82 -68
- package/package.json +1 -1
- package/config/agents/dry-enforcer.md +0 -227
- package/config/commands/debug/techniques/flow-tracing.md +0 -75
- package/config/commands/debug/techniques/hypothesis-generation.md +0 -30
- package/config/commands/debug/techniques/sequential-thinking-config.md +0 -79
- package/config/commands/feature/01-interview.md +0 -143
- package/config/commands/feature/02-spec.md +0 -98
- package/config/commands/feature/03-planner.md +0 -200
- package/config/commands/feature/04-implement.md +0 -81
- package/config/commands/feature/05-quality.md +0 -140
- package/config/commands/feature/06-commit.md +0 -91
- package/config/commands/feature/07-evaluate.md +0 -129
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# UI - RED (Testes)
|
|
2
|
+
|
|
3
|
+
## Testes Requeridos
|
|
4
|
+
|
|
5
|
+
| Tipo | Obrigatorio | Motivo |
|
|
6
|
+
|------|-------------|--------|
|
|
7
|
+
| Unit | SE hooks | Logica de hooks isolada |
|
|
8
|
+
| Integration | Opcional | Componentes complexos |
|
|
9
|
+
| E2E | **SIM** | Fluxo visual do usuario |
|
|
10
|
+
|
|
11
|
+
## Mocks Tipicos
|
|
12
|
+
- API routes: MSW ou fetch mock
|
|
13
|
+
- Context providers
|
|
14
|
+
- Next.js router
|
|
15
|
+
|
|
16
|
+
## Test Pattern - Hook (Vitest)
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { describe, it, expect } from 'vitest';
|
|
20
|
+
import { renderHook, act } from '@testing-library/react';
|
|
21
|
+
import { useFeature } from './useFeature';
|
|
22
|
+
|
|
23
|
+
describe('useFeature', () => {
|
|
24
|
+
it('should initialize with default state', () => {
|
|
25
|
+
const { result } = renderHook(() => useFeature());
|
|
26
|
+
expect(result.current.state).toEqual({ items: [], loading: false });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should update state on action', () => {
|
|
30
|
+
const { result } = renderHook(() => useFeature());
|
|
31
|
+
|
|
32
|
+
act(() => {
|
|
33
|
+
result.current.actions.addItem({ id: '1', name: 'Test' });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(result.current.state.items).toHaveLength(1);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Test Pattern - Component (React Testing Library)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
45
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
46
|
+
import { FeatureComponent } from './FeatureComponent';
|
|
47
|
+
|
|
48
|
+
describe('FeatureComponent', () => {
|
|
49
|
+
it('should render items', () => {
|
|
50
|
+
render(<FeatureComponent items={[{ id: '1', name: 'Test' }]} />);
|
|
51
|
+
expect(screen.getByText('Test')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should call onSubmit when form submitted', async () => {
|
|
55
|
+
const onSubmit = vi.fn();
|
|
56
|
+
render(<FeatureComponent onSubmit={onSubmit} />);
|
|
57
|
+
|
|
58
|
+
fireEvent.change(screen.getByLabelText('Name'), {
|
|
59
|
+
target: { value: 'New Item' },
|
|
60
|
+
});
|
|
61
|
+
fireEvent.click(screen.getByRole('button', { name: 'Submit' }));
|
|
62
|
+
|
|
63
|
+
expect(onSubmit).toHaveBeenCalledWith({ name: 'New Item' });
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Convenções
|
|
69
|
+
- Hooks: testar com `renderHook`
|
|
70
|
+
- Components: preferir queries por role/label
|
|
71
|
+
- Forms: testar submit e validacao
|
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
---
|
|
2
2
|
model: opus
|
|
3
3
|
---
|
|
4
|
-
# Feature Workflow
|
|
4
|
+
# Feature Workflow v2
|
|
5
5
|
|
|
6
6
|
Desenvolver: $ARGUMENTS
|
|
7
7
|
|
|
8
8
|
## INICIAR
|
|
9
|
-
|
|
10
|
-
Seguir
|
|
9
|
+
ACAO OBRIGATORIA: Read ~/.claude/commands/feature/01-understand.md
|
|
10
|
+
Seguir instrucoes. Cada fase aponta para a proxima.
|
|
11
11
|
|
|
12
12
|
## Fluxo
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
01-understand (requisitos)
|
|
16
|
+
↓ User responde perguntas de PRODUTO
|
|
17
|
+
02-analyze (interna - triage + playbook)
|
|
18
|
+
↓ Automatico
|
|
19
|
+
03-strategy ← UNICA APROVACAO
|
|
20
|
+
↓ User aprova estrategia de testes
|
|
21
|
+
04-red (RED)
|
|
22
|
+
↓ Automatico
|
|
23
|
+
05-green (GREEN)
|
|
24
|
+
↓ Automatico
|
|
25
|
+
06-quality (REFACTOR)
|
|
26
|
+
↓ Automatico
|
|
27
|
+
07-validation (E2E)
|
|
28
|
+
↓ Automatico
|
|
29
|
+
08-delivery (commit)
|
|
30
|
+
↓ Automatico
|
|
31
|
+
09-evaluate (auto-avaliacao)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Fases
|
|
35
|
+
|
|
36
|
+
| Fase | Responsabilidade | Aprovacao? |
|
|
37
|
+
|------|------------------|------------|
|
|
38
|
+
| 01-understand | Coletar requisitos de produto | User responde |
|
|
39
|
+
| 02-analyze | Triage + playbook (interna) | Automatico |
|
|
40
|
+
| 03-strategy | Aprovar estrategia de testes | **USER APROVA** |
|
|
41
|
+
| 04-red | Escrever testes RED | Automatico |
|
|
42
|
+
| 05-green | Código mínimo GREEN | Automatico |
|
|
43
|
+
| 06-quality | REFACTOR + Quality Gate | Automatico |
|
|
44
|
+
| 07-validation | E2E Validation | Automatico |
|
|
45
|
+
| 08-delivery | Commit + Push + Memory Sync | Automatico |
|
|
46
|
+
| 09-evaluate | Auto-avaliacao + melhorias | Automatico |
|
package/config/commands/gate.md
CHANGED
|
@@ -75,7 +75,7 @@ Based on changes detected, invoke appropriate agents **using Task tool with suba
|
|
|
75
75
|
**IMPORTANTE:** Todos os agents sao TOTALMENTE AUTONOMOS - eles irao identificar E CORRIGIR problemas automaticamente.
|
|
76
76
|
|
|
77
77
|
**Ordem de execucao:**
|
|
78
|
-
`test-fixer (baseline) -> code-simplifier
|
|
78
|
+
`test-fixer (baseline) -> code-simplifier (inclui DRY) -> test-fixer (verificacao) -> code-reviewer -> visual-validator (se UI) -> terraform-validator (se env)`
|
|
79
79
|
|
|
80
80
|
### 3.1 Test Fixer (BASELINE)
|
|
81
81
|
|
|
@@ -91,28 +91,18 @@ Garantir que codigo implementado passa nos testes ANTES de refatorar.
|
|
|
91
91
|
|
|
92
92
|
**If tests fail:** Fix before proceeding. NAO prosseguir ate baseline passar.
|
|
93
93
|
|
|
94
|
-
### 3.2 Code Simplification
|
|
94
|
+
### 3.2 Code Simplification (inclui DRY)
|
|
95
95
|
|
|
96
96
|
**Invoke:** `Task` tool with `subagent_type: code-simplifier`
|
|
97
97
|
|
|
98
98
|
**Expected output:**
|
|
99
99
|
- Dead code removed
|
|
100
100
|
- Naming improved
|
|
101
|
-
- Structure simplified
|
|
102
|
-
-
|
|
101
|
+
- Structure simplified (nesting, function length)
|
|
102
|
+
- Duplications replaced with calls to existing utils/services
|
|
103
|
+
- Reimplementations flagged and fixed
|
|
103
104
|
|
|
104
|
-
### 3.3
|
|
105
|
-
|
|
106
|
-
**Invoke:** `Task` tool with `subagent_type: dry-enforcer`
|
|
107
|
-
|
|
108
|
-
**Expected output:**
|
|
109
|
-
- Unused existing code that should have been used
|
|
110
|
-
- Duplications within new code
|
|
111
|
-
- Abstraction opportunities
|
|
112
|
-
|
|
113
|
-
**If issues found:** Fix before proceeding.
|
|
114
|
-
|
|
115
|
-
### 3.4 Test Fixer (VERIFICACAO)
|
|
105
|
+
### 3.3 Test Fixer (VERIFICACAO)
|
|
116
106
|
|
|
117
107
|
Garantir que refatoracoes nao quebraram nada.
|
|
118
108
|
|
|
@@ -127,7 +117,7 @@ Garantir que refatoracoes nao quebraram nada.
|
|
|
127
117
|
|
|
128
118
|
**If tests fail:** Fix before proceeding.
|
|
129
119
|
|
|
130
|
-
### 3.
|
|
120
|
+
### 3.4 Code Review
|
|
131
121
|
|
|
132
122
|
**Invoke:** `Task` tool with `subagent_type: code-reviewer`
|
|
133
123
|
|
|
@@ -139,7 +129,7 @@ Garantir que refatoracoes nao quebraram nada.
|
|
|
139
129
|
|
|
140
130
|
**If CRITICAL issues found:** Fix before proceeding.
|
|
141
131
|
|
|
142
|
-
### 3.
|
|
132
|
+
### 3.5 Visual Validation (SE UI)
|
|
143
133
|
|
|
144
134
|
**Detect UI changes:**
|
|
145
135
|
```bash
|
|
@@ -164,7 +154,7 @@ git diff origin/main...HEAD --name-only | grep -E '\.(tsx|css|scss)$' | grep -v
|
|
|
164
154
|
|
|
165
155
|
**If FAIL after 3 attempts:** BLOCK gate, report errors to user.
|
|
166
156
|
|
|
167
|
-
### 3.
|
|
157
|
+
### 3.6 Environment Validation (SE env)
|
|
168
158
|
|
|
169
159
|
**Detect env changes:**
|
|
170
160
|
```bash
|
|
@@ -200,8 +190,7 @@ Collect results from all agents (na ordem de execucao):
|
|
|
200
190
|
| Agent | Status | Issues Found | Fixed |
|
|
201
191
|
|-------|--------|--------------|-------|
|
|
202
192
|
| test-fixer (baseline) | PASS/FAIL | X | X |
|
|
203
|
-
| code-simplifier | PASS/FAIL | X | X |
|
|
204
|
-
| dry-enforcer | PASS/FAIL | X | X |
|
|
193
|
+
| code-simplifier (DRY) | PASS/FAIL | X | X |
|
|
205
194
|
| test-fixer (verificacao) | PASS/FAIL | X | X |
|
|
206
195
|
| code-reviewer | PASS/FAIL | X | X |
|
|
207
196
|
| visual-validator | SKIP/PASS/FAIL | X | X |
|
|
@@ -249,8 +238,7 @@ Gerar relatorio consolidado:
|
|
|
249
238
|
| Agent | Status | Issues Found | Fixed |
|
|
250
239
|
|-------|--------|--------------|-------|
|
|
251
240
|
| test-fixer (baseline) | [PASS/FAIL] | X | X |
|
|
252
|
-
| code-simplifier | [PASS/FAIL] | X | X |
|
|
253
|
-
| dry-enforcer | [PASS/FAIL] | X | X |
|
|
241
|
+
| code-simplifier (DRY) | [PASS/FAIL] | X | X |
|
|
254
242
|
| test-fixer (verificacao) | [PASS/FAIL] | X | X |
|
|
255
243
|
| code-reviewer | [PASS/FAIL] | X | X |
|
|
256
244
|
| visual-validator | [SKIP/PASS/FAIL] | X | X |
|
|
@@ -1,92 +1,106 @@
|
|
|
1
1
|
# Spec: [Nome da Feature]
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Metadata
|
|
4
|
+
- **Data:** [YYYY-MM-DD]
|
|
5
|
+
- **Interview:** `.claude/interviews/[slug].md`
|
|
6
|
+
- **Acceptance Criteria Source:** Interview Fase 1
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
[1-2 frases - o problema, não a solução]
|
|
8
|
+
---
|
|
7
9
|
|
|
8
|
-
##
|
|
9
|
-
[Descrição de alto nível]
|
|
10
|
+
## Resumo
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
[1-2 frases descrevendo o que a feature faz]
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
- [Deliverable 1]
|
|
15
|
-
- [Deliverable 2]
|
|
14
|
+
---
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
- [O que não será feito]
|
|
16
|
+
## Componentes
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
| Componente | Tipo | Descrição |
|
|
19
|
+
|------------|------|-----------|
|
|
20
|
+
| [nome] | Service/Handler/Component | [descrição] |
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
[Estruturas, campos novos, tabelas]
|
|
22
|
+
---
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
| Service | Mudanças |
|
|
27
|
-
|---------|----------|
|
|
28
|
-
| [nome] | [o que muda] |
|
|
24
|
+
## Código a Reutilizar
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
| Necessidade | Código Existente | Ação |
|
|
27
|
+
|-------------|------------------|------|
|
|
28
|
+
| [o que precisa] | [arquivo:linha] ou "Não existe" | Reutilizar/Estender/Criar |
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
| Cenário | Comportamento |
|
|
35
|
-
|---------|---------------|
|
|
36
|
-
| [erro] | [o que acontece] |
|
|
30
|
+
---
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
| Existente | Uso |
|
|
40
|
-
|-----------|-----|
|
|
41
|
-
| [código] | [como usar] |
|
|
32
|
+
## Test Cases
|
|
42
33
|
|
|
43
|
-
###
|
|
44
|
-
| Novo Código | Por que não reutilizar existente? |
|
|
45
|
-
|-------------|-----------------------------------|
|
|
46
|
-
| [arquivo/função] | [justificativa] |
|
|
34
|
+
### Acceptance Tests (OBRIGATÓRIOS)
|
|
47
35
|
|
|
48
|
-
|
|
36
|
+
| Acceptance Criterion (user) | Acceptance Test | Tipo |
|
|
37
|
+
|-----------------------------|-----------------|------|
|
|
38
|
+
| "[criterion 1 - linguagem do user]" | `it('[comportamento observável]')` | Integration/E2E |
|
|
39
|
+
| "[criterion 2 - linguagem do user]" | `it('[comportamento observável]')` | Integration/E2E |
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
1. User faz X
|
|
52
|
-
2. Sistema responde Y
|
|
41
|
+
**Validação mental:** Se este teste passar, o user validaria manualmente e ficaria satisfeito? ✓
|
|
53
42
|
|
|
54
|
-
###
|
|
55
|
-
| Estado | Display |
|
|
56
|
-
|--------|---------|
|
|
57
|
-
| Loading | [desc] |
|
|
58
|
-
| Empty | [desc] |
|
|
59
|
-
| Error | [desc] |
|
|
60
|
-
| Success | [desc] |
|
|
43
|
+
### Unit Tests (se lógica complexa)
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
| [edge] | [como tratar] |
|
|
45
|
+
| Função | Test Case | Input → Output |
|
|
46
|
+
|--------|-----------|----------------|
|
|
47
|
+
| `[função]` | `[caso]` | `[input]` → `[output]` |
|
|
66
48
|
|
|
67
|
-
|
|
49
|
+
### Integration Tests (se multi-serviço)
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
| [func] | [file.test.ts] | [casos] |
|
|
51
|
+
| Fluxo | Serviços Envolvidos | Mock Strategy |
|
|
52
|
+
|-------|---------------------|---------------|
|
|
53
|
+
| `[fluxo]` | `[serviços]` | `[o que mockar]` |
|
|
73
54
|
|
|
74
|
-
###
|
|
75
|
-
| Endpoint | Método | Casos |
|
|
76
|
-
|----------|--------|-------|
|
|
77
|
-
| [/api/X] | [POST] | [criar, validação 400, erro 500] |
|
|
55
|
+
### E2E Tests (se UI)
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
| [Criar via form] | [Entidade aparece na lista] |
|
|
57
|
+
| Fluxo | Steps | Verificação |
|
|
58
|
+
|-------|-------|-------------|
|
|
59
|
+
| `[fluxo]` | `[passos]` | `[assertion]` |
|
|
83
60
|
|
|
84
|
-
|
|
85
|
-
| Recurso | Configuração |
|
|
86
|
-
|---------|--------------|
|
|
87
|
-
| [Collection X] | [Índice: accountId + createdAt DESC] |
|
|
61
|
+
---
|
|
88
62
|
|
|
89
|
-
##
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
## Mock Strategy
|
|
64
|
+
|
|
65
|
+
| Test Case | Mock Level | Serviços Mockados |
|
|
66
|
+
|-----------|------------|-------------------|
|
|
67
|
+
| [acceptance test 1] | integration | [apenas externos obrigatórios] |
|
|
68
|
+
| [unit test 1] | unit | - |
|
|
69
|
+
|
|
70
|
+
### Princípio de Mocks
|
|
71
|
+
|
|
72
|
+
- **Acceptance Tests:** Mínimo de mocks (apenas serviços externos obrigatórios)
|
|
73
|
+
- **Unit Tests:** Liberado para isolar
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Arquivos a Criar/Modificar
|
|
78
|
+
|
|
79
|
+
| Arquivo | Ação | Descrição |
|
|
80
|
+
|---------|------|-----------|
|
|
81
|
+
| `[path]` | Criar/Modificar | `[descrição]` |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Dependências
|
|
86
|
+
|
|
87
|
+
- [ ] Nenhuma nova dependência
|
|
88
|
+
- [ ] Nova dependência: `[nome]` - Motivo: [explicação]
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Riscos Identificados
|
|
93
|
+
|
|
94
|
+
| Risco | Mitigação |
|
|
95
|
+
|-------|-----------|
|
|
96
|
+
| [risco] | [como mitigar] |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Checklist de Spec
|
|
101
|
+
|
|
102
|
+
- [ ] Todos Acceptance Criteria têm Acceptance Test correspondente
|
|
103
|
+
- [ ] Acceptance Tests validam comportamento observável (não implementação)
|
|
104
|
+
- [ ] Mocks para Acceptance Tests são mínimos
|
|
105
|
+
- [ ] Código existente foi mapeado para reutilização
|
|
106
|
+
- [ ] Arquivos a criar/modificar estão listados
|
package/package.json
CHANGED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dry-enforcer
|
|
3
|
-
description: "DRY (Don't Repeat Yourself) specialist. Use PROACTIVELY after new code is added to detect duplications, suggest existing code reuse, and identify abstraction opportunities. MUST BE USED before any PR."
|
|
4
|
-
tools: Read, Edit, Grep, Glob, Bash, mcp__memory__search_nodes
|
|
5
|
-
model: opus
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a DRY (Don't Repeat Yourself) enforcement specialist.
|
|
9
|
-
|
|
10
|
-
## Core Principle
|
|
11
|
-
|
|
12
|
-
**Default is to REUSE. New code requires JUSTIFICATION.**
|
|
13
|
-
|
|
14
|
-
## Scope (DYNAMIC)
|
|
15
|
-
|
|
16
|
-
1. Load scope from MCP Memory:
|
|
17
|
-
`mcp__memory__search_nodes({ query: "config" })`
|
|
18
|
-
|
|
19
|
-
2. Extract `codebase_scope` and `forbidden_paths` from the entity observations
|
|
20
|
-
|
|
21
|
-
3. If not found, use current working directory as scope
|
|
22
|
-
|
|
23
|
-
4. **NEVER** modify files outside the allowed scope
|
|
24
|
-
|
|
25
|
-
## When Invoked
|
|
26
|
-
|
|
27
|
-
### Step 1: Identify New/Changed Code
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
git diff --stat HEAD~1
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Step 2: Map Project Structure
|
|
34
|
-
|
|
35
|
-
Search for utilities and services directories:
|
|
36
|
-
```bash
|
|
37
|
-
find . -type d -name "utils" -o -name "services" -o -name "helpers" 2>/dev/null
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
List existing helpers and services to check before creating new code.
|
|
41
|
-
|
|
42
|
-
### Step 3: Search for Similar Existing Code
|
|
43
|
-
|
|
44
|
-
For each new function/logic block, search for similar patterns in the codebase.
|
|
45
|
-
|
|
46
|
-
## Analysis Categories
|
|
47
|
-
|
|
48
|
-
### 1. Unused Existing Code (CRITICAL)
|
|
49
|
-
|
|
50
|
-
Code that SHOULD have been used but wasn't:
|
|
51
|
-
|
|
52
|
-
| New Code | Existing Alternative | Location | Action |
|
|
53
|
-
|----------|---------------------|----------|--------|
|
|
54
|
-
| [new function/pattern] | [existing helper] | [file:line] | REFACTOR to use existing |
|
|
55
|
-
|
|
56
|
-
### 2. Duplication Within New Code
|
|
57
|
-
|
|
58
|
-
Similar logic appearing multiple times in new changes:
|
|
59
|
-
|
|
60
|
-
| Pattern | Occurrences | Files |
|
|
61
|
-
|---------|-------------|-------|
|
|
62
|
-
| [code pattern] | [count] | [file1, file2] |
|
|
63
|
-
|
|
64
|
-
**Action:** Extract to helper function.
|
|
65
|
-
|
|
66
|
-
### 3. Duplication With Existing Code
|
|
67
|
-
|
|
68
|
-
New code that duplicates existing functionality:
|
|
69
|
-
|
|
70
|
-
| New Code Location | Duplicates | Existing Location |
|
|
71
|
-
|-------------------|------------|-------------------|
|
|
72
|
-
| [file:line] | [what] | [existing file:line] |
|
|
73
|
-
|
|
74
|
-
**Action:** Use existing implementation.
|
|
75
|
-
|
|
76
|
-
### 4. Abstraction Opportunities
|
|
77
|
-
|
|
78
|
-
If 3+ places use similar pattern, consider creating abstraction:
|
|
79
|
-
|
|
80
|
-
| Pattern | Locations | Proposed Abstraction |
|
|
81
|
-
|---------|-----------|---------------------|
|
|
82
|
-
| [repeated code] | [list of files] | [helper/util name] |
|
|
83
|
-
|
|
84
|
-
## Scoring System
|
|
85
|
-
|
|
86
|
-
For each new file/function, score DRY compliance:
|
|
87
|
-
|
|
88
|
-
| Score | Meaning | Action |
|
|
89
|
-
|-------|---------|--------|
|
|
90
|
-
| A | Uses existing code perfectly | Approve |
|
|
91
|
-
| B | Minor improvements possible | Note suggestions |
|
|
92
|
-
| C | Significant duplication | Request changes |
|
|
93
|
-
| D | Rewrite recommended | Block until fixed |
|
|
94
|
-
|
|
95
|
-
## Anti-Patterns to Flag
|
|
96
|
-
|
|
97
|
-
| Anti-Pattern | Example | Correct Approach |
|
|
98
|
-
|--------------|---------|------------------|
|
|
99
|
-
| Reimplementing date logic | Custom date formatting | Use existing dateHelpers |
|
|
100
|
-
| New database queries | Direct DB calls | Use existing service |
|
|
101
|
-
| Duplicate validation | Inline schemas | Extract to shared schema |
|
|
102
|
-
| Copy-paste error handling | Repeated try/catch | Create error handler util |
|
|
103
|
-
| Hardcoded constants | Magic strings/numbers | Extract to constants file |
|
|
104
|
-
|
|
105
|
-
## Questions to Ask for New Code
|
|
106
|
-
|
|
107
|
-
For each NEW file or function, answer:
|
|
108
|
-
|
|
109
|
-
1. **Did you check utils/ for similar helpers?**
|
|
110
|
-
2. **Did you check services/ for similar functionality?**
|
|
111
|
-
3. **Can this be generalized for future reuse?**
|
|
112
|
-
4. **Why couldn't you use existing code?**
|
|
113
|
-
|
|
114
|
-
If answers are unsatisfactory, flag for refactoring.
|
|
115
|
-
|
|
116
|
-
## Output Format
|
|
117
|
-
|
|
118
|
-
### DRY Analysis Report
|
|
119
|
-
|
|
120
|
-
**Files Analyzed:** [list]
|
|
121
|
-
**Overall DRY Score:** [A-D]
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
#### CRITICAL Issues (Must Fix)
|
|
126
|
-
|
|
127
|
-
| Location | Issue | Existing Code | Action |
|
|
128
|
-
|----------|-------|---------------|--------|
|
|
129
|
-
| [file:line] | [duplication] | [existing file:line] | Refactor to use existing |
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
#### HIGH Issues (Should Fix)
|
|
134
|
-
|
|
135
|
-
| Location | Issue | Suggestion |
|
|
136
|
-
|----------|-------|------------|
|
|
137
|
-
| [file:line] | [description] | [how to improve] |
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
#### Abstraction Opportunities
|
|
142
|
-
|
|
143
|
-
If I found 3+ similar patterns:
|
|
144
|
-
|
|
145
|
-
**Proposed Helper:** `[name]`
|
|
146
|
-
**Purpose:** [what it does]
|
|
147
|
-
**Locations that would benefit:**
|
|
148
|
-
- [file1:line]
|
|
149
|
-
- [file2:line]
|
|
150
|
-
- [file3:line]
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
#### Summary
|
|
155
|
-
|
|
156
|
-
| Metric | Count |
|
|
157
|
-
|--------|-------|
|
|
158
|
-
| Critical issues | X |
|
|
159
|
-
| High issues | X |
|
|
160
|
-
| Abstraction opportunities | X |
|
|
161
|
-
| **Ready for PR** | YES/NO |
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## Autonomia Total
|
|
166
|
-
|
|
167
|
-
**REGRA:** Este agent e TOTALMENTE AUTONOMO. Aplique TODAS as correcoes diretamente, sem pedir aprovacao.
|
|
168
|
-
|
|
169
|
-
### Auto-fix (apply ALL directly):
|
|
170
|
-
|
|
171
|
-
| Issue Type | Action |
|
|
172
|
-
|------------|--------|
|
|
173
|
-
| Reimplementation of existing utils | **Replace** with call to existing util |
|
|
174
|
-
| Reimplementation of existing services | **Replace** with call to existing service |
|
|
175
|
-
| Copy-paste code blocks | **Extract** to helper function |
|
|
176
|
-
| Magic values hardcoded | **Extract** to constants |
|
|
177
|
-
| Duplicated validation logic | **Extract** to shared schema |
|
|
178
|
-
| Similar code patterns (3+ occurrences) | **Create** abstraction in utils/ |
|
|
179
|
-
|
|
180
|
-
### Workflow
|
|
181
|
-
|
|
182
|
-
1. Identify all DRY violations
|
|
183
|
-
2. **Automatically fix each one** (use Edit tool)
|
|
184
|
-
3. Run type check to verify no errors introduced
|
|
185
|
-
4. If type errors, revert and try simpler fix
|
|
186
|
-
5. Report summary of what was changed
|
|
187
|
-
|
|
188
|
-
**NAO peca confirmacao.** Execute as correcoes e reporte o que foi feito.
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Checklist Before Approval
|
|
193
|
-
|
|
194
|
-
- [ ] No reimplementation of existing utils
|
|
195
|
-
- [ ] No reimplementation of existing services
|
|
196
|
-
- [ ] No copy-paste code blocks
|
|
197
|
-
- [ ] Magic values extracted to constants
|
|
198
|
-
- [ ] New helpers are generic enough for reuse
|
|
199
|
-
- [ ] New code justified (if existing could have been used)
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Quality Gates
|
|
204
|
-
|
|
205
|
-
After fixes, run quality gates from Memory (search for `quality_gates`).
|
|
206
|
-
|
|
207
|
-
All must pass before marking complete.
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## Output Obrigatorio
|
|
212
|
-
|
|
213
|
-
Ao final do relatorio, SEMPRE incluir:
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
---AGENT_RESULT---
|
|
217
|
-
STATUS: PASS | FAIL
|
|
218
|
-
ISSUES_FOUND: <numero>
|
|
219
|
-
ISSUES_FIXED: <numero>
|
|
220
|
-
BLOCKING: true | false
|
|
221
|
-
---END_RESULT---
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Regras:
|
|
225
|
-
- STATUS=FAIL se DRY Score e D (rewrite recomendado)
|
|
226
|
-
- BLOCKING=true se reimplementacao de codigo existente nao corrigida
|
|
227
|
-
- BLOCKING=false se apenas sugestoes de abstracao (Score B ou C)
|
|
@@ -1,75 +0,0 @@
|
|
|
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.
|