Skip to main content
rule CX Codex

testing · justxor — Claude Code rule: what it does, how to install

testing sets automated test standards for Claude Code: Arrange-Act-Assert structure, banned sleep calls, and strict boundaries for mocks.

MIT ★ 353 updated 2026-10-01

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 files matching **/*.test.*, **/*.spec.*, tests/**, and __tests__/**. It requires every test to follow the Arrange → Act → Assert pattern with exactly one scenario per test. Test names must describe concrete behavior, such as returns 404 when task does not exist.

Mocks are restricted strictly to external systems: network calls, time, and the filesystem. Mocking internal application code is forbidden. Tests must not call sleep; instead, they must rely on fake timers or explicit waits.

Weakening assertions just to make a test pass is prohibited. If code behavior changes deliberately, the agent must state that change explicitly.

What it helps with

  • enforce Arrange → Act → Assert structure with one scenario per test
  • restrict mocks strictly to network, time, and filesystem boundaries
  • replace sleep delays with fake timers and explicit waiting
  • prevent weakening test assertions when checks fail

Example prompts for the agent

  • Write unit tests for the auth service in tests/auth.test.ts
  • Refactor api.spec.ts to replace sleep with fake timers
  • Add a test verifying returns 404 when task does not exist

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 to install testing in Claude Code?

Create the file .claude/rules/testing.md in your repository and paste the rule text into it.

Which file paths does the testing rule affect?

It applies to **/*.test.*, **/*.spec.*, and all paths inside tests/** or __tests__/**.

Does this rule allow mocking internal helpers?

No, internal application code must not be mocked. Mocks are permitted only for external systems like network, time, and the disk.

Source text

testing.md · MIT
---
paths:
  - "**/*.test.*"
  - "**/*.spec.*"
  - "tests/**"
  - "__tests__/**"
---

# Правила для тестов

- Структура: Arrange → Act → Assert, один сценарий — один тест.
- Имена тестов описывают поведение: `returns 404 when task does not exist`.
- Моки — только для внешних систем (сеть, время, файловая система). Свой код не мокаем.
- Никаких `sleep`: используй фейковые таймеры и явное ожидание.
- Не ослабляй проверки, чтобы тест прошёл. Если поведение изменилось намеренно — скажи об этом явно.

© justxor · MIT · justxor/claude-code-pro-course

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 jarrodwatts 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. CX Codex +1 ★ 1,064repo 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 Aaronontheweb Defines xUnit testing conventions for .NET: project configurations, test isolation, coverage thresholds, and integration test setup. CX Codex +1 ★ 138repo stars unit-testing-framework aj-geddes unit-testing-framework — a skill for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode: writes unit tests following the AAA pattern with mocks and coverage for critical paths. CX Codex +1 633installs testing-principles shinpr testing-principles — a skill for Claude Code enforces language-agnostic guidelines for test selection, mock boundaries, and assertion design. Triggers when writing new tests, planning test scope, or reviewing test suites. CX Codex +1 ★ 720repo stars shift-left-testing kindlmann shift-left-testing brings quality validation into refinement, design, and code review. It helps engineering teams run Three Amigos sessions, adopt TDD, and enforce testability before code hits staging. CX Codex +1 1,300installs test-driven-development addyosmani The test-driven-development Claude Code skill guides code changes through the red-green-refactor cycle. It activates for new logic, bug fixes, and changes to existing behavior. CX Codex +1 78,300installs principle-test-behavior-not-implementation backnotprop principle-test-behavior-not-implementation is a Claude Code skill that guides testing public behavior over internals. It activates whenever tests are authored, modified, or reviewed. CX Codex +1 10,200installs tdd backnotprop tdd is a Claude Code skill that enforces writing an executable failing test before changing bugged code. It runs on explicit TDD prompts or cheap local test paths. CX Codex +1 10,000installs

From the same set15

The whole set →
review This skill checks code changes for security issues and exposed secrets, then reports findings with risk levels and file locations. Run it before a merge or when asked for a security review. CX Codex +1 ★ 353repo stars fix-issue fix-issue — a skill that runs the full cycle of fixing a GitHub issue by number — from analysis and test to commit. CX Codex +1 ★ 353repo stars test-runner test-runner runs tests on modified files, diagnoses failures, and distinguishes real code bugs from outdated test suites. CX Codex ★ 353repo stars debugger The debugger subagent reproduces errors and failing tests, tracks down their cause, then checks the fix. Use it when a stack trace or unexpected behavior needs investigation. CX Codex ★ 353repo stars docs-writer docs-writer — a subagent that updates README, API docs, code comments, and ADRs whenever your code changes. It verifies actual behavior and keeps examples aligned with reality. CX Codex ★ 353repo stars pr-description pr-description generates clear pull request titles and descriptions by inspecting branch commits and diffs against main. CX Codex +1 ★ 353repo stars architect The architect subagent examines a project before implementation, compares design options, and lays out a change plan. Use it to scope a feature or a major refactor. CX Codex ★ 353repo stars code-reviewer code-reviewer reads your diff, flags security holes, missing tests and edge cases, then returns a severity-sorted report with a file and line for each fix. CX Codex ★ 353repo stars

Project sponsors

Companies that keep this analytics open