test

A command for running and improving automated tests for a selected file, directory, feature, or the whole project. It identifies the scope, checks coverage, runs targeted and broader tests, and documents the results.

In plain words
What is it for?
Use it with a file, directory, feature, or `all` to run tests, debug failures, add coverage, and perform integration or full-suite checks.
Why use it?
It helps avoid testing only the most obvious cases and provides a process for investigating failures and missing coverage. It can coordinate frontend, backend, quality, and general testing work.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/awattar/claude-code-best-practices/test
Clone the repo
git clone --depth 1 https://github.com/awattar/claude-code-best-practices

Made for: Claude Code.

Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 954 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.00954
Opus 5 $0.00005 $0.00477
Sonnet 5 $0.00002 $0.00191
Haiku 4.5 $0.00001 $0.00095

Measured 2d ago against content hash 239a2576fb64, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/test.md · 130 lines

How it starts

The opening of the file, as written. The whole thing — 130 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude Code User Command: Test

This command helps you run and improve the test suite for the scope specified in $ARGUMENTS.

Usage

To test specific files or features, just type:

/test <file-or-directory>
/test <feature>

To test everything, just type:

/test all

What This Command Does

  1. Identifies test scope based on $ARGUMENTS (file, directory, feature or all).
  2. Checks current test coverage and runs targeted tests first.
  3. Executes integration and full test suite as needed.
  4. Fixes failing tests and adds missing test coverage.
  5. Documents results and commits improvements.

Agents Used

This command leverages specialized agents for comprehensive test suite management:

  • general-qa - Primary agent for comprehensive testing strategies and automation
  • general-code-quality-debugger - For debugging failing tests and improving test quality
  • general-backend-developer - For API testing and integration test implementation
  • general-frontend-developer - For UI testing with browser automation tools

Each agent contributes specialized expertise to ensure thorough project analysis and high-quality documentation generation.

Follow these steps:

General

Follow testing best practices and TDD principles. See GitHub's language-specific testing guides at https://docs.github.com/en/actions/how-tos/use-cases-and-examples/building-and-testing

Before starting:

  • Identify the project's test framework (e.g., RSpec, Jest, pytest, xUnit). Check package.json, Gemfile, requirements.txt, or project documentation.
  • Determine the browser automation tool for UI tests (e.g., puppeteer, playwright, selenium, cypress). Ask if unclear.
  • Identify E2E testing approach based on the application type (browser-based, API, CLI, or mixed).
  • Locate test configuration files and understand the test structure.
  • Check for any project-specific testing guidelines in documentation or README.

Assess

Understand the current testing landscape:

  1. Identify the scope:
    • If $ARGUMENTS is a file/directory, focus tests there.
    • If $ARGUMENTS is a feature, find all related specs.
    • If $ARGUMENTS is "all", prepare for full suite run.
  2. Check current test coverage:
    • Run coverage reports if available.
    • Identify untested or poorly tested areas.
  3. Review existing test patterns:
    • Search for similar test files as examples.
    • Check scratchpads for testing guidelines.

Read the full file on GitHub · 130 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 130 lines · 10 tokens per session scan A 239a2576fb64

Subscribe to this mod's changes

test is a command published in the GitHub repository awattar/claude-code-best-practices (250 stars, last pushed 3mo ago), licensed MIT. It adds 10 tokens to every session and 954 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.