rune-kit/rune/test

Claude Code and agent skill by rune-kit/rune

Trust tier 1
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

TDD test writer. Use before implementing any feature or fix (write the failing test first), when the user asks to 'write tests', or when coverage is missing. Writes failing tests FIRST (red), then verifies they pass after implementation (green). Covers unit, integration, and e2e tests.

Install

npx vskill@latest install rune-kit/rune/test

SKILL.md

The same SKILL.md was published earlier as rune-kit/rune/test.

test

<HARD-GATE> Tests define the EXPECTED BEHAVIOR. They MUST be written BEFORE implementation code. If tests pass without implementation → the tests are wrong. Rewrite them. The only exception: when retrofitting tests for existing untested code.

THE IRON LAW: Write code before test? DELETE IT. Start over.

  • Do NOT keep it as "reference"
  • Do NOT "adapt" it while writing tests
  • Do NOT look at it to "inform" test design
  • Delete means delete. 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.

  • Do NOT "quickly fix" a broken import in source to make tests run
  • Do NOT refactor source code to be "more testable"
  • Do NOT add missing exports to source files
  • If source needs changes → hand off to 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.

  • bulk_test_count MUST stay <= 1 before the first GREEN in a session
  • After each GREEN, bulk_test_count resets to 0; writing 2+ tests before the next GREEN = HORIZONTAL VIOLATION
  • Each cycle MUST emit a commit pair: test(scope): <behavior> + feat(scope): <behavior>
  • Claim "I did TDD" is verified by completion-gate against git log --oneline — no paired commits = REJECTED
  • Horizontal slicing produces tests-of-imagination, not tests-of-behavior. See references/vertical-tdd.md.
  • Emit signal tdd.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. </HARD-GATE>

Instructions

Phase 1: Understand What to Test
  1. Read the implementation plan or task description carefully
  2. Use Glob to find existing test files: **/*.test.*, **/*.spec.*, **/test_*
  3. Use Read on 2-3 existing test files to understand:
  • Test framework in use
  • File naming convention (e.g., foo.test.ts mirrors foo.ts)
  • Test directory structure (co-located vs __tests__/ vs tests/)
  • Assertion style and patterns
  1. Use Glob to find the source file(s) being tested
