testing · sangrokjung — Claude Code rule: what it does, how to install
testing enforces a strict TDD workflow in Claude Code with an 80% coverage floor, Playwright E2E suites, and three test tiers.
MIT ★ 880 updated 2026-09-03
.claude/rules/testing.mdWhat testing does
The rule triggers on test files matching patterns such as **/*.test.*, **/*.spec.*, **/tests/**, and **/playwright/**. It forces Claude Code into a strict test-driven development loop: write a failing test first, provide minimal code to pass, refactor, and verify that coverage reaches at least 80%.
Every project under this rule must include three tiers of testing: unit tests for functions, integration tests for APIs and databases, and Playwright end-to-end tests for critical flows. When a suite fails, the agent must fix the application code rather than altering the test assertions.
Without Playwright installed in the repository, the required end-to-end stage will fail because the instructions mandate that specific runner.
What it helps with
- force the assistant to write failing tests before writing feature code
- keep codebase test coverage at or above 80%
- automate critical user flows with Playwright end-to-end tests
- separate unit, integration, and E2E test layers across the project
Example prompts for the agent
- Implement the order cancellation endpoint using the mandatory TDD workflow
- Write unit tests for the date parsing utility and ensure coverage is at least 80%
- Use e2e-runner to add Playwright tests for the checkout flow
How to install testing
Manually: put the files in place
.claude/rules/testing.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/testing.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/testing.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/testing.mdManually: put the files in place
.clinerules/testing.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about testing
How to install testing in Claude Code?
Save the rule file to .claude/rules/testing.md in the root of your project.
What coverage does the testing rule demand?
It mandates an 80% minimum test coverage across the codebase along with unit, integration, and E2E suites.
Which test runner is required for end-to-end suites?
The rule explicitly requires Playwright for end-to-end user flows and references the e2e-runner specialist agent.
Source text
testing.md · MIT
--- paths: - "**/*.test.*" - "**/*.spec.*" - "**/tests/**" - "**/__tests__/**" - "**/playwright/**" --- # Testing Requirements ## Minimum Test Coverage: 80% Test Types (ALL required): 1. **Unit Tests** - Individual functions, utilities, components 2. **Integration Tests** - API endpoints, database operations 3. **E2E Tests** - Critical user flows (Playwright) ## Test-Driven Development MANDATORY workflow: 1. Write test first (RED) 2. Run test - it should FAIL 3. Write minimal implementation (GREEN) 4. Run test - it should PASS 5. Refactor (IMPROVE) 6. Verify coverage (80%+) ## Troubleshooting Test Failures 1. Use **tdd-guide** agent 2. Check test isolation 3. Verify mocks are correct 4. Fix implementation, not tests (unless tests are wrong) ## Agent Support - **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first - **e2e-runner** - Playwright E2E testing specialist
© sangrokjung · MIT · sangrokjung/claude-forge
Similar IDE rules
All IDE rules for Testing and QA →testing by other authors comes first.