This skill should be used when the user asks to "run tests", "create tests", "fix failing test", "add test coverage", "fix slow tests", or "commit test changes".
Unified workflow for test development, execution, and maintenance.
Read .claude/project-config.yaml → test section at project root. Provides:
runner — test framework (pytest, jest, vitest, go, cargo)test_dir — test root directorycoverage_package — package name for coverage reportingcommands — named commands (fast, unit, integration, single, topic, coverage, collect, plus project-specific)path_mapping — source→test location rulesfixtures — available test fixtures/helpers with descriptionsmarkers — test markers/tags with descriptionstest_pattern — canonical test structure exampleIf missing, discover from pyproject.toml, jest.config.*, Makefile, package.json, CLAUDE.md, or common conventions. Prefer project-defined commands over raw runner invocations.
| Action | Trigger | Description |
|---|---|---|
run | "run tests", "test X" | Execute tests |
create | "create test", "add tests for" | Create new tests |
fix | "fix failing test" | Debug and fix test failures |
coverage | "add coverage", "coverage gaps" | Add test coverage |
perf | "slow tests", "optimize tests" | Fix slow tests |
cleanup | "commit test changes" | Commit modified test files |
Commit rule: After any write action completes successfully, always run the Cleanup step before returning to the user. Do not wait for the user to request a commit.
Input: Marker/tag, path, topic, "all", "ci", or empty (fast/default)
Resolve input to a runner command via config commands:
| Input | Strategy |
|---|---|
| Named target | Config commands.{name} (e.g., commands.unit, commands.tpch) |
| Path | Config commands.single with {path} substitution |
| Topic/keyword | Config commands.topic with {topic} substitution |
| Empty | Config commands.fast (default suite) |
Report: Pass/fail counts, failure patterns, slow tests, next steps.
Input: Goal, module path, feature, or ticket
Steps:
commands.collect filtered by topicpath_mapping rules (source pattern → test path)fixtures list with descriptionsmarkers listtest_pattern and existing project stylecommands.single with new test pathcommands.coverageResearch Gate (SHARED/research-framework.md): Read the code under test and at least one existing test in the same area before writing.
Input: Test path, "last", marker, or empty
Steps:
| Category | Fix |
|---|---|
| Test bug | Update test |
| Code bug | Fix source |
| Environment | Fix setup/fixtures |
| Flaky | Fix race condition, timing, shared state |
See references/perf.md for slow test optimization.
Input: Module path, topic, "gaps", "report"
Steps:
commands.coverage (uses coverage_package for scope)test_patternpath_mappingInput: Path, marker, threshold, "all", "report"
Steps:
| Issue | Fix |
|---|---|
| Repeated setup | Widen fixture/setup scope |
| Real external dep | Mock or in-memory substitute |
| Large test data | Reduce to minimum needed |
| External process | Mock subprocess/network |
See references/perf.md for detailed strategies.
Uses SHARED/commit-framework.md with:
git status --porcelain filtered to config test_dirtestcommands.fastSee references/cleanup.md for details.
## Test {Action}: {scope}
### Summary
- **Scope**: {marker/path}
- **Status**: PASSED/FAILED
### Results
| Status | Count |
|--------|-------|
| Passed | X |
| Failed | Y |
### {Action-specific details}
### Next Steps
- {recommendation}