Skip to content
Habits

Tests AGENTS.md

A test file is the cheapest way to keep an agent honest. This starter tells it to reproduce a bug with a failing test, to use the runner the repository already has, and to show the command output in the summary.

Paste, then edit

It does not pick Jest or pytest for you. The language files name those commands. Paste this next to them.

In this stack

What to tell the agent

Do

  • Name the test command and the directory it reads.
  • Say how to run one file, so the agent does not run a ten-minute suite for a one-line fix unless CI will.
  • Point at a short test that shows the style you want.
  • Ask for a regression test when the change fixes a reported bug.

Leave alone

  • Deleting a failing test to finish the task.
  • Snapshotting an entire page for a logic change.
  • Hitting production or a paid API from a unit test.
Starter file

AGENTS.md to copy

Save this as AGENTS.md at the root of the repository, or next to the package it covers. Replace the commands with the ones in this repo. See which agents read the file.

AGENTS.md
# Tests

## Order
- For a bug, first add a test that fails for the reason in the report. Then change the code until that test passes.
- For a new behavior, add a test that names the behavior, not the implementation detail.

## Runner
- Use the test command already in the repo. Do not add a second framework.
- Keep fixtures next to the tests that use them.
- A skipped test needs a comment and a link to the follow-up. Do not skip a test to make the suite green.

## What to assert
- Assert the outcome a caller can observe: the return value, the row, the status code, the text on the screen.
- Avoid asserting a private call sequence unless the sequence is the contract.

## Report
- Paste the command and the pass or fail line.
- If you could not run the suite, say why, and do not describe the work as verified.
Commands to confirm

Checks named in the file

Confirm each command exists here before you rely on it. Delete the ones this repository does not use.

  • The project's suite. pnpm test
  • One file, when the runner supports a path. pnpm test path/to/file.test.ts
FAQ

Questions

What is the Tests AGENTS.md for?

It tells an agent to reproduce the bug with the repository's existing test runner before changing production code.

Should the agent write the test before the fix?

For a bug, yes. A test that fails first shows the agent understood the report. A test written after the fix often asserts whatever the new code happens to do.

What belongs in the summary after a test run?

The command and the line that says it passed or failed. A summary that says verified, without that output, is a guess.

Keep going

Related on MCPpedia