원클릭으로
test-driven-development
Ciclo RED-GREEN-REFACTOR obrigatorio para todo codigo de producao
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Ciclo RED-GREEN-REFACTOR obrigatorio para todo codigo de producao
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Refina ideias atraves de perguntas antes de implementar
Revisao sistematica de codigo focada em qualidade, padroes e manutencao
Captura e armazena licoes tecnicas de bug fixes ou decisoes arquiteturais
Decomposição de tarefas complexas em Roadmaps e Sprints
Workflow sistemático para versionamento, atualização de documentação e tagueamento seguro de releases.
Processo de 4 fases para encontrar causa raiz de bugs
| name | test-driven-development |
| description | Ciclo RED-GREEN-REFACTOR obrigatorio para todo codigo de producao |
| triggers | ["implementar","codigo","desenvolver","tdd","feature"] |
| globs | ["**/*.test.*","**/*.spec.*","tests/**"] |
| steps | 3 |
| checkpoints | ["red_phase_complete","green_phase_complete","refactor_phase_complete"] |
| requires_validation | true |
NUNCA escreva codigo de producao sem um teste que falhe primeiro. Codigo sem teste = Divida Tecnica = BLOQUEADO
[!CRITICAL] SEGURANCA EM PRIMEIRO LUGAR
# Antes de modificar arquivos
validation_check "safe_path" "$filepath"
# Antes de deletar codigo
validation_check "file_exists" "$filepath"
# Antes de commit
validation_check "tests_pass"
aidev snapshot antes de mudancas estruturaisrm -rf em paths genericosCheckpoint: red_phase_complete
Escrever um teste que FALHE pelo motivo correto.
describe('[Feature/Component]', () => {
it('should [comportamento esperado] when [condicao]', () => {
// Arrange - preparar dados
const input = ...;
// Act - executar acao
const result = funcaoATestar(input);
// Assert - verificar resultado
expect(result).toBe(expected);
});
});
# Executar teste e verificar que falha
npm test -- --testNamePattern="[nome do teste]"
# ou
pytest -k "[nome do teste]"
# ou
php artisan test --filter="[nome do teste]"
confidence: 0.1 (algo errado)confidence: 0.9 (prosseguir)Checkpoint: green_phase_complete
Escrever o MINIMO codigo necessario para o teste passar.
# Executar teste especifico
npm test -- --testNamePattern="[nome do teste]"
# Executar suite completa para verificar regressoes
npm test
confidence: 0.95confidence: 0.2 (investigar)Checkpoint: refactor_phase_complete
Melhorar a qualidade do codigo SEM mudar comportamento.
# Antes de refatorar, criar checkpoint
validation_check "tests_pass"
# Se mudanca grande:
aidev snapshot
# Apos cada refatoracao
npm test
# Verificar que nada quebrou
git diff --stat
ERRADO: Escrever codigo -> Escrever teste
CERTO: Escrever teste -> Escrever codigo
ERRADO: expect(spy.toHaveBeenCalledWith(...))
CERTO: expect(result).toBe(expected)
ERRADO: Sem assertions, catch-all de excecoes
CERTO: Assertions especificas que podem falhar
ERRADO: Dependem de timing, estado externo
CERTO: Isolados, deterministicos
ERRADO: Testar que React renderiza
CERTO: Testar SUA logica de componente
describe('Feature', () => {
beforeEach(() => { /* setup */ });
afterEach(() => { /* cleanup */ });
it('should do X when Y', () => {
// Arrange -> Act -> Assert
});
});
test('feature does X when Y', function () {
// Arrange
$input = ...;
// Act
$result = $this->feature->execute($input);
// Assert
expect($result)->toBe($expected);
});
def test_feature_does_x_when_y():
# Arrange
input_data = ...
# Act
result = feature(input_data)
# Assert
assert result == expected
| Tipo | Meta | Foco |
|---|---|---|
| Unit Tests | 80%+ | Funcoes individuais |
| Integration | Paths criticos | Interacao entre modulos |
| E2E | Happy paths + erros | Fluxos completos do usuario |
RED -> GREEN -> REFACTOR -> [proxima feature] -> RED -> ...
skill_complete "test-driven-development"
agent_handoff "backend" "qa" "Revisar implementacao" "src/feature.ts"
# Para cada unidade de funcionalidade:
skill_init "test-driven-development"
skill_set_steps "test-driven-development" 3
# RED
skill_advance "test-driven-development" "RED: Escrever teste que falha"
# ... escrever teste, verificar que falha ...
validation_log "test_fails" "tests/feature.test.ts" "passed"
skill_validate_checkpoint "test-driven-development"
# GREEN
skill_advance "test-driven-development" "GREEN: Implementar minimo"
# ... implementar codigo minimo ...
validation_check "tests_pass"
skill_validate_checkpoint "test-driven-development"
# REFACTOR
skill_advance "test-driven-development" "REFACTOR: Melhorar qualidade"
# ... refatorar mantendo testes verdes ...
validation_check "tests_pass"
skill_validate_checkpoint "test-driven-development"
skill_complete "test-driven-development"
| Stack | Test Runner | Coverage | Mocking |
|---|---|---|---|
| JavaScript | Jest, Vitest | c8, istanbul | jest.mock |
| TypeScript | Jest, Vitest | c8 | ts-jest |
| PHP | PHPUnit, Pest | xdebug | Mockery |
| Python | pytest | coverage.py | pytest-mock |
| Go | testing | go test -cover | testify |
| Laravel | Pest, PHPUnit | xdebug | Mockery |
| React | RTL, Vitest | c8 | MSW |