Skip to main content
rule CX Codex

testing · jarrodwatts — Claude Code rule: tests and installation

The testing rule sets conventions for TypeScript test files and the __tests__ directory. Use it to guide checks for success cases, failures, and edge conditions.

no license ★ 1,064 updated 2026-01-21

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/testing.md
Open on GitHub

What testing does

The rule targets *.test.ts, *.spec.ts, and files under __tests__. It calls for tests organized around a setup, an action, and an expected result, with names that describe the scenario and one logical check in each test. That structure keeps cases such as UserService lookups easy to follow.

Use mocks for external APIs and databases, but keep the unit being tested real; clear mocks between tests. The rule also covers normal results, errors, empty and boundary values, plus loading, success, and error states for async code. If mocks are not reset, state can carry over between tests.

What it helps with

  • organize tests around setup, action, and expected result
  • name tests after the scenario they check
  • isolate external APIs and databases with mocks
  • cover error paths and boundary values
  • check loading and result states in async code

Example prompts for the agent

  • Apply the testing rule to UserService tests and cover a successful lookup.
  • Add tests for an API failure and an empty result, following the testing rule.
  • Check that mocks are reset between tests under __tests__.

How to install testing

Manually: put the files in place

.claude/rules/testing.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about testing

How do I install testing in Claude Code?

Add the rule file to your project at .claude/rules/testing.md.

What does the testing rule do?

It sets conventions for test structure, mocks, and checks for failures, edge cases, and async states.

Which files does testing apply to?

It applies to *.test.ts, *.spec.ts, and files under __tests__.

Similar IDE rules

All IDE rules for Testing and QA →

testing by other authors comes first.

testing caliber-ai-org Defines Vitest testing patterns for Caliber, enforcing colocated test suites, environment isolation, and global LLM mocks. CX Codex +1 ★ 1,319repo stars testing sangrokjung testing enforces a strict TDD workflow in Claude Code with an 80% coverage floor, Playwright E2E suites, and three test tiers. CX Codex +1 ★ 880repo stars testing justxor testing sets automated test standards for Claude Code: Arrange-Act-Assert structure, banned sleep calls, and strict boundaries for mocks. CX Codex +1 ★ 353repo stars testing Aaronontheweb Defines xUnit testing conventions for .NET: project configurations, test isolation, coverage thresholds, and integration test setup. CX Codex +1 ★ 138repo stars caliber-testing caliber-ai-org caliber-testing is a Claude Code skill that generates Vitest tests with process.env resets, vi.hoisted mocks, and test files placed in __tests__ directories. CX Codex +1 ★ 1,319repo stars testing-boss Pedro Nauck testing-boss guides test writing and LLM eval design: helps pick the right test layer, trim fragile mocks, and diagnose flaky CI suites without adding dummy production code. CX Codex +1 274installs testing-patterns caliber-ai-org testing-patterns is a Claude Code rule for Vitest conventions: test locations, LLM mocks, and running a single spec. CX Codex +1 ★ 1,319repo stars safe-extraction ZaxbyHub safe-extraction guides the safe refactoring of monolithic files into submodules. Keeps test mocks working through _internals proxies, preserves public APIs, and updates CI path allowlists. CX Codex +1 ★ 539repo stars writing-tests ZaxbyHub writing-tests is a Claude Code skill that sets test conventions for opencode-swarm. It loads before an agent edits a test file. CX Codex +1 ★ 539repo stars e2e-testing affaan-m Playwright E2E testing patterns covering Page Object Model setup, CI/CD configuration, flaky test quarantine, and artifact capture. CX Codex +1 7,200installs

From the same set20

The whole set →
js-combine-iterations js-combine-iterations tells the Claude agent to replace several filter or map passes over the same array with one loop that fills the results as it goes. CX Codex +1 ★ 1,064repo stars bundle-dynamic-imports bundle-dynamic-imports guides Claude Code to lazy-load heavy components using next/dynamic with SSR disabled. Keeps your initial client bundle lean to protect TTI and LCP metrics. CX Codex +1 ★ 1,064repo stars rendering-content-visibility The rendering-content-visibility rule applies content-visibility: auto to long lists so off-screen items can wait before rendering. It fits message feeds and other scrollable collections. CX Codex +1 ★ 1,064repo stars rerender-dependencies rerender-dependencies — a Claude rule that keeps useEffect dependency arrays on primitives like user.id rather than whole objects, so an effect stops firing on every field change. CX Codex +1 ★ 1,064repo stars forge The forge rule configures Foundry workflows for Abstract and tells Claude Code to use the ZKsync mode for Solidity projects. CX Codex +1 ★ 1,064repo stars js-batch-dom-css js-batch-dom-css — a Claude rule that keeps the agent from writing styles one property at a time and pushes it toward a class or a single cssText string. CX Codex +1 ★ 1,064repo stars codebase-search codebase-search finds where a feature lives in your repo and hands back absolute paths plus a short explanation of the flow. CX Codex ★ 1,064repo stars media-interpreter media-interpreter — a subagent for working with PDFs, images, diagrams, and other binary formats. Extracts text, tabular data, and descriptions of visual content when standard file reading isn't an option. CX Codex ★ 1,064repo stars

Project sponsors

Companies that keep this analytics open