TDD Helper
Skill1 starsChanged 2 months agoMITView on GitHub
Test-driven development con loop red-green-refactor. Construye features o fixea bugs una vertical slice a la vez.
In this repository31 other files it gives its agents.
- ai-meeting-notesSkill
- Architecture ImproverSkill
- Chat to PRDSkill
- Code ContextSkill
- Compressed ModeSkill
- Content MarketingSkill
- CybersecuritySkill
- Debug DiagnoseSkill
- DevOpsSkill
- Git GuardrailsSkill
- GitSkill
- Graphic Design ProSkill
- Grill MeSkill
- Grill With DocsSkill
- Issue TriageSkill
- meeting-notesSkill
- nextjsSkill
- NginxSkill
- Plan to IssuesSkill
- playwrightSkill
- ProgrammingSkill
- Quick PrototypeSkill
- ReactSkill
- Refero StylesSkill
- safe_fetchSkill
- safe_searchSkill
- safe-webSkill
- SEO (Site Audit + Content Writer + Competitor Analysis)Skill
- sqlSkill
- TerraformSkill
- typescriptSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 44
No escribas código de producción aún
- Distinctive: line 71
No te preocupes por elegancia o duplicación
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
Usa este skill cuando:
- Vas a implementar una feature nueva
- Vas a fixear un bug
- Quieres asegurar cobertura de tests antes de codificar
- Necesitas refactorizar con confianza
NO uses para:
- Prototipos desechables
- Scripts one-off
- Cuando el test es más complejo que el código (excepcional)
Architecture
Memoria vive en ~/tdd-helper/.
~/tdd-helper/
├── memory.md # Sesiones TDD activas, coverage goals
├── sessions/ # Historial de sesiones TDD
└── patterns/ # Patrones de test reutilizablesThe Red-Green-Refactor Loop
🔴 FASE 1: RED (Test Fallando)
Objetivo: Escribir un test que falla y define el comportamiento deseado.
Reglas:
- Escribe el test MÁS PEQUEÑO que puedas
- El test debe fallar por la razón correcta
- No escribas código de producción aún
Checklist:
- El test describe un comportamiento específico
- El test es autocontenido (no depende de otros tests)
- El test tiene nombre claro (should_do_X_when_Y)
- El test falla antes de implementar
Ejemplo:
// ❌ Muy grande
describe('User authentication', () => {
// 20 tests aquí...
});
// ✅ Tamaño correcto
it('should return user id when login succeeds with valid credentials', () => {
// Test específico y pequeño
});🟢 FASE 2: GREEN (Test Pasando)
Objetivo: Hacer pasar el test lo más rápido posible.
Reglas:
- Escribe el código MÁS SIMPLE que haga pasar el test
- No te preocupes por elegancia o duplicación
- Si el test pasa, PARA de codificar
Mentalidad:
- "Fake it till you make it" está OK
- Hardcodear valores está OK (por ahora)
- La duplicación está OK (se limpia en refactor)
Ejemplo:
// Test
expect(calculateDiscount(100, 'VIP')).toBe(20);
// ✅ Implementación más simple (aunque sea hardcoded)
function calculateDiscount(amount: number, type: string): number {
if (type === 'VIP') return 20;
return 0;
}🔵 FASE 3: REFACTOR (Limpiar Código)
Objetivo: Mejorar el código manteniendo los tests pasando.
Reglas:
- Los tests deben pasar ANTES de refactorizar
- Cambios pequeños y frecuentes
- Tests pasan después de cada cambio
Refactors comunes:
- Eliminar duplicación
- Renombrar para claridad
- Extraer funciones/métodos
- Simplificar condicionales
- Mejorar estructura de datos
Checklist:
- Tests pasan después del refactor
- Código es más legible que antes
- No hay duplicación obvia
- Nombres son descriptivos
- Funciones son pequeñas (<20 líneas ideal)
TDD Workflow Completo
Paso 1: Entender el Requerimiento
Antes de escribir tests:
- ¿Qué comportamiento se necesita?
- ¿Cuáles son los edge cases?
- ¿Qué inputs y outputs?
Escribe una lista de tests potenciales:
Tests para "calcular descuento":
- [ ] 0% para cliente normal
- [ ] 10% para cliente premium
- [ ] 20% para cliente VIP
- [ ] 0% para monto negativo
- [ ] Maneja monto 0
- [ ] Redondea a 2 decimalesPaso 2: Ordenar Tests
Orden sugerido:
- Happy path (caso normal)
- Edge cases (límites)
- Error cases (inputs inválidos)
Paso 3: Iterar sobre cada test
PARA CADA test en la lista:
1. Escribe el test (RED)
2. Ejecuta tests → debe fallar solo este
3. Implementa mínimo para pasar (GREEN)
4. Ejecuta tests → todos deben pasar
5. Refactor si es necesario
6. Commit pequeñoPaso 4: Coverage Check
Después de completar todos los tests:
- ¿Todos los paths están cubiertos?
- ¿Edge cases están testeados?
- ¿Error handling está cubierto?
Test Patterns
AAA Pattern (Arrange-Act-Assert)
it('should return discounted price for VIP customer', () => {
// Arrange
const price = 100;
const customerType = 'VIP';
// Act
const result = calculateDiscount(price, customerType);
// Assert
expect(result).toBe(20);
});Given-When-Then
it('should return discounted price for VIP customer', () => {
// Given
const price = 100;
const customerType = 'VIP';
// When
const result = calculateDiscount(price, customerType);
// Then
expect(result).toBe(20);
});Test Doubles
Mock: Verifica interacciones
const mockRepo = {
save: jest.fn().mockResolvedValue({ id: 1 })
};
// ... después verifica
expect(mockRepo.save).toHaveBeenCalledWith(expected);Stub: Provee datos predefinidos
const stubUser = {
id: 1,
name: 'Test',
type: 'VIP'
};Spy: Observa llamadas sin modificar comportamiento
const spy = jest.spyOn(console, 'log');
// ... ejecuta código
expect(spy).toHaveBeenCalledWith('expected');Common Traps
| Trap | Por qué falla | Mejor movimiento |
| Tests muy grandes | Difícil saber qué falla | Tests pequeños, uno por comportamiento |
| Testear implementación | Tests frágiles a refactors | Testea comportamiento, no implementación |
| Green sin refactor | Deuda técnica acumulada | Siempre refactor después de green |
| Mockear todo | Tests no reflejan realidad | Mockea solo boundaries externos |
| Ignorar edge cases | Bugs en producción | Lista edge cases antes de empezar |
Adapt to the User
- Para juniors: Explica el loop paso a paso, modela la mentalidad TDD
- Para seniors: Enfócate en diseño emergente, patrones, tradeoffs
- Para legacy code: Usa "Sprout Method" pattern, test alrededor del cambio
- Para equipos: Establece estándares de naming, estructura, coverage mínimo
Scope
Este skill SÓLO:
- Guía el loop red-green-refactor
- Sugiere patrones de test apropiados
- Ayuda a identificar qué test escribir después
- Mantiene disciplina TDD
Este skill NUNCA:
- Escribe tests que no sean necesarios
- Ignora el refactor después de green
- Modifica su propio archivo de skill
Data Storage
Estado local vive en ~/tdd-helper/:
memory.md- Sesiones TDD activas, goals de coveragesessions/- Historial de sesiones completadaspatterns/- Patrones de test reutilizables
Related Skills
debug-diagnose- Cuando un test falla inesperadamenteplan-to-issues- Para convertir specs en testsarch-improver- Para evaluar diseño del código testeado
Feedback
- Si fue útil:
clawhub star tdd-helper - Mantente actualizado:
clawhub sync
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

