Test
Write tests for a plan's acceptance criteria. Works in two modes:
- Before implementation (TDD red phase): write failing tests that define "done", then hand off to
/work to make them pass
- After implementation: write tests that verify the code already works, catching gaps in coverage
Subagents
This skill uses the cexplore subagent to research testing conventions in the codebase.
Workflow
Phase 1: Understand What to Test
1. Read the Plan
- If no plan path was provided, read the path from
docs/plans/.latest
- Read the plan document completely
- Extract all acceptance criteria and implementation tasks
- Identify the testable behaviors — each criterion should map to at least one test
2. Detect Mode
- Run
git diff --name-only HEAD and check if implementation files already exist for the plan's tasks
- Pre-implementation (red phase): no implementation exists yet — tests will fail
- Post-implementation (verification): code already exists — tests should pass
- Announce the detected mode: "Running in [pre/post]-implementation mode."
3. Research Testing Conventions
- Use the
cexplore subagent to find:
- The project's test framework and runner (Jest, Vitest, pytest, RSpec, etc.)
- Test file naming conventions and directory structure
- Existing test patterns — how fixtures, mocks, and assertions are written
- How to run tests (the test command)
- Match the project's conventions exactly — don't introduce a new test style
4. Map Criteria to Tests
- For each acceptance criterion in the plan, draft a test name and brief description
- Group tests by file/module based on where the implementation lives (or will live)
- Present the test plan (names + descriptions) to the user for approval before writing
- Use
#askQuestions to confirm: "Proceed with these [N] tests?" with options to approve, add more, or adjust scope
Phase 2: Write Tests
For each test group:
- Create the test file following project conventions (e.g.,
__tests__/, spec/, test/, colocated .test.ts)
- Write test cases that:
- Describe the expected behavior clearly in the test name
- Set up the necessary context (imports, fixtures, test data)
- Assert the expected outcome
- Use minimal mocking — prefer testing real behavior where possible
- Include edge cases from the plan's risk section if applicable
Test Writing Principles
- Test behavior, not implementation — test what the code should do, not how it does it
- One assertion per concept — each test should verify one thing
- Descriptive names —
it("returns 404 when user does not exist") not it("test error")
- Arrange-Act-Assert — clear structure in each test
- Only test what the plan specifies — don't invent requirements
Phase 3: Verify
Run the test suite and check results based on mode:
Pre-implementation (red phase):
- All new tests must fail
- Verify failures are for the right reason (missing implementation, not syntax errors)
- Fix any tests that fail for the wrong reason (broken imports, typos, bad test setup)
- Run again — confirm all new tests fail with meaningful error messages
Post-implementation (verification):
- All new tests should pass
- If tests fail, investigate — is it a test bug or an implementation bug?
- Fix test bugs (bad assertions, wrong imports). Flag implementation bugs to the user.
- Run again — confirm all new tests pass
Phase 4: Record and Commit
- Write the list of test file paths to
docs/tests/.latest (one path per line)
- Commit:
- Pre-implementation:
test: add failing tests for <feature> (TDD red phase)
- Post-implementation:
test: add tests for <feature>
- Present a summary:
- Number of test files created
- Number of test cases written
- Status: all red (pre) or all green (post)
Phase 5: Handover
Use #askQuestions to ask what the user wants to do next, based on mode:
Pre-implementation:
| Option |
When to show |
Start Implementation (Recommended) — load the /work skill |
Always (default) |
| Add more tests — continue writing tests |
Always |
| Revise tests — adjust based on feedback |
Always |
Post-implementation:
| Option |
When to show |
Simplify Code (Recommended) — load the /simplify skill |
Always (default) |
| Add more tests — continue writing tests |
Always |
| Revise tests — adjust based on feedback |
Always |
After the user picks a next skill, announce the handover and load the chosen skill.
Key Principles
- Tests define "done" — the implementation is complete when all tests pass
- Write the minimum tests that cover the plan — comprehensive but not exhaustive
- Follow existing patterns — new tests should look like they belong in the project
- Adapt to context — red phase before implementation, green verification after
Response Rules
- Never echo full file contents into chat — reference by path
- Keep status updates to 1-2 lines per test file created
- Show the test plan (names + descriptions) for approval before writing
- After writing, report: "[N] tests across [M] files — all [red/green]"
1---2name: test3description: Write tests from a plan's acceptance criteria — before or after implementation. Use when the user says 'write tests', 'test this', 'TDD', or wants to create tests for a planned feature.4---56# Test78Write tests for a plan's acceptance criteria. Works in two modes:910- **Before implementation (TDD red phase):** write failing tests that define "done", then hand off to `/work` to make them pass11- **After implementation:** write tests that verify the code already works, catching gaps in coverage1213## Subagents1415This skill uses the `cexplore` subagent to research testing conventions in the codebase.1617## Workflow1819### Phase 1: Understand What to Test2021#### 1. Read the Plan22- If no plan path was provided, read the path from `docs/plans/.latest`23- Read the plan document completely24- Extract all acceptance criteria and implementation tasks25- Identify the testable behaviors — each criterion should map to at least one test2627#### 2. Detect Mode28- Run `git diff --name-only HEAD` and check if implementation files already exist for the plan's tasks29- **Pre-implementation (red phase):** no implementation exists yet — tests will fail30- **Post-implementation (verification):** code already exists — tests should pass31- Announce the detected mode: "Running in [pre/post]-implementation mode."3233#### 3. Research Testing Conventions34- Use the `cexplore` subagent to find:35 - The project's test framework and runner (Jest, Vitest, pytest, RSpec, etc.)36 - Test file naming conventions and directory structure37 - Existing test patterns — how fixtures, mocks, and assertions are written38 - How to run tests (the test command)39- **Match the project's conventions exactly** — don't introduce a new test style4041#### 4. Map Criteria to Tests42- For each acceptance criterion in the plan, draft a test name and brief description43- Group tests by file/module based on where the implementation lives (or will live)44- Present the test plan (names + descriptions) to the user for approval before writing45- Use `#askQuestions` to confirm: "Proceed with these [N] tests?" with options to approve, add more, or adjust scope4647### Phase 2: Write Tests4849#### For each test group:50511. **Create the test file** following project conventions (e.g., `__tests__/`, `spec/`, `test/`, colocated `.test.ts`)522. **Write test cases** that:53 - Describe the expected behavior clearly in the test name54 - Set up the necessary context (imports, fixtures, test data)55 - Assert the expected outcome563. **Use minimal mocking** — prefer testing real behavior where possible574. **Include edge cases** from the plan's risk section if applicable5859#### Test Writing Principles6061- **Test behavior, not implementation** — test what the code should do, not how it does it62- **One assertion per concept** — each test should verify one thing63- **Descriptive names** — `it("returns 404 when user does not exist")` not `it("test error")`64- **Arrange-Act-Assert** — clear structure in each test65- **Only test what the plan specifies** — don't invent requirements6667### Phase 3: Verify6869Run the test suite and check results based on mode:7071**Pre-implementation (red phase):**721. All new tests must fail732. Verify failures are for the right reason (missing implementation, not syntax errors)743. Fix any tests that fail for the wrong reason (broken imports, typos, bad test setup)754. Run again — confirm all new tests fail with meaningful error messages7677**Post-implementation (verification):**781. All new tests should pass792. If tests fail, investigate — is it a test bug or an implementation bug?803. Fix test bugs (bad assertions, wrong imports). Flag implementation bugs to the user.814. Run again — confirm all new tests pass8283### Phase 4: Record and Commit84851. Write the list of test file paths to `docs/tests/.latest` (one path per line)862. Commit:87 - Pre-implementation: `test: add failing tests for <feature> (TDD red phase)`88 - Post-implementation: `test: add tests for <feature>`893. Present a summary:90 - Number of test files created91 - Number of test cases written92 - Status: all red (pre) or all green (post)9394### Phase 5: Handover9596Use `#askQuestions` to ask what the user wants to do next, based on mode:9798**Pre-implementation:**99100| Option | When to show |101|--------|-------------|102| **Start Implementation (Recommended)** — load the `/work` skill | Always (default) |103| **Add more tests** — continue writing tests | Always |104| **Revise tests** — adjust based on feedback | Always |105106**Post-implementation:**107108| Option | When to show |109|--------|-------------|110| **Simplify Code (Recommended)** — load the `/simplify` skill | Always (default) |111| **Add more tests** — continue writing tests | Always |112| **Revise tests** — adjust based on feedback | Always |113114**After the user picks a next skill**, announce the handover and load the chosen skill.115116## Key Principles117118- **Tests define "done"** — the implementation is complete when all tests pass119- **Write the minimum tests that cover the plan** — comprehensive but not exhaustive120- **Follow existing patterns** — new tests should look like they belong in the project121- **Adapt to context** — red phase before implementation, green verification after122123## Response Rules124125- Never echo full file contents into chat — reference by path126- Keep status updates to 1-2 lines per test file created127- Show the test plan (names + descriptions) for approval before writing128- After writing, report: "[N] tests across [M] files — all [red/green]"