Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud
AICodingTesting Strategies

AGENTS.md as a Testing Contract, Not Just Style Notes

Turn AGENTS.md into a testing contract: the commands an agent must run, what done means, how to handle a failing suite, and what it must never touch.

Author

Prince Dewani

Author

Author

Srinivasan Sekar

Reviewer

Published on: August 27, 2026

AGENTS.md is a plain-Markdown file AI coding agents read from a repository, and it earns most when it carries testing rules a machine can check. ETH Zurich researchers found context files gave no general gain in task success while raising inference cost over 20%, because agents follow explicit instructions and ignore repository overviews.[1]

This guide covers which agents read the file, whether it measurably helps, the four clauses of a testing contract, a complete worked example, monorepo precedence, the CLAUDE.md relationship, and how to verify compliance.

Key Takeaways

  • Instructions over overviews: ETH Zurich's evaluation found coding agents follow explicit instructions in a context file but gain nothing from repository summaries.
  • Four contract clauses: Name the exact commands, the definition of done, the failing-suite protocol, and the prohibitions, then stop writing.
  • Nearest file wins: In a monorepo the file closest to the edited code takes precedence, so package-level rules override the repository root.
  • Context, not enforcement: Anthropic documents memory files as context rather than enforced configuration, which leaves continuous integration as the layer that actually blocks a merge.
  • 200-line working limit: Anthropic targets under 200 lines per CLAUDE.md file and warns that longer files reduce adherence.
  • Never-delete-a-test rule: GitHub's review of 2,500 repositories found the strongest testing boundary forbids removing a test because it is failing.

What Is AGENTS.md and Which Agents Read It?

AGENTS.md is an open Markdown format that AI coding agents read for project instructions. Codex, Cursor, Copilot, Gemini CLI, and Devin support it across more than 60,000 public repositories.[2]

The format carries no JSON schema and no YAML frontmatter. It is Markdown in the repository root, versioned with the code, reviewed in the same pull requests. The Agentic AI Foundation stewards it under the Linux Foundation, which is why adoption spread across vendors that compete with each other.

Claude Code is the exception, because it reads CLAUDE.md and not the shared file, so mixed toolchains import or symlink one into the other.[3] Teams comparing terminal tooling on this basis will find the same split in agentic coding CLI tools.

Do Context Files Improve Coding Agent Results?

No. ETH Zurich researchers evaluating context files across SWE-bench tasks found no general gain in task success and over 20% higher inference cost, though agents did follow explicit instructions.[1]

The split inside the ETH Zurich result is the useful part. The paper reports that instructions in context files are well followed, while repository overviews are not helpful, and it recommends that human-written files describe only minimal requirements.

The work comes from the SRI Lab at ETH Zurich and was presented at the MemAgents workshop at ICLR 2026.[4]

The instruction-versus-overview split gives the design rule. An instruction an agent can execute changes behaviour. A paragraph describing the architecture spends context budget and returns nothing measurable, because the agent can read the architecture from the code.

The evidence makes the case for treating the file as a testing contract. Style notes and architecture summaries are overviews. Commands, exit criteria, and prohibitions are instructions, and the ETH Zurich evaluation found only instructions changed agent behaviour.

What Turns Style Notes Into a Testing Contract?

Four clauses do it: the exact commands to run, the definition of done, the protocol for a failing suite, and the prohibitions. Each one states something the agent can execute rather than interpret.

GitHub reached a similar conclusion from the other direction. Reviewing more than 2,500 repositories, its team found the pattern that works is a specific job, exact commands, well-defined boundaries, and clear examples of good output.[5]

The four clauses of an AGENTS.md testing contract: the exact commands with flags for the full suite, a single file, the end-to-end run and the type or lint check; done defined as pnpm test, pnpm typecheck and pnpm lint all exiting 0 with new behaviour needing a new test in the same commit; the failing-suite protocol to fix the source not the assertion, re-run the single failing file first, and stop and ask after a repeated unexplained failure; and the prohibitions on deleting a failing test, adding test.skip or .only, and weakening an existing assertion.

Clause 1: The Exact Commands

Write the command an agent can copy without editing it. GitHub's guidance is to put executable commands in an early section and to include flags and options, not just tool names.

The flags-and-options distinction is not cosmetic. Anthropic's documentation makes the same point with a worked pair: write "Run npm test before committing" instead of "Test your changes", because instructions concrete enough to verify are followed more consistently. An agent given a vague instruction fills the gap by guessing a command, and a guessed command in a monorepo usually runs the wrong package.

Cover four commands at minimum: the full suite, a single file, the end-to-end run, and the type or lint check. The single-file command earns its place because it is what the agent needs during a fix loop.

Clause 2: The Definition of Done

State done as an exit condition, not an adjective. "The change is complete when pnpm test, pnpm typecheck, and pnpm lint all exit 0" is checkable. "Make sure the code is well tested" is not.

Scope the expensive checks to the paths that need them. Requiring a full end-to-end run on every change teaches the agent to treat the requirement as noise, so tie the e2e suite to the directories where a regression actually costs money.

Add the coverage rule here too, in one line: new behaviour needs a new test in the same commit. Without it, an agent that satisfies every command still ships untested code, and the suite stays green because nothing exercises the new path.

Clause 3: The Failing-Suite Protocol

Tell the agent what to do when a test goes red, because the default behaviour is to make the red go away. Fixing the source and weakening the assertion both produce a green suite, and only one of them is correct.

Three lines cover it: fix the source rather than the assertion, re-run the single failing file before the whole suite, and stop after a repeated unexplained failure instead of continuing. The stop rule is the one teams forget, and it is what prevents an agent from burning an hour on a broken environment.

In the Reddit thread "Really tight, succinct AGENTS.md (CLAUDE.md , etc) file" on r/AI_Agents, a developer published a compact context file built around a Verification Checklist. That checklist names tests, lint, build, and a doc-drift check, then closes with the rule "If any step fails: stop & ask." The practical takeaway is that the runnable checklist carries the value, not the style guidance around it.

Clause 4: The Prohibitions

List what the agent must never touch. GitHub found the most common helpful constraint across its sample was "Never commit secrets", and the critical testing boundary is that an agent may write to the tests directory but should never remove a test because it is failing.

Prohibitions work better than aspirations because they are checkable after the fact. A reviewer can grep a diff for test.skip in seconds. Nobody can grep a diff for "followed our testing philosophy".

  • Assertion edits: Ban changing an existing assertion to make a failing suite pass, which is the most common silent regression an agent introduces.
  • Skip annotations: Ban test.skip, .only, and framework ignore markers, because each one hides a failure while leaving the suite green.
  • Test deletion: Ban removing a test that fails, the boundary GitHub's repository review flagged as critical.
  • Payment and auth mocks: Ban mocking the payment or auth client inside end-to-end runs, where the integration is the thing under test.
  • Protected paths: Ban edits to secrets, vendor directories, and production configuration by naming the directories explicitly.
Note

Note: Run agent-written suites across 3,000+ browser and OS combinations with TestMu AI. Try free!

What Does a Complete Testing Contract Look Like?

A testing section of roughly 30 lines: the run commands with flags, the pre-commit checks, the definition of done, the failure protocol, and an explicit list of what the agent must never touch.

## Testing

Run these before reporting a change as finished:

- Unit and integration: pnpm test
- A single file: pnpm test src/billing/invoice.test.ts
- End to end: pnpm test:e2e
- Types and lint: pnpm typecheck && pnpm lint

Done means pnpm test, pnpm typecheck, and pnpm lint all exit 0,
and the e2e suite passes for any change under src/checkout/.

New behaviour needs a new test in the same commit.

## When a test fails

1. Read the failure and fix the source, not the assertion.
2. Re-run the single failing file before re-running the suite.
3. If the same test fails twice for a reason you cannot explain,
   stop and report the failure. Do not continue to the next task.

## Never

- Never edit or weaken an existing assertion to make a suite pass.
- Never add test.skip, .only, or an ignore annotation.
- Never delete a test because it is failing.
- Never mock the payments client in an end-to-end test.
- Never commit secrets or edit files under infra/production/.

Every line in that file is either a command or a rule a reviewer can check against a diff. Nothing in it describes the architecture, names a design pattern, or explains what the project does, because the code already carries all three.

Keep the whole file short. Anthropic targets under 200 lines and states plainly that longer files consume more context and reduce adherence, which is the same pressure the ETH Zurich cost finding measured from the outside.

Where Does the File Go in a Monorepo?

At the repository root, with an optional file inside each package. Agents read the nearest file in the directory tree, so the closest one takes precedence over the root in a monorepo.[2]

OpenAI Codex walks from the Git root to the current directory and places closer files later in the combined prompt, so they override earlier guidance. Codex stops merging once the combined size reaches its 32 KiB default.[6]

AgentReads the fileHow nested files combine
OpenAI CodexYes, nativelyConcatenates root down, closer files override, 32 KiB cap
CursorYes, root and subdirectoriesCoexists with project rules in .cursor/rules
GitHub CopilotYes, as agent instructionsRanks below .github/copilot-instructions.md
Claude CodeNo, reads CLAUDE.mdConcatenates rather than overrides, subdirectories load on demand

That 32 KiB cap has a practical consequence teams hit late. A bloated root file can consume the budget before the package-level testing rules are ever reached, so the package that most needed its own commands silently inherits the generic ones.

How to Check the Agent Honored the Contract?

Run the listed commands yourself and compare the output. A context file shapes behaviour without enforcing it, so continuous integration stays the only layer that actually blocks a bad merge.

Anthropic states the limit directly: memory files are treated as context, not enforced configuration, and blocking an action regardless of what the model decides requires a hook. A contract written in Markdown therefore sets an expectation, and it cannot guarantee one.

The specification adds a second limit. Explicit user chat prompts override everything in the file, so a teammate asking an agent to skip the suite wins over the line telling it not to. Both limits point the same way: the file sets defaults, and the pipeline sets rules. That enforcement layer is the subject of pre action checks ai coding agents.

  • Loaded-file check: Run /context in Claude Code and read the Memory files list, which shows what actually reached the session rather than what exists on disk.
  • Command echo: Ask the agent to state the commands it plans to run before it starts, then compare that list against the file.
  • Diff grep: Search each pull request for test.skip, .only, and deleted test files, since these are the prohibitions an agent breaks quietly.
  • Required CI status: Make the same commands a required check, because a rule the pipeline enforces survives a distracted reviewer and a direct chat prompt.

A quality layer around agent-written code spans more than one stage, and TestMu AI ships purpose-built AI agents for several of them, including Agent Testing for evaluating conversational agents, a Test Orchestration Agent, and a Root Cause Analysis Agent.

Keep Agent-Written Code Under a Real Quality Layer

Who Checks the Tests the Agent Writes?

Nothing in the contract does. The file names which suite an agent must run, and it cannot judge whether the assertions inside that suite are meaningful, so a green run can rest on weak coverage.

The coverage-quality gap widens as the agent writes more of the suite. A contract that forbids deleting a failing test does not stop an agent from adding a test that asserts almost nothing, and the pipeline reports both as passing.

KaneAI by TestMu AI works on assertion quality, and its GitHub App already reads the same repository files an agent does. Relevant capabilities:

  • Context-aware test generation: Analyzes the pull request diff, title, description, README.md, and optional agent.md to generate end-to-end tests with assertions reflecting both the technical change and the business logic.
  • Smart assertions: Proposes assertions where validation matters, covering value checks, element presence, API response shape, and database state, so coverage answers whether the system behaved correctly rather than whether the steps ran.
  • Multi-framework export: Exports generated tests to Selenium, Playwright, Cypress, or Appium, so the suite stays in the repository the agent already reads.

The getting started with kane ai documentation covers setup, and the wider question of agents validating their own work is covered in can coding agents test their own code.

Conclusion

Open the AGENTS.md file in your largest repository and delete every paragraph describing the architecture. Replace them with the four commands your agents need, one exit condition, three lines on what to do when a suite fails, and a short list of prohibitions.

The evidence points the same direction as the practice. Instructions get followed and overviews do not, so the file earns its context budget only where it tells an agent something it can run. Everything else is a summary of code the agent can already read.

Then move the parts that must never break out of Markdown and into the pipeline, because a context file sets defaults and only continuous integration sets rules. Teams tightening that loop across a whole workflow can start with vibe coding QA process.

Author

...

Prince Dewani

Blogs: 21

  • Linkedin

Prince Dewani is a Community Contributor at TestMu AI specializing in AI agents, software testing, QA, and SEO. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI, and presented academic research on AI agents at PBCON-01. At TestMu AI, he has also carried out extensive cross-browser research on the support of modern web technologies such as WebGPU, WebAssembly, WebXR, WebGL2 and other web technologies, validating their compatibility and feature parity across major browsers and rendering engines through rigorous hands-on testing. Prince has hands-on experience building AI agent workflows using Anthropic Claude, Google Antigravity, n8n, LangChain, and other agentic frameworks, and works regularly with MCP and A2A protocols. He shares his work with 5,500+ QA engineers, developers, DevOps experts, tech leaders, and AI agent practitioners on LinkedIn.

Reviewer

...

Srinivasan Sekar

Reviewer

  • Linkedin

Srinivasan Sekar is Director of Engineering at TestMu AI (formerly LambdaTest), where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.

Add to Google preferred sources

Summarise with AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

AGENTS.md FAQs

Did you find this page helpful?

More Related Blogs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests