/add:test-writer specs/{feature}.md [--ac AC-001,AC-002] [--type unit|integration|e2e]from add
Writes failing tests from feature specifications (TDD RED phase). Parses acceptance criteria and user test cases to generate comprehensive, runnable failing tests.
Ships in add. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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 ${CLAUDE_PLUGIN_ROOT}/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 ${CLAUDE_PLUGIN_ROOT}/../../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 ${CLAUDE_PLUGIN_ROOT}/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 ${CLAUDE_PLUGIN_ROOT}/references/skill-epilogue.md (observation + learning checkpoint + progress tracking).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mountainunicorn/add --plugin add28 skills in this plugin
/agents-mdADD AGENTS.md Skill v0.11.0[ADD v0.11.0] Generate or sync a portable AGENTS.md from ADD project state — writes, checks drift, or merges with hand-curated content/awayADD Away Command v0.11.0[ADD v0.11.0] Declare absence — get autonomous work plan for the duration/backADD Back Command v0.11.0[ADD v0.11.0] Return from absence — get briefing on autonomous workOther plugins' skills for the same job