TodoWrite: [
{ 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" }
]
Phase 2: Detect Test Framework

Use Glob to find config files and identify the framework:

  • jest.config.* or "jest" key in package.json → Jest
  • vitest.config.* or "vitest" key in package.json → Vitest
  • pytest.ini, [tool.pytest.ini_options] in pyproject.toml → pytest
  • Async check: If pytest detected AND source files contain async def:
  • Check if pytest-asyncio is in dependencies (pyproject.toml [project.dependencies] or [project.optional-dependencies])
  • Check if asyncio_mode is set in [tool.pytest.ini_options] (values: auto, strict, or absent)
  • If async code exists but no 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 test
  • cypress.config.* → Cypress (E2E)
  • playwright.config.* → Playwright (E2E)

Verification gate: Framework identified before writing any test code.

Phase 3: Write Failing Tests

Use Write to create test files following the detected conventions:

  1. Mirror source file location: if source is src/auth/login.ts, test is src/auth/login.test.ts
  2. Structure tests with clear describe / it blocks (or language equivalent):
  • describe('Feature name')
  • it('should [expected behavior] when [condition]')
  1. Cover all three categories:
  • Happy path: valid inputs, expected success output
  • Edge cases: empty input, boundary values, large input
  • Error cases: invalid input, missing data, network failure simulation
  1. Use proper assertions. Do NOT use implementation details — test behavior:
  • Jest/Vitest: expect(result).toBe(expected)
  • pytest: assert result == expected
  • Rust: assert_eq!(result, expected)
  • Go: if result != expected { t.Errorf(...) }
  1. For async code: use async/await or pytest @pytest.mark.asyncio
Python Async Tests (pytest-asyncio)
Full detail moved to `references/python-async.md` (progressive disclosure). Read that file before executing this section.
Phase 3.5: Cycle Discipline (Vertical Slicing Gate)

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.

StateAction
bulk_test_count == 1Proceed to Phase 4 (run RED).
bulk_test_count >= 2 AND no prior GREEN this sessionHORIZONTAL VIOLATION — pause, keep one test, defer the rest.
bulk_test_count >= 2 AND last GREEN exists in git logHORIZONTAL VIOLATION — same.
bulk_test_count == 0No 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."

Phase 4: Run Tests — Verify They FAIL (RED)

Use Bash to run ONLY the newly created test files (not full suite):

  • Jest: npx jest path/to/test.ts --no-coverage
  • Vitest: npx vitest run path/to/test.ts
  • pytest: pytest path/to/test_file.py -v (if async tests and no asyncio_mode in config: add --asyncio-mode=auto)
  • Rust: cargo test test_module_name
  • Go: go test ./path/to/package/... -run TestFunctionName

Hard gate: ALL new tests MUST fail at this point.

  • If ANY test passes before implementation exists → that test is not testing real behavior. Rewrite it to be stricter.
  • If tests fail with import/syntax errors (not assertion errors) → fix the test code, re-run
Phase 5: After Implementation — Verify Tests PASS (GREEN)

After rune:fix writes implementation code, run the same test command again:

  1. ALL tests in the new test files MUST pass
  2. Run the full test suite with Bash to check for regressions:
  • npm test, pytest, cargo test, go test ./...
  1. If any test fails: report clearly which test, what was expected, what was received
  2. If an existing test now fails (regression): escalate to rune:debug

Verification gate: 100% of new tests pass AND 0 regressions in existing tests.

Phase 6: Coverage Check

After GREEN phase, call verification to check coverage threshold (80% minimum):

  • If coverage drops below 80%: identify uncovered lines, write additional tests
  • Report coverage gaps with file:line references
Phase 6.5: Diff-Aware Mode (optional)

When invoked with mode: "diff-aware" or by cook after implementation:

  1. Run git diff main --name-only to get changed files
  2. For each changed file, trace its blast radius: what imports it? what routes does it serve? what components render it?
  3. Map changed files → affected routes/endpoints/pages
  4. Prioritize tests: files with most downstream dependents get tested first
  5. Generate targeted test commands that cover ONLY affected paths — skip unchanged modules

This 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

Test Types — 4-Layer Methodology

Full detail moved to `references/test-types.md` (progressive disclosure). Read that file before executing this section.

TEST.md — Test Plan + Results Document

Full detail moved to `references/test-plan-doc.md` (progressive disclosure). Read that file before executing this section.

Skill Behavior Tests (Eval Scenarios)

Full detail moved to `references/evals.md` (progressive disclosure). Read that file before executing this section.

Error Recovery

  • If test framework not found: ask calling skill to specify, or check package.json devDependencies
  • If Write to test file fails: check if directory exists, create it first with Bash mkdir -p
  • If tests error on import (module not found): check that source file path is correct, adjust imports
  • If Bash test runner hangs beyond 120 seconds: kill and report as TIMEOUT

Called By (inbound)

  • cook (L1): Phase 3 TEST — write tests first
  • fix (L2): verify fix passes tests
  • review (L2): untested edge case found → write test for it
  • deploy (L2): pre-deployment full test suite
  • preflight (L2): run targeted regression tests on affected code
  • surgeon (L2): verify refactored code
  • launch (L1): pre-deployment test suite
  • safeguard (L2): writing characterization tests for legacy code
  • review-intake (L2): write tests for issues identified during review intake
  • scaffold (L1): generate initial test suite for new project
  • graft (L2): write integration tests for grafted code
  • skill-forge (L2): write tests for new skill functionality
  • mcp-builder (L2): write tests for MCP server tools
  • debug (L2): write regression test capturing the bug
  • plan (L2): reference test requirements in implementation plan

Calls (outbound)

  • verification (L3): Phase 6 — coverage check (80% minimum threshold)
  • browser-pilot (L3): Phase 4 — e2e and visual testing for UI flows
  • debug (L2): Phase 5 — when existing test regresses unexpectedly

Data Flow

Feeds Into →
  • cook (L1): test results (pass/fail/coverage) → cook's Phase 5 quality gate evidence
  • completion-gate (L3): test runner stdout → evidence for "tests pass" claims
  • fix (L2): failing test output → fix's target (what to make green)
Fed By ←
  • plan (L2): phase file test tasks → test's RED phase targets (what to test)
  • review (L2): untested edge cases found during review → new test targets
  • fix (L2): implemented code → test's GREEN phase verification target
Feedback Loops ↻
  • test ↔ fix: test writes failing tests (RED) → fix implements to pass → test verifies (GREEN) → if new failures emerge, loop continues
  • test ↔ debug: test discovers regression → debug diagnoses root cause → test writes regression test to prevent recurrence

Anti-Rationalization Table

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 0 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
77
Repository forks
21
7-day trend score
22

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/rune-kit/rune/test/badge)](https://verified-skill.com/skills/rune-kit/rune/test)

Something wrong with this skill or its page? Tell us.