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
AIAutomationCoding

How to Add Automated Testing to Cursor, Copilot, and Codex

All three read plain markdown instruction files, and all three now honour AGENTS.md. One file can teach every one of them to prove its work before it claims to be done.

Author

Bhawana

Author

Author

Shahzeb Hoda

Reviewer

Published on: August 27, 2026

The agent finishes the feature and writes, confidently, that it has been tested. Nothing opened a browser. Nothing ran.

The gap is not that these tools cannot test. It is that nobody told them, in a place they read, what testing means in this repository.

That place is different for each tool, and one of them is now shared by all three.

TL;DR

Cursor, GitHub Copilot, and Codex all read plain markdown instruction files, and all three now honour AGENTS.md. One file can therefore teach every one of them to verify a change in a real browser before reporting success, instead of three separate integrations that drift apart.

  • The shared file - AGENTS.md is read by all three, at the project root for Cursor and Codex, and as the nearest file in the directory tree for Copilot.
  • The tool-specific files - Cursor additionally reads .mdc rules under .cursor/rules, and Copilot additionally reads .github/copilot-instructions.md.
  • The command to name - a single agent-mode command gives any of them a real Chrome browser and an exit code, which is something none of the three has natively.
  • The limit to plan for - instruction files are advisory, so compliance decays on long sessions and only a hook or a required CI step makes the check unconditional.

Why the Agent Skips Testing

Because testing was never defined for it. Left undefined, an agent settles on the cheapest thing that resembles verification, which is usually reading its own diff and declaring it correct.

There is also a capability gap underneath the instruction gap. None of these three drives a browser on its own.

  • They can run commands - that is the opening, because a shell command is something all three already do without new integrations.
  • They cannot see a page - without a browser in the loop, a rendering failure produces no signal at all.
  • They will not invent a convention - if the repository has no stated check, the agent picks whatever it saw most in training.
  • Vague instructions read as optional - test your changes competes with every other line in context and usually loses.

The Three Instruction Surfaces

Each tool has its own preferred file, and each has a second path that behaves differently. Getting the path wrong is the most common reason an instruction appears to be ignored.

ToolNative instruction fileScoping mechanismAlso reads AGENTS.md
Cursor.mdc rule files under .cursor/rulesFrontmatter: alwaysApply, globs, or description for intelligent selectionYes, in the project root and subdirectories
GitHub Copilot.github/copilot-instructions.md.github/instructions/NAME.instructions.md with an applyTo globYes, nearest file in the directory tree takes precedence
CodexAGENTS.mdProject root file, or a global one under the Codex config directoryYes, this is its native file

One caveat on the Copilot row is worth reading twice. GitHub's documentation states that path-specific custom instructions on GitHub.com are currently supported only for the Copilot cloud agent and Copilot code review, so a glob-scoped file will not necessarily reach every surface you use.

Full field references live in the Cursor rules documentation and in GitHub's guide to repository custom instructions.

The One File All Three Read

AGENTS.md is the convergence point. Write the testing contract there once and Cursor, Copilot, and Codex all pick it up, which turns three integrations into one file in the repository root.

What goes in it matters more than where it goes. Name the trigger, the exact command, and what each outcome means.

## Verification contract

After changing anything under src/ that affects a rendered page, run:

    kane-cli run --agent --headless "<objective describing the user-visible result>"

Rules for reading the result:

- Exit 0 means verified. Only then may you report the task complete.
- Exit 1 means an assertion failed. Fix the feature. Do not weaken the objective.
- Exit 2 means Chrome or auth failed. Say so. This is not a code failure.
- Exit 3 means the run timed out. Re-run once, then escalate.

Never report success on a non-zero exit code.

The last line does the most work. Without it, agents routinely summarise a failed run as a minor issue and carry on.

Note also that this contract names no selectors and no framework. That is deliberate, because it has to survive all three tools and whichever one you adopt next.

Wiring Cursor

AGENTS.md alone is enough for Cursor. Add a rule file only when you want the instruction to fire on specific paths rather than on every session.

---
description: Browser verification required for UI changes
globs: ["src/pages/**", "src/components/**"]
alwaysApply: false
---

Any change matching these globs must be verified in a real browser
before the task is reported complete. Follow the verification contract
in AGENTS.md. A non-zero exit code is a failure, not a warning.

Save that as a .mdc file under .cursor/rules. With alwaysApply set to false and globs set, the rule attaches only when a matching file is in play, which keeps it out of the way during unrelated work.

We covered the rest of the rule system, including how the four application types differ, in Cursor rules.

Test infrastructure that does not break, from TestMu AI

Wiring GitHub Copilot

