AI Coding Agents for Testers: Set Up Skills and Rules for QA
A tested setup for coding agents on a QA repository: a short AGENTS.md, path-scoped rules, an on-demand triage skill, a protect hook and ESLint that enforces what the files only request.
Hely PatelHead of Product and Marketing18 min read
AI coding agents for testers work well on a test repository when they have three things: a short always-loaded file that states commands, conventions and boundaries; scoped rules and skills that load only when needed; and automated checks that enforce what the files can only request. The third matters because Claude Code's own documentation says CLAUDE.md is context, not enforcement.
This guide builds that setup for a Playwright repository. It includes working files, a lint configuration that caught 14 problems in an agent-style test file, a hook that blocked edits to protected paths, and a checker that finds a broken setup before an agent does.
Who this is for: SDETs, automation engineers and QA leads who let a coding agent such as Claude Code, Codex or GitHub Copilot work in a test repository. What you get: working files you can copy, a table of what belongs where, a list of the mistakes teams make most, and a rollout plan.
What do AI coding agents for testers need from a test repository?
A coding agent opens your repository with no memory of your team. It does not know how to run the suite, which locator strategy you require, that expected values are never edited to make a test pass, or that app/ is off limits. It learns these from files, and the quality of those files decides whether it behaves like a new colleague who read the handbook or one who guessed.
The common mistakes are predictable. The file is too long, so important lines drown. Rules are duplicated across tools and drift apart. Everything loads in every session, including procedures needed once a week. And rules are written as requests with nothing to catch a violation.
Commands, conventions, boundaries, definition of done
Paid every time
CLAUDE.md
Every session in Claude Code
Imports AGENTS.md plus anything Claude-specific
Paid every time
.claude/rules/*.md with paths:
When matching files are touched
Rules that matter only for some files, such as test files
Paid only on matching work
Skills
The description each session, the body when used
Multi-step procedures such as triaging a failure
Small, then paid on use
ESLint, hooks, CI
When run
Rules that must hold
Compute, not tokens
AGENTS.md is an open, plain-Markdown format described as a "README for agents". Its site says it is used by over 60,000 open-source projects and is stewarded by the Agentic AI Foundation under the Linux Foundation. It is read by many tools, including Codex, Cursor, GitHub Copilot's coding agent, Gemini CLI, Aider, Windsurf and Zed. Large repositories can place one in each subproject: agents read the nearest file in the tree, and an instruction in your chat prompt overrides the file. No fields are required.
Claude Code's documentation adds details that shape the design of any CLAUDE.md for test automation:
CLAUDE.md files are concatenated, not overridden. If two give conflicting instructions, the agent may pick one arbitrarily, so contradictions are bugs.
@path imports work up to four hops deep and do not reduce context cost. An import shares text, it does not save tokens.
Rules with paths: frontmatter load only when matching files are touched.
Target under 200 lines per CLAUDE.md. Longer files reduce adherence.
Claude Code v2.1.277 and later reads AGENTS.md only when there is no CLAUDE.md, which supersedes older articles saying it never does. To share one file, put @AGENTS.md inside CLAUDE.md.
Step 1: How do you write a short, useful AGENTS.md?
The file below is the whole always-loaded instruction set for the example repository: 28 lines and 1,402 characters, about 350 tokens at four characters per token.
# AGENTS.md
Playwright (TypeScript) end-to-end tests for Acme Shop. The app under test is a static page in `app/`.
## Commands
- Install: `npm ci`
- Run everything: `npm test`
- Run one file: `npx playwright test tests/cart.spec.ts`
- Lint: `npm run lint` (must pass before you call a task done)
- Failure summary: `npm run triage`
## Conventions
- Tests live in `tests/`, one feature per file, named `<feature>.spec.ts`.
- Find elements with `getByRole`, `getByLabel`, `getByText` or `getByTestId`. No raw CSS selectors, no `nth` helpers.
- Assert with web-first matchers: `await expect(locator).toHaveText(...)`. Never read text into a variable and compare.
- Each test starts from a clean page in `beforeEach` and never depends on another test.
- Name tests as behaviour: "Rejects an unknown coupon", not "coupon test 2".
- Create test data inside the test. Never share records between tests.
## Boundaries
- Do not edit `app/`, `playwright.config.ts` or `eslint.config.mjs` without asking.
- Never change an expected value to make a failing test pass. Report the mismatch as a possible product defect.
- Never use `test.skip`, `test.fixme`, `waitForTimeout`, `networkidle` or `force: true`.
## Done means
- `npm test` and `npm run lint` pass, or you list exactly which ones fail and why.
- Your last message lists files changed, tests added, and any assertion you touched (none unless asked).
Five choices make it work.
Commands are exact and runnable. An agent that can run the suite and linter verifies its own work.
Conventions state the choice, not the philosophy. "Find elements with getByRole, getByLabel, getByText or getByTestId" is checkable. "Write robust locators" is not.
Boundaries include the rule that matters most for testers: never change an expected value to make a failing test pass, and report the mismatch as a possible product defect. The guide to Playwright test agents shows why, with a healer patch that hid a real bug.
Done means something measurable. Tests and lint pass, or the agent lists exactly what fails and why, and reports any assertion it touched.
It stays small. Every line is paid for in every session.
How do you write instructions an agent can follow?
Most failures come from how lines are written. The test for a line is whether a violation could be detected.
Weak line
Why it fails
Stronger line
Write clean, maintainable tests
No one can check it
Each test is under 25 lines and covers one behaviour
Use good locators
"Good" is undefined
Use getByRole, getByLabel, getByText or getByTestId
Be careful with test data
Vague
Create test data inside the test and never share records between tests
Don't break existing tests
Obvious and unverifiable
Run npm test before finishing and list any failures
Never use waits
Absolute, with no alternative
Use web-first assertions. Never use waitForTimeout
Follow the project conventions
Points at nothing
Name tests as behaviour, for example "Rejects an unknown coupon"
Three habits make lines stronger. State the choice, not the principle. Give the alternative along with the prohibition, because an agent told only what not to do has to guess. And prefer lines a linter or script could check, because those can graduate from the file to the enforcement layer.
Step 2: How do you share one file between tools?
@AGENTS.md
## Claude Code
- When a test fails, use the triage-failed-test skill before changing any code.
Four lines. @AGENTS.md pulls in the shared file, so tools that read AGENTS.md and Claude Code see one source of truth, and the Claude-specific note stays separate. This avoids the common drift where two files describe the same repository differently.
Step 3: How do you add rules that apply only to test files?
Some rules matter only when test files are touched. A rule file with a paths list loads only then.
---
paths:
- "tests/**/*.spec.ts"
---
# Rules for test files
- Import `test` and `expect` from `@playwright/test`, nothing else.
- Put a one-line comment with the requirement ID above each test when one exists, for example `// LV-3`.
- Keep a test under 25 lines. Split it when it grows.
A requirement-ID comment above each test is a good fit. It matters for tests and is noise when an agent edits a config file. The traceability it creates is the kind used in the test case review workflow.
Step 4: How do you write a skill for a multi-step procedure?
Triaging a failed test is a procedure with steps and judgement, which is what skills are for. A skill is a folder with a SKILL.md. Claude Code's documentation says a skill's description is in context in every session so the agent knows what is available. The full body loads when the skill is invoked, and it then stays in context for the rest of the session. The description and when_to_use text is truncated at 1,536 characters in the listing, so put the key use case first.
Keep SKILL.md under 500 lines and move reference material into separate files. A skill can also take a paths field to limit automatic loading to matching files, and disable-model-invocation: true for workflows with side effects such as deploys.
---
name: triage-failed-test
description: Classify failing Playwright tests as product defect, test defect or environment problem before fixing anything. Use when npm test fails or when asked why a test is red. ---
# Triage a failed test
1. Run `npm run triage`. Read the summary it prints. Do not open the full report unless the summary is not enough.
2. For each failing test, decide one class:
- Product defect: the page shows a different value than the requirement says. Expected and Received both look plausible.
- Test defect: an element was not found, a locator is ambiguous or a name changed. The page still behaves as required.
- Environment: timeouts, connection errors, same test passes on a rerun.
3. Fix only test defects, and only locators or waits. Never edit an expected value.
4. Report product defects with the test name, expected value, received value and the requirement id. Do not change the test.
5. Finish with one line per failing test: class, evidence, action taken.
The skill makes the agent classify each failure as a product defect, a test defect or an environment problem before editing anything, and restates that only locators and waits may change. The earlier guides in this series cover skills in depth: agent skills for QA testing and the comparison with MCP and prompts. The description above leads with the use case and names the triggers, which is the documented best practice.
Why should a skill read a small input?
A skill is only as good as the data it reads. Playwright's JSON report for four failing tests in this repository is 14,747 characters, about 3,700 tokens, mostly stack traces and metadata. A short script reduces it to the facts the skill needs.
// Turns a Playwright JSON report into a short summary an agent can read.
import { readFileSync } from 'node:fs';
const report = JSON.parse(readFileSync(process.argv[2], 'utf8'));
const rows = [];
const walk = (suite, trail = []) => {
for (const s of suite.suites ?? []) walk(s, [...trail, s.title]);
for (const spec of suite.specs ?? []) for (const t of spec.tests ?? []) {
const last = t.results[t.results.length - 1];
if (t.status === 'expected' || t.status === 'skipped') continue;
const msg = (last.error?.message ?? '').replace(/\u001b\[[0-9;]*m/g, '');
const pick = k => (msg.match(new RegExp(k + ':\\s*(.*)')) ?? [])[1];
rows.push({ title: [...trail.slice(1), spec.title].join(' > '), where: `${spec.file}:${spec.line}`,
expected: pick('Expected'), received: pick('Received'), first: msg.split('\n').find(l => l.trim()) ?? '' });
}
};
for (const s of report.suites) walk(s, [s.title]);
const st = report.stats;
console.log(`${st.expected} passed, ${st.unexpected} failed, ${st.skipped} skipped`);
for (const r of rows) {
console.log(`\nFAIL ${r.title} (${r.where})`);
if (r.expected && r.received) console.log(` expected ${r.expected} received ${r.received}`);
else console.log(` ${r.first.slice(0, 160)}`);
}
Run on the shop app after a release that renamed a button, the real output is:
> triage
> playwright test --reporter=json > report.json; node scripts/summarize_failures.mjs report.json
0 passed, 4 failed, 0 skipped
FAIL Cart and coupon > Shows a product after it is added (cart.spec.ts:9)
Test timeout of 8000ms exceeded.
FAIL Cart and coupon > Free shipping from Rs 500 (cart.spec.ts:15)
Test timeout of 8000ms exceeded.
FAIL Cart and coupon > SAVE10 takes 10 percent off (cart.spec.ts:21)
Test timeout of 8000ms exceeded.
FAIL Cart and coupon > Unknown coupon is rejected (cart.spec.ts:29)
Test timeout of 8000ms exceeded.
The summary is 564 characters against 14,747 for the report, and it says what an agent needs: four failures, all timeouts. Four timeouts on a click points to a test defect, probably a changed locator, and not to four product bugs.
After the locator fix, the same script reports something different:
> playwright test --reporter=json > report.json; node scripts/summarize_failures.mjs report.json
3 passed, 1 failed, 0 skipped
FAIL Cart and coupon > SAVE10 takes 10 percent off (cart.spec.ts:21)
expected "720.00" received "792.00"
Three pass, and one fails with expected "720.00" and received "792.00". Both values are plausible, the page otherwise behaves as required, and the skill's rules say what that means: a product defect, to be reported and not patched. Playwright 1.65's failures reporter and onlyFailures option push in the same direction, with one caution from the release coverage: do not compute pass rates from onlyFailures files. The November roundup has the details.
Step 5: How do you enforce the rules?
Claude Code's documentation is plain that CLAUDE.md shapes behaviour and does not enforce it. For test code, the cheapest enforcement is a linter that already knows Playwright. The configuration below uses eslint-plugin-playwright with its recommended rules and sets the rules behind the AGENTS.md conventions to errors.
The committed tests pass cleanly with npx eslint tests. To see what the rules catch, we wrote a file in the style an unsupervised agent often produces. It has raw selectors, a fixed wait, a forced click, text read into a variable, a conditional assertion and a skipped test.
/home/claude/b2/ex10/repo/examples/agent-draft.spec.ts
5:9 error Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators playwright/no-raw-locators
6:9 error Unexpected use of page.waitForTimeout() playwright/no-wait-for-timeout
7:9 error Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators playwright/no-raw-locators
8:9 error Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators playwright/no-raw-locators
8:40 error Unexpected use of { force: true } option playwright/no-force-option
9:23 error Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators playwright/no-raw-locators
10:3 error Replace textContent() with toHaveText() playwright/prefer-web-first-assertions
14:46 error Unexpected use of networkidle playwright/no-networkidle
15:53 error Unexpected use of first() playwright/no-nth-methods
16:3 error Avoid having conditionals in tests playwright/no-conditional-in-test
17:11 warning Avoid calling `expect` conditionally playwright/no-conditional-expect
21:1 error Test has no assertions playwright/expect-expect
21:6 error Unexpected use of the `.skip()` annotation playwright/no-skipped-test
25:1 error Test has no assertions playwright/expect-expect
✖ 14 problems (13 errors, 1 warning)
1 error and 0 warnings potentially fixable with the `--fix` option.
Fourteen problems, thirteen errors and one warning, each tied to a line.
Rule
Hits
What it blocks
no-raw-locators
5
CSS and XPath selectors instead of roles, labels and test IDs
expect-expect
2
Tests with no assertion
no-wait-for-timeout
1
Fixed sleeps
no-force-option
1
Clicks that bypass real user checks
prefer-web-first-assertions
1
Reading text into a variable and comparing
no-networkidle
1
An unreliable page-ready signal
no-nth-methods
1
first(), nth() and last()
no-conditional-in-test
1
if blocks in a test
no-conditional-expect (warning)
1
An assertion that may not run
no-skipped-test
1
test.skip
One honest limitation: the missing-playwright-await rule is enabled, and it did not flag the un-awaited click() on line 15 of the sample. Do not rely on lint for missing awaits. Running the tests and TypeScript's own checks remain necessary.
Put npm run lint in two places: the AGENTS.md definition of done, so the agent runs it, and CI, so a person or agent who forgets cannot merge. The first makes the agent faster and the second makes the rule real.
Step 6: How do you stop a coding agent editing test config with a Claude Code hook?
Lint cannot stop an edit to a config file. A hook can. Claude Code hooks are user-defined commands that run at points in the agent's lifecycle and give deterministic control: certain actions always happen, whatever the model decides. A PreToolUse hook runs before a tool call and can block it. The script receives the tool call as JSON on standard input, and exiting with code 2 blocks the action and sends the script's error message back to the agent as feedback.
The script below follows the pattern in Claude Code's documentation and protects the paths this repository keeps under human control.
#!/bin/bash
# Blocks agent edits to files the team keeps under human control.
# Claude Code passes the tool call as JSON on stdin. Exit 2 blocks the edit and
# sends stderr back to the agent as feedback.
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
FILE_PATH="${FILE_PATH//\\//}"
PROTECTED=("app/" "playwright.config.ts" "eslint.config.mjs" ".claude/hooks/" ".github/workflows/")
for p in "${PROTECTED[@]}"; do
if [[ "$FILE_PATH" == *"$p"* ]]; then
echo "Blocked: $FILE_PATH is protected. Report the problem instead of editing it." >&2
exit 2
fi
done
exit 0
It is registered in .claude/settings.json for the Edit and Write tools:
We tested the script by feeding it the JSON a hook receives for five files and recording the exit code:
exit 0 tests/cart.spec.ts
exit 2 app/shop.html Blocked: /work/acme/app/shop.html is protected. Report the problem instead of editing it.
exit 2 playwright.config.ts Blocked: /work/acme/playwright.config.ts is protected. Report the problem instead of editing it.
exit 2 eslint.config.mjs Blocked: /work/acme/eslint.config.mjs is protected. Report the problem instead of editing it.
exit 0 tests/checkout.spec.ts
Edits to tests/ files exit 0 and proceed. Edits to app/, playwright.config.ts and eslint.config.mjs exit 2 with a message the agent can act on. This tests the script, not Claude Code itself, so confirm the registration in your own environment.
A hook also covers a gap in the other layers. AGENTS.md says "do not edit app/", lint cannot check it and the hook enforces it. A hook is not a security boundary against a determined user, and it is a reliable guardrail for an agent doing routine work.
Step 7: How do you check the setup itself?
Agent files rot like any documentation. A command is renamed, a path moves, an import is deleted, and the agent follows instructions that no longer match. A short checker verifies that the files agree with the repository.
"""Check that an agent setup is internally consistent. Usage: python3 check_agent_files.py REPO"""
import json, os, re, sys
repo = sys.argv[1]
def read(p): return open(os.path.join(repo, p), encoding="utf-8").read()
problems = []
agents = read("AGENTS.md")
lines, chars = agents.count("\n") + 1, len(agents)
print(f"AGENTS.md {lines} lines, {chars} characters, about {chars // 4} tokens loaded every session")
# 1. every command in AGENTS.md exists
scripts = json.load(open(os.path.join(repo, "package.json"))).get("scripts", {})
for cmd in re.findall(r"`((?:npm|npx)[^`]*)`", agents):
m = re.match(r"npm (?:run )?(\w+)$", cmd)
if m and m.group(1) not in ("ci", "install") and m.group(1) not in scripts:
problems.append(f"command `{cmd}` has no script in package.json")
for path in re.findall(r"\b((?:tests|app)/[\w./-]+)", cmd):
if not os.path.exists(os.path.join(repo, path)): problems.append(f"command `{cmd}` points at missing file {path}")
# 2. every path mentioned in backticks exists
for path in re.findall(r"`((?:tests|app|scripts)/[\w./-]*)`", agents):
if "*" not in path and not os.path.exists(os.path.join(repo, path.rstrip("/"))): problems.append(f"AGENTS.md mentions {path}, which does not exist")
# 3. Claude Code reads CLAUDE.md first, so it must import AGENTS.md
claude = read("CLAUDE.md") if os.path.exists(os.path.join(repo, "CLAUDE.md")) else ""
if "@AGENTS.md" not in claude: problems.append("CLAUDE.md does not import @AGENTS.md")
# 4. rules files carry a paths list; skills carry name and description
rules_dir = os.path.join(repo, ".claude", "rules")
for f in sorted(os.listdir(rules_dir)) if os.path.isdir(rules_dir) else []:
t = read(f".claude/rules/{f}")
if not re.search(r"^paths:\s*\n\s*- ", t, re.M): problems.append(f".claude/rules/{f} has no paths list, so it loads in every session")
skills_dir = os.path.join(repo, ".claude", "skills")
for d in sorted(os.listdir(skills_dir)) if os.path.isdir(skills_dir) else []:
t = read(f".claude/skills/{d}/SKILL.md")
name = re.search(r"^name:\s*(.+)$", t, re.M); desc = re.search(r"^description:\s*(.+)$", t, re.M)
if not name or name.group(1).strip() != d: problems.append(f"skill {d}: name missing or different from the folder")
if not desc: problems.append(f"skill {d}: description missing")
else: print(f"skill {d}: description {len(desc.group(1))} characters, about {len(desc.group(1)) // 4} tokens per session; body {len(t) // 4} tokens only when used")
# 5. size guidance
if lines > 200: problems.append(f"AGENTS.md is {lines} lines; keep it under 200")
problems = list(dict.fromkeys(problems))
print("\n" + ("\n".join("PROBLEM " + p for p in problems) if problems else "OK commands, paths, imports, rules and skills are consistent"))
sys.exit(1 if problems else 0)
It checks five things. Every command and path in AGENTS.md must exist. CLAUDE.md must import @AGENTS.md. Every rule file needs a paths: list. Each skill needs a name matching its folder, plus a description. AGENTS.md must stay under 200 lines. On the example repository:
AGENTS.md 28 lines, 1402 characters, about 350 tokens loaded every session
skill triage-failed-test: description 168 characters, about 42 tokens per session; body 250 tokens only when used
OK commands, paths, imports, rules and skills are consistent
On a deliberately broken copy, where a script was renamed, a test file moved, an import removed, a paths list dropped and a skill folder renamed:
AGENTS.md 28 lines, 1435 characters, about 358 tokens loaded every session
skill triage-failed-test: description 168 characters, about 42 tokens per session; body 247 tokens only when used
PROBLEM command `npm run e2e` has no script in package.json
PROBLEM command `npx playwright test tests/checkout/cart.spec.ts` points at missing file tests/checkout/cart.spec.ts
PROBLEM CLAUDE.md does not import @AGENTS.md
PROBLEM .claude/rules/playwright-tests.md has no paths list, so it loads in every session
PROBLEM skill triage-failed-test: name missing or different from the folder
Five problems, each of which would have degraded the agent with no visible error. The missing paths list is the quiet one: the rule would still work, but it would load in every session and cost tokens on every task. Run the checker in CI next to the linter.
How much does the setup cost in tokens?
Item
Size
When paid
AGENTS.md
28 lines, about 350 tokens
Every session
Skill description
168 characters, about 42 tokens
Every session
Skill body
About 250 tokens
When the skill is used, then for the rest of the session
Path rule
Short
When a matching file is touched
Lint, hook, checker
No tokens
When run
The always-loaded cost is roughly 400 tokens, small enough that no line needs a budget fight and large enough to discourage padding. The estimates use four characters per token, a rough convention, so read them as ratios.
What belongs where?
If the content is...
Put it in
A command, convention or boundary every task needs
AGENTS.md
A rule for some files only
.claude/rules/ with paths:
A procedure with several steps and judgement
A skill
A rule that must never be broken
Lint, a hook or CI, with the file stating it too
An action that must be blocked
A PreToolUse hook
Agent-specific tweaks
CLAUDE.md under the import
Standards used across repositories
A shared skill or template
Test code produced outside the agent loop belongs here too. A script drafted with Test Automation Genius, one more way to produce an agent input or a first draft, can be dropped into the repository. It is then held to the same lint rules and review as anything an agent writes, so the standards apply to every source of test code.
What guardrail mistakes do teams make most often with coding agents in a test repository?
Mistake
What it costs
Fix
One file that grows to hundreds of lines
Important rules get lost and every session pays for the rest
The agent decides when to stop
The same rules copied into several tool-specific files
Copies drift and conflict
One AGENTS.md and a thin CLAUDE.md that imports it
Rules with no enforcement
A violation is found in review, if at all
Lint, hooks and CI
Commands that no longer exist
The agent runs them, fails and improvises
Run the setup checker in CI
Secrets or environment details in agent files
Exposure through the repository
Keep them in the environment and reference variable names only
Rules written for a person
Context an agent cannot use, such as "ask the team lead"
Write what to do when unsure: stop and report
No definition of done
The agent decides when to stop
State what must pass and what the final message must list
How do you roll this out to a team?
Pilot on one repository, the one with the most test churn.
Review the files like code. Changes to AGENTS.md, rules, skills and hooks go through pull requests, with an owner for each.
Watch the first dozen agent changes. Each rule violation is a missing line, a weak line or a missing enforcement. Fix the layer that failed.
Keep a template with the layout, lint configuration, hook and checker, so new repositories start the same way.
Review on a schedule. After a Claude Code update, a Playwright upgrade or a change in conventions, read the files again and remove lines that no longer earn their place.
When the agent still gets it wrong, identify the layer: missing, unclear, misplaced or unenforced. Prefer enforcement over emphasis, and add a lint rule or script test where you can. Remove something when you add something, so the file stays small.
Frequently Asked Questions
What should I put in AGENTS.md for a test repository?
Exact commands to install, run and lint. Locator and assertion conventions stated as choices. Boundaries, such as files the agent must not edit and the rule that expected values are never changed to make a test pass. A definition of done. Keep it short enough that every line is read in every session.
AGENTS.md vs CLAUDE.md: what is the difference?
AGENTS.md is a shared instruction file read by many coding tools, and CLAUDE.md is the file Claude Code reads. Claude Code v2.1.277 and later reads AGENTS.md only when there is no CLAUDE.md, so the way to share one file is a CLAUDE.md containing @AGENTS.md plus any Claude-specific notes.
How long should AGENTS.md or CLAUDE.md be?
Under 200 lines according to Claude Code's documentation, and shorter is better. The example here is 28 lines. Move multi-step procedures to skills and file-specific rules to path-scoped rule files.
Do coding agents always follow AGENTS.md?
No. The files are context, not enforcement, and conflicting instructions across files may be resolved arbitrarily. Enforce rules that must hold with lint, hooks and CI, and keep the files consistent with a checker.
When should I use a skill instead of a rule?
Use a skill for a multi-step procedure needed occasionally, such as triaging a failed test. A skill costs a short description each session and loads its full body when used. Use a rule file for guidance tied to particular files.
How do I stop a coding agent from weakening my tests?
State the boundary in AGENTS.md, then enforce it. Lint rules block fixed waits, forced clicks, skipped tests and raw selectors, a hook blocks edits to config and app files, and a diff guard on agent pull requests flags changed assertions.
How do I block an agent from editing certain files in Claude Code?
Register a PreToolUse hook for the Edit and Write tools in .claude/settings.json. The hook script reads the tool call as JSON on standard input and exits with code 2 to block the edit, with a message that goes back to the agent. The script in this post does that for app/ and config files.
Do AI coding agents for testers need different files for each tool?
AGENTS.md is read by many tools, so it is the shared source. Skills, paths: rules and hooks are Claude Code features, so another tool needs its own equivalents.
Can I use the same setup with other coding tools?
AGENTS.md is read by many tools, which is why it is the shared source. Skills, paths: rules and hooks are Claude Code features, so another tool needs its own equivalents. Keep lint and CI enforcement tool-neutral so it protects the repository whichever agent is used.
Conclusion
AI coding agents for testers behave like the repository they read. A short AGENTS.md states what every task needs, path rules and skills keep detail out of sessions that do not need it, and lint, hooks and CI make the important rules real. The checker keeps the files honest as the repository changes. The always-loaded cost is about 400 tokens, and the setup turns an unsupervised draft with 14 lint problems into code that must pass the rules a reviewer cares about.
Key Takeaways
Give a coding agent three layers: a short always-loaded AGENTS.md, scoped rules and skills that load on demand, and automated enforcement.
CLAUDE.md is context, not enforcement. Enforce what must hold with lint, hooks and CI.
Share one file across tools with @AGENTS.md in CLAUDE.md. Claude Code 2.1.277 and later reads AGENTS.md only when no CLAUDE.md exists.
Keep it small: the example AGENTS.md is 28 lines and about 350 tokens, a skill description about 42 tokens and a skill body about 250 tokens.
The most important tester rule: never change an expected value to make a failing test pass. Report the mismatch as a possible product defect.
Write lines a violation of which can be detected: state the choice, give the alternative and prefer what a linter can check.
ESLint with Playwright rules flagged 14 problems in an agent-style test file. It did not flag a missing await, so keep running the tests.
A PreToolUse hook that exits with code 2 blocked edits to app/ and config files in our test, and let edits to tests through.
Give a skill a small input: a 564-character failure summary did the work of a 14,747-character report.
Check the agent files in CI. A checker found five problems in a broken setup that an agent would have followed silently.
This post measures the setup and the enforcement, not how closely any model follows instructions.
Happy Testing!
AI AgentsAGENTS.mdCLAUDE.mdAgent SkillsClaude Code HooksESLintPlaywrightTest automation
Hely PatelHead of Product and Marketing @AIdriventesting.ai. Leads the platform's AI testing tools from idea to launch, and writes about AI-driven testing and practical AI adoption for QA teams.