test-writer · git:20260512.fbc88a7 · 2026-05-12 · sha256 7a720e6931b67100
test-writer git:20260512.fbc88a7A
Immutable. This exact content never changes and is served at /api/v1/blob/7a720e6931b67100.
---
name: test-writer
description: "Write tests with TDD following structured patterns. Ensures consistent AAA structure, proper coverage targets, and framework-specific conventions. Without this skill, tests lack consistent naming, miss coverage targets, and skip anti-pattern checks."
autoInvoke: true
priority: medium
triggers:
- "add tests"
- "test coverage"
- "write tests"
- "TDD"
- "E2E test"
allowed-tools: Read, Grep, Glob, Edit, Write, Bash
user-invocable: false
---
# Test Writer
## When to Use
Adding tests, improving coverage, TDD (Phase 2/3). NOT for: bug fixes (use the `bugfix-quick` **skill** via the Skill tool — it is NOT an agent), features (run-orchestrator **skill**).
---
## Process
1. **Detect framework** from package.json / pyproject.toml / go.mod
2. **Analyze target** — read file, identify testable units, list deps to mock
3. **Write tests** — TDD: RED (failing) → GREEN (implement) → refactor. Existing code: passing → edge cases → errors
4. **Verify coverage** — run with coverage flag, check against targets
## Principles
```toon
principles[5]{principle}:
AAA pattern: Arrange → Act → Assert
"should [action] when [condition]" naming
One concern per test — no shared state
Test behavior not implementation
Mock external deps only — use fakes for complex deps
```
## Coverage Targets
```toon
coverage[4]{scope,target}:
Critical paths (auth/payment),100%
Business logic,90%
UI / utilities,80%
Overall minimum,80%
```
## Anti-Patterns
```toon
avoid[5]{pattern,fix}:
Test implementation details,Test behavior/output only
Shared state between tests,Reset in beforeEach
Sleep/delays,Use waitFor/polling
Giant multi-assertion tests,One concern per test
No assertions,Always assert expected outcomes
```
## Framework Detection
```toon
frameworks[6]{framework,file_pattern,runner}:
Jest/Vitest,"*.test.ts *.spec.ts","npm test / npx vitest"
PHPUnit,"*Test.php","./vendor/bin/phpunit"
Pytest,"test_*.py","pytest --cov=."
Go,"*_test.go","go test -cover ./..."
Cypress,"*.cy.ts","npx cypress"
Detox,"*.e2e.ts","detox test"
```
---
## Related Rules
- `rules/core/tdd-workflow.md` — RED → GREEN → REFACTOR
- `rules/core/verification.md` — Read output, then claim
- `rules/core/code-quality.md` — Coverage targets per file type
- `rules/workflow/post-implementation-linting.md` — Lint after tests added
- `rules/core/simplicity-over-complexity.md` — One concern per test, no shared mutable state, no over-engineered mocks