add-test-writer
[ADD v0.11.0] Write failing tests from spec (TDD RED phase)
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
[ADD v0.11.0] Write failing tests from spec (TDD RED phase)
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
[ADD v0.11.0] Generate or sync a portable AGENTS.md from ADD project state — writes, checks drift, or merges with hand-curated content
[ADD v0.11.0] Declare absence — get autonomous work plan for the duration
[ADD v0.11.0] Return from absence — get briefing on autonomous work
[ADD v0.11.0] View project branding — accent color, palette, drift detection, image gen status
[ADD v0.11.0] Update project branding — new colors, fonts, tone, audit artifacts
[ADD v0.11.0] Generate or refresh CHANGELOG.md from conventional commits
| name | add-test-writer |
| description | [ADD v0.11.0] Write failing tests from spec (TDD RED phase) |
| argument-hint | specs/{feature}.md [--ac AC-001,AC-002] [--type unit|integration|e2e] |
Generate comprehensive failing tests from a feature specification. This is the RED phase of TDD — write tests before implementation.
Test Writer converts acceptance criteria and user test cases from a spec into failing, runnable tests. The output is test files that:
Verify spec file exists and is readable
Parse acceptance criteria
Parse user test cases
Load test framework configuration
Identify test file location
tests/ or __tests__/)Check for session handoff — per the Session-Handoff Preflight in ~/.codex/add/references/skill-epilogue.md
For each acceptance criterion:
Example AC:
AC-001: When user clicks the "Submit" button with valid form data,
the form should POST to /api/submit and display a success message.
Maps to tests:
test_AC_001_submit_valid_data_posts_to_apitest_AC_001_submit_valid_data_displays_success_messagetest_AC_001_submit_shows_error_on_network_failure (edge case)For each AC, determine:
unit: Test individual functions/components in isolationintegration: Test feature interactions with other modulese2e: Test complete user workflows end-to-endCreate test file(s) following the framework conventions:
For Jest/Vitest (JavaScript/TypeScript):
tests/{feature}.test.ts or __tests__/{feature}.test.jsdescribe() blocks for AC groupingtest() or it() for individual test casesbeforeEach(), afterEach()Example template:
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
// imports for module under test
describe('Feature Name', () => {
describe('AC-001: requirement statement', () => {
beforeEach(() => {
// Setup for this AC
});
it('should test specific behavior', () => {
// Arrange
const input = { /* test data */ };
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toBe(expectedValue);
});
});
});
For pytest (Python):
tests/test_{feature}.pyclass Test{Feature}: for grouping by ACdef test_ac_NNN_description(self): for test methodspytest.fixture for setupassert statementsExample template:
import pytest
# imports for module under test
class TestFeatureName:
"""Tests for Feature Name"""
@pytest.fixture
def setup(self):
# Setup fixture
yield
# Teardown
class TestAC001:
"""AC-001: requirement statement"""
def test_specific_behavior(self, setup):
# Arrange
input_data = { /* test data */ }
# Act
result = function_under_test(input_data)
# Assert
assert result == expected_value
After generating tests:
Attempt to compile/run tests
npm test # for JavaScript/TypeScript
python -m pytest # for Python
Verify they fail with clear messages
If tests don't fail
Before returning control to the tdd-cycle orchestrator, capture the test surface snapshot so Gate 3.5 can later detect deletions:
python3 ~/.codex/add/../../scripts/check-test-count.py snapshot \
--phase red \
--cycle-id {N} \
--spec-slug {slug} \
--base-sha {cycle-base-sha} \
--fail-on-empty
Requirements (AC-005, AC-006):
test(red): snapshot {total_functions} tests for {slug}--fail-on-empty reports zero tests, halt with the structured error
"RED phase produced no failing tests — TDD violation."The snapshot lives at .add/cycles/cycle-{N}/tdd-{slug}-red.json and captures: test
files, function names, normalized body hashes, language, git base SHA, and phase-end
SHA. /add-verify Gate 3.5 reads this file alongside the GREEN snapshot to enforce
the test-deletion invariant. See core/rules/tdd-enforcement.md.
Create a test mapping file: tests/{feature}-mapping.md
# Test Mapping for {Feature Name}
## Acceptance Criteria Coverage
| AC ID | Description | Test File | Test Function | Status |
|-------|-------------|-----------|-----------------|--------|
| AC-001 | requirement | tests/{feature}.test.ts | test_AC_001_* | ✗ FAIL |
| AC-002 | requirement | tests/{feature}.test.ts | test_AC_002_* | ✗ FAIL |
## User Test Cases Coverage
| UT ID | Description | Test File | Test Function | Status |
|-------|-------------|-----------|-----------------|--------|
| UT-001 | scenario | tests/{feature}.test.ts | test_UT_001_* | ✗ FAIL |
## Notes
- All tests are currently in RED state (failing)
- Tests are ready for implementation in GREEN phase
- No implementation code exists yet
Tests must follow the convention for traceability:
test_AC_{id}_{description}_{condition}
Examples:
test_AC_001_user_can_submit_valid_formtest_AC_001_submission_fails_with_empty_emailtest_AC_002_success_message_shows_user_nameEach test must:
Upon completion, output:
# Test Writing Complete (RED Phase) ✓
## Feature
{feature-name} v{spec-version}
## Tests Generated
- Total Tests: {count}
- By Type:
- Unit Tests: {count}
- Integration Tests: {count}
- E2E Tests: {count}
- All in RED state (failing as expected)
## Acceptance Criteria Coverage
- AC-001: ✓ Covered by {N} tests
- AC-002: ✓ Covered by {N} tests
... (all ACs listed)
## Test Files Created
- {test-file-path}
- {test-file-path}
## Coverage Status
- Mapping file: tests/{feature}-mapping.md
- Ready for GREEN phase (implementation)
## Next Steps
1. Run /add-implementer to write minimal code to pass tests
2. Verify all tests pass
3. Proceed to REFACTOR phase
Tasks to create (mechanics per ~/.codex/add/references/skill-epilogue.md):
| Phase | Subject | activeForm |
|---|---|---|
| Parse spec | Reading spec and acceptance criteria | Reading spec and acceptance criteria... |
| Analyze framework | Analyzing test framework configuration | Analyzing test framework configuration... |
| Write tests | Writing failing tests | Writing failing tests... |
| Verify RED | Confirming tests fail as expected | Verifying tests fail (RED confirmed)... |
Spec parsing fails
AC-###: descriptionTest file already exists
Tests don't fail when run
Test framework not installed
Syntax errors in generated tests
End-of-skill epilogue: follow ~/.codex/add/references/skill-epilogue.md (observation + learning checkpoint + progress tracking).