Copilot has the widest spread between surfaces, so decide which surface you are targeting before choosing a file.

  • Repository-wide - put the contract in .github/copilot-instructions.md, the broadest option and the one to start with.
  • Path-scoped - add .github/instructions/browser-checks.instructions.md with an applyTo glob such as src/pages/**, remembering GitHub's stated surface limits.
  • Shared with the others - rely on AGENTS.md, where GitHub documents that the nearest file in the tree wins.
  • Nested overrides - a subdirectory AGENTS.md lets a monorepo package state a stricter contract than the root.

GitHub also documents CLAUDE.md and GEMINI.md in the repository root as alternatives Copilot will honour. If your repository already has one of those for another agent, Copilot can read it rather than needing a duplicate.

Wiring Codex

Codex is the simplest of the three, because AGENTS.md is its native format rather than a compatibility layer.

It reads AGENTS.md at the project root, and a global file under the Codex configuration directory applies across every repository on the machine. TestMu AI publishes a ready-made section you can append rather than writing the contract yourself.

# project-level: append the Kane CLI section to this repo's AGENTS.md
curl -o /tmp/kane-cli-agents.md \
  https://raw.githubusercontent.com/LambdaTest/kane-cli/main/skills/codex/AGENTS.md

cat /tmp/kane-cli-agents.md >> AGENTS.md

# global: the same section, applied to every repository on this machine
cat /tmp/kane-cli-agents.md >> ~/.codex/AGENTS.md

Because Cursor reads AGENTS.md too, that same appended section covers Cursor without a second step. Codex-specific usage limits and how to stretch them are covered separately in Codex usage.

What the Agent Actually Runs

The instruction is only as good as the command it names. That command has to work headless, return a status the agent can branch on, and not require a test file that does not exist yet.

Kane CLI from TestMu AI fits those three constraints. It takes the objective in plain English, drives real Chrome, and exits with a POSIX status.

  • No test file required - the objective is the test, which suits an agent verifying something it built two minutes ago.
  • Machine-readable stream - agent mode emits newline-delimited JSON and closes with a run_end event carrying the full result.
  • Runs where agents run - headless mode needs no display server, so it works the same in a terminal, in CI, and in a cloud agent.
  • Evidence for the reviewer - each run seals per-step screenshots, a HAR network log, and console output into a pack under .testmuai/evidence.
  • Install is one command - npm install -g @testmuai/kane-cli, with Node.js 18 or higher and Chrome on the PATH.

Here is a real run of the shape an agent would issue, on Kane CLI 0.8.4, checking that a form refuses to submit when it should.

$ kane-cli run --agent --headless \
    "open the Input Form Submit page, submit the form with all fields empty,
     and assert the browser blocks submission with a validation message
     on the Name field" \
    --url https://www.testmuai.com/selenium-playground/ | tail -1

{"type":"run_end","status":"passed",
 "summary":"Tried to submit the form without entering any information. The browser
            stopped the submission and showed a validation message on the Name field,
            so the form was not submitted.",
 "final_state":{"name_field_validation_message":"true"},
 "reason":"Objective completed","duration":47,"bifurcated":false,"total_runs":1}

$ echo $?
0

That objective asserts a negative, which is the case agent-written unit tests miss most reliably. Nothing in the source says the browser refused to submit.

Command flags and configuration are documented in the Kane CLI introduction documentation.

Note

Note: TestMu AI's Kane CLI turns an advisory instruction into a required CI check, which is the part agents actually obey. Try TestMu AI free!

Checking the Instruction Took

Do not assume a file is being read because it exists. Give the instruction a cheap observable side effect, run one small task, and check whether the side effect happened.

  • Add a line telling the agent to append a timestamp to a local file before starting any task, then run something trivial and look at the file.
  • If the file is empty, fix the path before rewording anything, because wording cannot rescue a file that is never loaded.
  • Once it loads, replace the timestamp line with the real verification contract and repeat the same one-task test.
  • Then watch compliance over a long session, because that is where instruction-following degrades and where you learn whether you need enforcement instead.

Step four is where most teams land on the honest answer. An instruction file gets you most of the way, and a lifecycle event gets you the rest.

If your agent supports that kind of enforcement, Claude Code hooks walks through binding a command to a lifecycle event so the check fires whether or not the model remembers it. For a wider view of which assistants help with testing at all, see our roundup of AI code assistants for testing.

Author

...

Bhawana

Blogs: 76

  • Twitter
  • Linkedin

Bhawana is a Community Evangelist at TestMu AI with over 3 years of experience creating technically accurate, strategy-driven content in software testing. She has authored 50+ blogs on test automation, cross-browser testing, mobile testing, and real device testing. She also serves as Product Marketing Manager for Kane CLI, the command-line tool that runs browser automation from the terminal using natural-language flows in a real Chrome browser. Bhawana is certified in KaneAI, Selenium, Appium, Playwright, and Cypress, reflecting her hands-on knowledge of modern automation practices. On LinkedIn, she is followed by 6000+ QA engineers, testers, AI automation testers, and tech leaders.

Reviewer

...

Shahzeb Hoda

Reviewer

  • Linkedin

Shahzeb Hoda is the Associate Director of Marketing and a Community Contributor at TestMu AI, leading strategic initiatives in developer marketing, content, and community growth. With 10+ years of experience in quality engineering, software testing, automation testing, and e-learning, he has authored and reviewed 70+ technical articles on software testing and automation. Shahzeb holds an M.Tech in Computer Science from BIT, Mesra, and is certified in Selenium, Cypress, Playwright, Appium, and KaneAI. He brings deep expertise in CI/CD pipeline automation, cross-browser testing, AI-driven testing practices, and framework documentation. On LinkedIn, he is followed by 3,700+ engineers, developers, DevOps professionals, tech leaders, and enthusiasts.

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

AI Coding Tool Testing 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