name: tdd
This command enforces test-driven development methodology for GROWI.
THIS IS NOT OPTIONAL. THIS IS A TEAM REQUIREMENT.
If you find yourself about to deviate from the TDD cycle:
Example of required user confirmation:
"This task requires writing integration tests with complex setup
(database mocks, authentication, etc.).
I have two options:
Option A: Follow strict TDD (recommended)
- RED: Write failing integration test first
- GREEN: Implement minimal code to pass
- REFACTOR: Improve code while keeping tests green
- May take 15-30 minutes for test setup
- Ensures proper test coverage
Option B: Skip TDD for this specific change
- Implement directly
- Verify with existing test suite only
- Risk: No specific test for this change
Which approach would you prefer?"
Never assume. Always ask.
Before writing ANY code, confirm:
If any checkbox is unchecked, STOP and ask the user.
Use /tdd when:
RED → GREEN → REFACTOR → REPEAT
RED: Write a failing test
GREEN: Write minimal code to pass
REFACTOR: Improve code, keep tests passing
REPEAT: Next feature/scenario
User: /tdd I need a function to validate page paths
Agent:
// src/utils/page-path-validator.ts
export interface ValidationResult {
isValid: boolean;
errorMessage?: string;
}
export function validatePagePath(path: string): ValidationResult {
throw new Error('Not implemented');
}
⚠️ CHECKPOINT: Confirm you have NOT written any implementation code yet.
// src/utils/page-path-validator.spec.ts
describe('validatePagePath', () => {
it('should return valid for correct path', () => {
const result = validatePagePath('/user/docs/page');
expect(result.isValid).toBe(true);
});
it('should reject path without leading slash', () => {
const result = validatePagePath('user/docs');
expect(result.isValid).toBe(false);
expect(result.errorMessage).toBeDefined();
});
it('should reject empty path', () => {
const result = validatePagePath('');
expect(result.isValid).toBe(false);
});
});
⚠️ MANDATORY: Tests MUST fail before proceeding to implementation.
turbo run test --filter @growi/app -- src/utils/page-path-validator.spec.ts
FAIL src/utils/page-path-validator.spec.ts
✕ should return valid for correct path
Error: Not implemented
✅ CHECKPOINT PASSED: Tests fail as expected. Ready to implement.
❌ If tests pass or don't run: STOP. Fix the test first.
⚠️ CHECKPOINT: Only write the MINIMUM code needed to pass the tests.
export function validatePagePath(path: string): ValidationResult {
if (!path) {
return { isValid: false, errorMessage: 'Path cannot be empty' };
}
if (!path.startsWith('/')) {
return { isValid: false, errorMessage: 'Path must start with /' };
}
return { isValid: true };
}
⚠️ MANDATORY: ALL tests MUST pass before proceeding to refactoring.
turbo run test --filter @growi/app -- src/utils/page-path-validator.spec.ts
PASS ✓ All tests passing!
✅ CHECKPOINT PASSED: Ready to refactor if needed.
❌ If tests fail: Fix implementation, do NOT move to refactoring.
⚠️ MANDATORY: Verify test coverage meets requirements (80% minimum).
cd {package_dir} && pnpm vitest run --coverage src/utils/page-path-validator.spec.ts
Coverage: 100% ✅ (Target: 80%)
✅ TDD CYCLE COMPLETE: All phases completed successfully.
DO:
vitest-mock-extended for type-safe mocksDON'T:
Unit Tests (*.spec.ts):
Integration Tests (*.integ.ts):
Component Tests (*.spec.tsx):
MANDATORY - NO EXCEPTIONS: The complete TDD cycle MUST be followed:
Absolute Requirements:
If you violate these rules:
This is a team development standard. Violations are not acceptable.
This command uses patterns from: