Skip to main content
Moxie Docs
← Blog
12 min readThe Moxie Docs team

AGENTS.md Testing Before You Trust a Change

Use AGENTS.md testing to check instruction changes with isolated tasks, observable outcomes, and a repeatable review process.

  • agents.md
  • coding-agents
  • repository-instructions
  • testing

You tighten an instruction in AGENTS.md, ask your coding agent to explain it, and get a correct answer. Then the next patch misses the required release note. Reading the rule back didn't establish that the agent would apply it during an edit.

AGENTS.md testing needs tasks with observable outcomes, separate working trees, and prompts that don't reveal the behavior you're checking. The workflow below turns an instruction-file change into something you can review alongside the code. All repository paths, scripts, and task fixtures are illustrative examples; adapt them to your checkout.

Pick an Observable Test Outcome#

Start with one instruction you're changing and identify what would prove that it affected the work. Avoid testing the entire instruction file at once. If an agent misses a requirement, you need to distinguish a discovery problem from an unclear rule or an unrelated implementation failure.

Instruction under testTask to give the agentEvidence to inspect
Public API changes need a release note.Add an optional argument to an exported function.The patch includes the required release-note entry.
Generated clients must come from the schema.Add a response field to an API client.The agent edits the schema and runs generation rather than hand-editing generated output.
A new production dependency needs approval.Implement a feature that might benefit from another library.The agent asks before changing the production dependency list, or implements it without a new dependency.
Package changes need package-local checks.Fix a bug inside packages/parser/.The execution record shows the documented command from the documented directory.
Documentation-only changes have narrower checks.Correct an example in docs/parser.md.The agent runs the documentation check and avoids unnecessary application changes.

The AGENTS.md format documentation describes repository instructions for coding agents, including build commands, tests, and conventions. It doesn't make a successful behavioral test unnecessary. A file can contain a clear instruction and still fail to affect a particular agent session.

Choose one positive case and one nearby negative case. For a release-note rule, changing an exported function should trigger the requirement. Fixing a typo in an internal comment shouldn't. This pair checks whether the agent applies the condition rather than blindly adding a release note to every patch.

Record the Contract Before Running the Task#

Write down the expected behavior before you see the patch. Otherwise, it's easy to accept whatever the agent did and explain afterward why it was reasonable.

1. Name the instruction being tested. Quote the relevant sentence and record its location. For example: AGENTS.md, under “Public API changes.” Keep unrelated rules outside this test's acceptance criteria, though normal code review still applies.

2. Define the trigger. State what about the task activates the rule. “Changes a documented export from packages/parser/src/index.ts” is more useful than “changes something important.” If maintainers disagree about the trigger, resolve that disagreement before evaluating an agent.

3. Define the required evidence. A release-note test needs a file in the repository's release-note directory with accurate content. A verification-command test needs an execution record. A final message claiming compliance isn't enough for either one.

4. Define legitimate exceptions. If the agent discovers that the requested argument already exists, a no-op may be correct. Mark the run inconclusive for the intended edit behavior rather than counting it as a pass or forcing an unnecessary change.

Keep this contract separate from files the agent can read during the test. Here's an illustrative evaluator record:

YAML
case: exported-parser-option
instruction_file: AGENTS.md
instruction_section: Public API changes
base_revision: recorded-before-run
prompt: Add an optional strict argument to the exported parse function.
trigger: Changes the signature of a documented public export.
required:
  - A release note describes the new argument.
  - Existing call sites remain compatible.
forbidden:
  - Unrelated dependency changes.
inconclusive_if:
  - The requested argument already exists.

This isn't an agent configuration format. It's a record for the reviewer. Store it outside the test checkout, or in an evaluation repository the agent cannot access during the run.

Build Fixtures From Real Review Corrections#

The most useful fixture starts with a correction you've already made in review. Perhaps an agent edited a generated client directly, skipped a package-specific check, or changed a public export without a release note. Preserve the shape of that task without embedding the correction in the prompt.

For example, this prompt tests implementation and instruction use:

Code
Add an optional strict argument to parse(). Preserve existing behavior
when callers omit it. In strict mode, reject trailing input.

This version largely gives away the answer:

Code
Add an optional strict argument to parse(). Remember the AGENTS.md
requirement to add a release note for public API changes.

Use the first prompt for the behavioral test. The second can help diagnose whether an agent can perform the companion edit when explicitly directed, but it doesn't test whether repository instructions supplied the requirement.

Keep fixtures small enough that you can review the resulting patch. A broad request such as “modernize the parser package” introduces too many discretionary decisions. If the agent spends the run restructuring the package, you learn little about your release-note instruction.

Also check that the task genuinely exercises the rule. An “exported function” fixture is invalid if the function is private on the chosen base revision. Record the base commit and inspect the relevant source before running the agent.

Don't make every fixture a trap. Include an ordinary task that should complete without an approval pause or companion documentation change. Overly broad instructions can create needless work, and your tests should expose that cost.

Compare Changes in Separate Worktrees#

Use the same starting code and task prompt to compare the current instruction with a proposed revision. Change only the instruction under test when practical. Otherwise, a different package layout or repaired test script can explain the result.

Git worktrees let you create separate working directories backed by the same repository. The following commands are an illustrative setup. Replace BASE_COMMIT with a reviewed commit containing the fixture's starting state:

Shell
git worktree add -b eval/agents-baseline ../agents-baseline BASE_COMMIT
git worktree add -b eval/agents-candidate ../agents-candidate BASE_COMMIT

1. Apply only the proposed instruction change to the candidate. Leave the baseline instruction unchanged. Save the candidate diff so reviewers can see exactly what was tested.

2. Start independent agent sessions. Point each session at its own worktree. Don't reuse a conversation that already discussed the missed rule or the expected answer.

3. Hold the execution conditions steady. Record the agent version, selected model when exposed, working directory, permissions, dependency setup, and available services. You don't need an elaborate benchmark system, but you do need enough detail to spot obvious differences between runs.

4. Give both sessions the same task prompt. Don't add hints to the candidate prompt because you want the new wording to succeed. That changes two inputs at once.

5. Preserve the evidence before resetting anything. Save the patch, command results, final report, and any approval request. Check for untracked files as well as tracked changes:

Shell
git -C ../agents-candidate status --short
git -C ../agents-candidate diff --check
git -C ../agents-candidate diff -- AGENTS.md packages/ .changes/

Separate worktrees don't isolate every resource. Both sessions may still share caches, credentials, ports, or an external database. Keep tasks away from production services and use separate local resources where concurrent runs could interfere.

Score Actions Separately From Claims#

Evaluate the resulting work against the contract you wrote earlier. Separate the agent's report from what the patch and execution record show.

A final response might say “added the release note” when the file is untracked, empty, or describes the wrong behavior. Conversely, the patch may contain the correct release note even if the final response omits it. These are different findings: one concerns task execution; the other concerns reporting.

Use simple outcomes:

  • Pass: The required behavior is observable and the task reached the relevant decision point.
  • Fail: The task reached that point, but the agent missed or violated the instruction.
  • Blocked: The environment prevented the task from reaching a meaningful result.
  • Inconclusive: The task didn't exercise the intended condition, or the evidence isn't sufficient.

Don't count a setup failure as instruction failure unless setup behavior was the instruction under test. If dependency installation fails before any edit, the run says little about whether the agent would add a release note.

For generated-file rules, inspect both the command record and the diff. Running the generator doesn't establish that the agent avoided hand-editing its output afterward. For approval rules, inspect when approval was requested. Asking after changing the manifest doesn't satisfy “ask before adding a production dependency.”

One successful run demonstrates one successful run. Repeat the important cases when the result will determine whether you adopt a rule, and preserve misses alongside successes. If outcomes differ, report the variation rather than presenting the best patch as the representative result.

Human review remains the acceptance gate. A companion-file check can pass while the implementation is wrong, and a correct implementation can still violate a repository boundary.

Catch the Test That Supplies Its Own Answer#

The non-obvious failure mode is contamination: the evaluation gives the agent the information you intended it to obtain from AGENTS.md.

This can happen without an obvious reminder in the task prompt. You might first ask the agent to summarize the release-note policy, then ask it to change the public API in the same conversation. The agent now has that policy in the conversation even if instruction discovery would fail in a fresh session.

An evaluator file inside the checkout can cause the same problem. If it contains required: add a release note, an agent that reads it may satisfy the test without using the instruction file. An earlier patch or a leftover generated file can also make the expected action easier to infer.

Separate discovery diagnostics from behavioral tests. In a diagnostic session, ask which instruction files apply and inspect the answer. In a fresh behavioral session, provide only the actual engineering task. Don't carry the diagnostic conversation into the run you're scoring.

A useful control, when safe, is to run the same disposable fixture without the specific rule. If the agent still performs the companion edit, the task may be following a familiar convention or another document may contain the same requirement. That doesn't make the behavior bad. It limits what you can conclude about the proposed instruction.

Don't remove safety boundaries to create a control. Use harmless outcomes such as a release-note entry, and keep the work isolated from protected branches and external services. The purpose is to understand the evidence, not to provoke a dangerous action.

Keep Test Evidence Separate From Context#

Once a revised instruction performs better on the fixtures, keep the instruction diff, task prompt, base revision, and observed outcomes together in the review. A maintainer should be able to understand the change without replaying a whole conversation.

Keep the types of context distinct. Human-facing documentation explains the API and its behavior. AGENTS.md supplies checkout-specific working instructions. CLAUDE.md is appropriate for instructions consumed by a Claude Code setup; verify what your installed agent actually loads. MCP is appropriate when an agent needs to retrieve repository context through a connected server. A published llms.txt index helps readers and agents discover documentation; it isn't a substitute for local execution rules. For the broader design, see context engineering for coding agents.

Moxie Docs can help with the supporting documentation in this workflow. It generates source-backed documentation from GitHub repositories, updates it as code changes, provides repository context over MCP, and proposes documentation fixes in reviewable Cleanup PRs. It doesn't replace the behavioral test of your instruction change.

As an illustrative workflow, an agent retrieves the parser's documented behavior, edits the implementation, and follows the repository's release-note rule. Your evaluation checks those actions independently. If supporting documentation needs correction, a maintainer reviews the proposed Cleanup PR; it isn't automatically merged.

Generated documentation and MCP context are available on the free plan. Weekly automation is available on Pro and Team. Keep that documentation workflow separate from your decision to accept an instruction change: a maintained API reference doesn't prove the agent applied the repository rule.

The Short Version#

Choose one recurring review correction and turn it into a task with a visible acceptance condition. Run the task against the current and proposed instructions in separate worktrees and fresh sessions, without putting the expected behavior in the prompt. Inspect the patch and execution record, record blocked or inconclusive runs honestly, and include a nearby task where the rule shouldn't apply. Merge the instruction change only after a human reviews both its wording and the evidence.

FAQ#

Does asking an agent to repeat AGENTS.md count as a test?#

It checks whether the agent can identify or describe instructions in that session. It doesn't establish that the agent will apply them during an edit. Use it as a discovery diagnostic, separate from the behavioral run.

Do I need to test every instruction on every pull request?#

Start with the instruction you're changing and any adjacent behavior it could affect. For example, a broader release-note rule deserves both a public API case and an internal-only case. Keep expensive agent runs separate from cheap checks for broken paths or missing scripts.

What if the baseline and candidate both pass?#

The revision hasn't demonstrated a behavioral improvement on that fixture. It may still improve clarity for maintainers, but don't claim that the test proves better compliance. Try a relevant task that previously exposed the ambiguity, or keep the simpler wording.

Should these evaluations block merges automatically?#

Begin with review evidence rather than an automatic gate. Establish that the fixtures reach the intended decision points and that reviewers can interpret failures consistently. Any resulting code or documentation patch remains a proposed change for human review.

Republish or cite this article

You're welcome to republish this piece in full or in part. We just ask that you credit the original with a link back. See our republishing guidelines.

Attribution snippet

<p>This article was originally published on <a href="https://moxiedocs.com/blog/agents-md-testing">Moxie Docs</a>.</p>

Cite this article

The Moxie Docs team. "AGENTS.md Testing Before You Trust a Change." Moxie Docs, December 1, 2026, https://moxiedocs.com/blog/agents-md-testing.

Try it on your repo

Put your own codebase on the same footing.

Searchable docs, MCP-ready context, and Cleanup PRs that keep everything current as the code changes.