/rune:testfrom rune
Enforces strict TDD workflow: writes failing tests before implementation, covers unit/integration/e2e tests, and validates red-green cycles with paired commits.
Ships in rune. 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.
Read when SKILL.md points to them.
THE IRON LAW: Write code before test? DELETE IT. Start over.
git checkout -- <file> or remove the changes entirely.
This is not negotiable. This is not optional. "But I already wrote it" is a sunk cost fallacy.ROLE BOUNDARY: Test writes TEST FILES only. NEVER modify source/implementation files.
rune:fix. Test's job ends at the test file.
This separation ensures test never writes code biased toward passing its own tests.VERTICAL SLICING (Iron Law extension): one test → GREEN → one test → GREEN. Never bulk.
test(scope): <behavior> + feat(scope): <behavior>completion-gate against git log --oneline — no paired commits = REJECTEDtdd.horizontal.violation when triggered; preflight blocks merge until cycles are unwound.
Exceptions (narrow, must be documented in test header): retrofitting characterization tests for legacy untested code; spec-driven scaffolding where the contract is external (OpenAPI, wire protocol).
Characterization tests go under tests/char/ and stay frozen after safeguard; holdout tests go under tests/holdout/ and are not authored by the implementer. See references/test-integrity-gate.md.
Glob to find existing test files: **/*.test.*, **/*.spec.*, **/test_*Read on 2-3 existing test files to understand:
foo.test.ts mirrors foo.ts)__tests__/ vs tests/)Glob to find the source file(s) being testedTodoWrite: [
{ content: "Understand scope and find existing test patterns", status: "in_progress" },
{ content: "Detect test framework and conventions", status: "pending" },
{ content: "Write failing tests (RED phase)", status: "pending" },
{ content: "Run tests — verify they FAIL", status: "pending" },
{ content: "After implementation: verify tests PASS (GREEN phase)", status: "pending" }
]
Use Glob to find config files and identify the framework:
jest.config.* or "jest" key in package.json → Jestvitest.config.* or "vitest" key in package.json → Vitestpytest.ini, [tool.pytest.ini_options] in pyproject.toml → pytest
async def:
pytest-asyncio is in dependencies (pyproject.toml [project.dependencies] or [project.optional-dependencies])asyncio_mode is set in [tool.pytest.ini_options] (values: auto, strict, or absent)asyncio_mode configured → WARN: "pytest-asyncio not configured. Async tests may silently pass without executing async code. Recommend adding asyncio_mode = \"auto\" to [tool.pytest.ini_options] in pyproject.toml."Cargo.toml with #[cfg(test)] pattern → built-in cargo test*_test.go files present → built-in go testcypress.config.* → Cypress (E2E)playwright.config.* → Playwright (E2E)Verification gate: Framework identified before writing any test code.
Use Write to create test files following the detected conventions:
Mirror source file location: if source is src/auth/login.ts, test is src/auth/login.test.ts
Structure tests with clear describe / it blocks (or language equivalent):
describe('Feature name')
it('should [expected behavior] when [condition]')Cover all three categories:
Use proper assertions. Do NOT use implementation details — test behavior:
expect(result).toBe(expected)assert result == expectedassert_eq!(result, expected)if result != expected { t.Errorf(...) }For async code: use async/await or pytest @pytest.mark.asyncio
Full detail moved to
references/python-async.md(progressive disclosure). Read that file before executing this section.
Before running the new test in Phase 4, count what's about to be added to the working tree:
bulk_test_count = (test files staged + test files unstaged but new) since the last GREEN commit
Gate: bulk_test_count MUST be exactly 1.
| State | Action |
|---|---|
bulk_test_count == 1 | Proceed to Phase 4 (run RED). |
bulk_test_count >= 2 AND no prior GREEN this session | HORIZONTAL VIOLATION — pause, keep one test, defer the rest. |
bulk_test_count >= 2 AND last GREEN exists in git log | HORIZONTAL VIOLATION — same. |
bulk_test_count == 0 | No test to run; this phase is a no-op. |
Cycle audit log — append to TEST.md (or create) one line per cycle:
cycle 1 — RED: test_validates_email_rejects_empty | GREEN: validateEmail handles empty | commit: 4f3a1c
cycle 2 — RED: test_validates_email_requires_at_sign | GREEN: validateEmail checks @ | commit: a92e0d
The audit log is the receipt. completion-gate reads it.
When the violation fires, do NOT delete tests automatically — surface to the calling agent: "horizontal slicing detected (N tests before first GREEN). Recommend keeping test K, deferring N-1 to subsequent cycles."
Use Bash to run ONLY the newly created test files (not full suite):
npx jest path/to/test.ts --no-coveragenpx vitest run path/to/test.tspytest path/to/test_file.py -v (if async tests and no asyncio_mode in config: add --asyncio-mode=auto)cargo test test_module_namego test ./path/to/package/... -run TestFunctionNameHard gate: ALL new tests MUST fail at this point.
After rune:fix writes implementation code, run the same test command again:
Bash to check for regressions:
npm test, pytest, cargo test, go test ./...rune:debugVerification gate: 100% of new tests pass AND 0 regressions in existing tests.
After GREEN phase, call verification to check coverage threshold (80% minimum):
When invoked with mode: "diff-aware" or by cook after implementation:
git diff main --name-only to get changed filesThis mode is valuable for large codebases where running the full suite is slow. It answers: "what could this diff have broken?"
Input: git diff main --name-only
Output: Prioritized test plan targeting only affected paths
Full detail moved to
references/test-types.md(progressive disclosure). Read that file before executing this section.
Full detail moved to
references/test-plan-doc.md(progressive disclosure). Read that file before executing this section.
Full detail moved to
references/evals.md(progressive disclosure). Read that file before executing this section.
package.json devDependenciesWrite to test file fails: check if directory exists, create it first with Bash mkdir -pBash test runner hangs beyond 120 seconds: kill and report as TIMEOUTcook (L1): Phase 3 TEST — write tests firstfix (L2): verify fix passes testsreview (L2): untested edge case found → write test for itdeploy (L2): pre-deployment full test suitepreflight (L2): run targeted regression tests on affected codesurgeon (L2): verify refactored codelaunch (L1): pre-deployment test suitesafeguard (L2): writing characterization tests for legacy codereview-intake (L2): write tests for issues identified during review intakescaffold (L1): generate initial test suite for new projectgraft (L2): write integration tests for grafted codeskill-forge (L2): write tests for new skill functionalitymcp-builder (L2): write tests for MCP server toolsdebug (L2): write regression test capturing the bugplan (L2): reference test requirements in implementation planverification (L3): Phase 6 — coverage check (80% minimum threshold)browser-pilot (L3): Phase 4 — e2e and visual testing for UI flowsdebug (L2): Phase 5 — when existing test regresses unexpectedlycook (L1): test results (pass/fail/coverage) → cook's Phase 5 quality gate evidencecompletion-gate (L3): test runner stdout → evidence for "tests pass" claimsfix (L2): failing test output → fix's target (what to make green)plan (L2): phase file test tasks → test's RED phase targets (what to test)review (L2): untested edge cases found during review → new test targetsfix (L2): implemented code → test's GREEN phase verification targettest ↔ fix: test writes failing tests (RED) → fix implements to pass → test verifies (GREEN) → if new failures emerge, loop continuestest ↔ debug: test discovers regression → debug diagnoses root cause → test writes regression test to prevent recurrence| Excuse | Reality |
|---|---|
| "Too simple to need tests first" | Simple code breaks. Test takes 30 seconds. Write it first. |
| "I'll write tests after — same result" | Tests-after = "what does this do?" Tests-first = "what SHOULD this do?" Completely different. |
| "I already wrote the code, let me just add tests" | Iron Law: delete the code. Start over with tests. Sunk cost is not an argument. |
| "Tests after achieve the same goals" | They don't. Tests-after are biased by the implementation you just wrote. |
| "It's about spirit not ritual" | Violating the letter IS violating the spirit. Write the test first. |
| "I mentally tested it" | Mental testing is not testing. Run the command, show the output. |
| "This is different because..." | It's not. Write the test first. |
| "I'll batch the tests since they're related" | Batched tests = tests of imagination. Each cycle reacts to the prior. Write one, GREEN it, then the next. |
| "All five tests are already written, let me just review them with you" | Same fallacy as code-before-test. Keep the first one, defer the others to subsequent cycles. |
Full detail moved to
references/oracle-e2e.md(progressive disclosure). Read that file before executing this section.
Full detail moved to
references/traceability.md(progressive disclosure). Read that file before executing this section.
Full detail moved to
references/evals.md(progressive disclosure). Read that file before executing this section.
If you catch yourself with ANY of these, delete implementation code and restart with tests:
All of these mean: Delete code. Start over with TDD.
test: then feat:) — git log is the audit trail for "I did TDD" claims| Gate | Requires | If Missing |
|---|---|---|
| RED Gate | All new tests FAIL before implementation | If any pass, rewrite stricter tests |
| GREEN Gate | All tests PASS after implementation | Fix code, not tests |
| Coverage Gate | 80%+ coverage verified via verification | Write additional tests for gaps |
| Integrity Gate | rune verify --integrity (also preflight / sentinel hooks) is clean, or an auditable override is present | Do not weaken, skip, or retarget tests to get green — see references/test-integrity-gate.md |
## Test Report
- **Framework**: [detected]
- **Files Created**: [list of new test file paths]
- **Tests Written**: [count]
- **Status**: RED (failing as expected) | GREEN (all passing)
### Test Cases
| Test | Status | Description |
|------|--------|-------------|
| `test_name` | FAIL/PASS | [what it tests] |
### Coverage
- Lines: [X]% | Branches: [Y]%
- Gaps: `path/to/file.ts:42-58` — uncovered branch (error handling)
### Regressions (if any)
- [existing test that broke, with error details]
Full detail moved to
references/testing-anti-patterns.md(progressive disclosure). Read that file before executing this section.
| Artifact | Format | Location |
|---|---|---|
| Test files | Source files | Co-located or __tests__/ per project convention |
| Test plan + results | Markdown | TEST.md in test directory (non-trivial features only) |
| Eval scenarios | Markdown | skills/<name>/evals.md (for skill behavior testing) |
| Coverage report | Inline stdout | Shown in Test Report |
| Test Report | Markdown (inline) | Emitted to calling skill (cook, fix, review) |
Append to Test Report when invoked standalone. Suppress when called as sub-skill inside an L1 orchestrator (cook, team, etc.) — the orchestrator emits a consolidated block. See docs/references/chain-metadata.md.
chain_metadata:
skill: "rune:test"
version: "1.2.0"
status: "[DONE]"
domain: "[area tested]"
files_changed:
- "[test files created/modified]"
exports:
test_results: { passed: [N], failed: [N], coverage: [N] }
test_files: ["[paths to test files]"]
status: "[RED | GREEN]" # RED = TDD failing (expected), GREEN = all pass
suggested_next: # status-aware — pick based on RED or GREEN
# When GREEN:
- skill: "rune:preflight"
reason: "[grounded in results — e.g., 'All 15 tests GREEN, check edge case completeness']"
consumes: ["test_results", "test_files"]
# When RED (TDD expected):
- skill: "rune:fix"
reason: "[grounded in failures — e.g., '3 tests RED as expected, implement to make them pass']"
consumes: ["test_results", "test_files"]
Known failure modes for this skill. Check these before declaring done.
| Failure Mode | Severity | Mitigation |
|---|---|---|
| Tests passing before implementation exists | CRITICAL | RED Gate: rewrite stricter tests — passing without code = not testing real behavior |
| Skipping the RED phase (not confirming FAIL) | HIGH | Run tests, confirm FAIL output before calling cook/fix to implement |
| Testing mock behavior instead of real code | HIGH | Anti-Pattern 1 gate: "Am I testing real behavior or mock existence?" |
| Mocking without understanding side effects | HIGH | Anti-Pattern 3 gate: run with real impl first, observe side effects, THEN mock minimally |
| Incomplete mocks missing downstream fields | HIGH | Anti-Pattern 4 iron rule: mock COMPLETE data structure, not just fields your test checks |
| Coverage below 80% without filling gaps | MEDIUM | Coverage Gate: identify uncovered lines and write additional tests |
| Introducing a new test framework instead of using existing one | MEDIUM | Constraint 6: detect framework first, use project's existing one always |
| Modifying source files to make tests work | HIGH | Role boundary: test writes test files ONLY — source changes go to rune:fix |
| Test-only methods leaking into production code | MEDIUM | Anti-Pattern 2 gate: if method only called by tests → move to test utilities |
| Bulk test writing before first GREEN (horizontal slicing) | CRITICAL | Phase 3.5 gate — bulk_test_count <= 1, defer additional tests to subsequent cycles |
Test names describe shape (returns boolean, has property) instead of behavior | MEDIUM | Scan names for shape-words; rewrite to behavior verbs (accepts/rejects/produces). See references/test-quality.md |
| Mocking internal collaborators in same module | HIGH | System-boundary rule from references/mocking-policy.md — mock only what you don't own |
| Layering old shallow-module tests on top of new deepened-interface tests | MEDIUM | After improve-architecture deepens a module, REPLACE tests don't ADD them; one interface = one test surface |
SELF-VALIDATION (run before emitting Test Report):
- [ ] Every test file has at least one assertion — no empty test bodies
- [ ] RED phase output shows actual failures (not "0 tests") — tests were real, not stubs
- [ ] No test modifies source code — test files only, source changes belong to fix
- [ ] Test names describe behavior, not implementation ("should reject expired token" not "test function X")
- [ ] No mocks of the thing being tested — only mock external dependencies
- [ ] If BA requirements exist (REQ-xxx), every requirement has at least one test — check plan's Traceability Matrix
git log, no orphan tests pre-first-GREEN~$0.03-0.08 per invocation. Sonnet for writing tests, Bash for running them. Frequent invocation in TDD workflow.
Scope guardrail: Do not modify source or implementation files to make tests pass unless explicitly delegated by the parent agent.
evals.md (opens in a new tab)references/evals.md (opens in a new tab)references/mocking-policy.md (opens in a new tab)references/oracle-e2e.md (opens in a new tab)references/python-async.md (opens in a new tab)references/test-integrity-gate.md (opens in a new tab)references/test-plan-doc.md (opens in a new tab)references/test-quality.md (opens in a new tab)references/test-types.md (opens in a new tab)references/testing-anti-patterns.md (opens in a new tab)references/traceability.md (opens in a new tab)references/vertical-tdd.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
67 skills in this plugin
/adversaryPre-implementation red-team analysis. Use when a plan is high-risk, critical path, or expensive to reverse. Challenges plans before code is written — finds edge cases, security holes, scalability bottlenecks, error propagation risks, and integration conflicts. Catches flaws at plan time (10x cheaper than post-implementation)./asset-creatorCreates code-based visual assets — SVG icons, OG image HTML templates, social banners, and icon sets. Use when generating visuals as code (vector/HTML), NOT raster images — for raster generation see @rune-pro/media. Outputs files with usage instructions./auditComprehensive project audit — security, dependencies, code quality, architecture, performance, infra, docs, and mesh analytics. Use when needing a full 8-dimension health-score snapshot before a major release, M&A diligence, or quarterly review. Delegates to specialist skills (sentinel, dependency-doctor, perf, autopsy, etc.)./autopsyFull codebase health assessment. Use when diagnosing project health or starting a rescue workflow on legacy code — OR when evaluating an external GitHub repo for dependency / fork / contribution decisions (--external mode). Analyzes complexity, dependencies, dead code, tech debt, and git hotspots. Produces a health score and rescue plan./baBusiness Analyst agent. Use when starting a new feature requiring requirements elicitation BEFORE plan or cook. Asks probing questions, identifies hidden requirements, maps stakeholders, defines scope boundaries, and produces a structured Requirements Document that plan and cook consume./brainstormCreative ideation and solution exploration. Use when a task is vague or open-ended, several approaches are viable, or the current approach has fundamentally failed ('ideas', 'explore options', 'what are the ways to'). Generates multiple approaches with trade-offs using structured frameworks (SCAMPER, First Principles) and hands off to plan.npx claudepluginhub rune-kit/rune --plugin runeOther plugins' skills for the same job