Audit a repository against its own agent rules. Reads AGENTS.md, CLAUDE.md and similar files, counts the rules nothing enforces, compiles 5 to 7 into agentests Tests, replays the last 30 days of merged PRs and reports the violation rate for agents vs people. Read-only, no API key. Use when the user asks "does my agent follow AGENTS.md?", "audit my repo against our rules" or "which PRs broke our conventions?".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Agentests Audit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mlgxiii-agentests-audit)
---
name: agentests-audit
description: Audit a repository against its own agent rules. Reads AGENTS.md, CLAUDE.md and similar files, counts the rules nothing enforces, compiles 5 to 7 into agentests Tests, replays the last 30 days of merged PRs and reports the violation rate for agents vs people. Read-only, no API key. Use when the user asks "does my agent follow AGENTS.md?", "audit my repo against our rules" or "which PRs broke our conventions?".
---
# agentests audit
You told your agents the rules. This shows how many of them nothing enforces, and how often agents and
people broke them last month: which merged PRs, which rule, where. The output is one report, `AUDIT.md`.
**Never change the user's repository.** Everything happens in a detached git worktree and an output
folder outside it. Never comment on PRs or issues, never push. What gets shared is the user's call.
Needs Node 22+ and git. `gh`, signed in, lists merged PRs; without it the replay uses first-parent
history. No API key: by default only agentests' grep and glob stages run, and you judge what they
find. `--keys` on `setup` runs the model stages too, with the keys from the user's `.env`.
`SCRIPT` means `node <this skill's folder>/scripts/audit.mjs`.
## 1. Set up
`SCRIPT setup --repo <repository root>` installs agentests into the output folder, creates the
worktree and prints both paths. Pass the printed `out` folder as `--out` from here on.
## 2. Classify every rule, then pick 5 to 7
Read every rules file: `AGENTS.md` and `CLAUDE.md` at any depth, `.cursor/rules/`,
`.github/copilot-instructions.md`, `.windsurfrules`, `GEMINI.md`. Write every rule in them to
`<out>/rules.json`:
```json
[{ "source": "AGENTS.md:42", "text": "Log with get_logger(), never print().", "status": "checked" }]
```
`status` is `enforced` (a linter, formatter, CI job or type checker already does it: check their
configs), `checked` (one of your picks), `unchecked` (checkable, not picked), `process` ("run the tests
first") or `vague` (two reviewers wouldn't agree). The report opens with the rules nothing enforces.
Pick **5 to 7** `checked` rules that show in what a PR adds, two reviewers would agree on, and are
likely to be broken: conventions that differ from the language's habits, such as a project logger, no
naive `datetime.now()`, typed test parameters, no AI attribution in commits. List the picks for the
user with file and line. Carry on without waiting: the audit changes nothing.
## 3. Write a Test per rule
In the worktree, run `node <out>/tools/node_modules/agentests/dist/cli/index.js compile <test-id>`
for each rule. Follow the instructions it prints, plus these:
- Quote the rule's source (file and line) and its exceptions in `TEST.md`.
- **Every assertion has a `grep`** that matches every possible violation. Broad is fine: grep picks
candidates, you judge them. An assertion without a grep can't run keyless.
- Scope `select.glob` to the files the rule covers.
- At least one `fail` eval, one near-miss `pass` eval and one `skip` eval.
**Message rules** are about the PR, not the code. Give them `select.glob: .agents/audit/pr-message.md`:
the replay runs their grep on each PR's title, body and merge commit message, and an eval puts its
message in that file. Until agentests checks PR messages itself, `scripts/audit.mjs` does it.
```yaml
select: { glob: .agents/audit/pr-message.md }
assert:
- { id: no-ai-trailer, description: No AI attribution line., error: Remove the AI attribution.,
grep: '^Co-[Aa]uthored-[Bb]y:.*(Claude|Codex|Cursor)|[Gg]enerated with \[?Claude' }
```
## 4. Prove the Tests
`SCRIPT evals --out <out>`. A Test holds when grep catches every `fail` eval and skips every `skip` eval. Near misses grep flags
are fine: you judge them in step 6. Fix and rerun until every Test holds.
## 5. Replay the merged PRs
```sh
SCRIPT replay --out <out> [--days 30] [--prs 200] [--agents my-agent,other-agent]
```
By default: PRs merged in the last 30 days, at most 200. `--search` takes a GitHub search instead.
Each merge commit is checked against its parent. A match counts when it covers a line the PR added,
so swapping one violation for another counts too. Matches on old lines only are left out.
Each PR's author is an **agent**, a **bot** (Renovate, Dependabot, release and sync bots: not checked)
or a **person**. An agent PR records why: `login` (Devin, Copilot), `trailer` (an agent co-author or
"Generated with" line in its commit messages), `body marker` (Cursor's PR marker, "Codex assisted", a
Devin session link; naming a tool isn't one) or `commit co-author` (an agent on one of the PR's own
commits, read with `gh api`). A repo's own agent goes in `--agents`. `classify --input f.json` tests it.
## 6. Judge every candidate
Each candidate in `<out>/candidates.json` has the rule, the check and the added lines that matched. Set:
- `verdict`: `"violation"` only when an added line breaks the rule as written, exceptions included.
Otherwise `"false-alarm"`. If the snippet isn't enough: `git -C <worktree> show <merge>:<path>`.
- `note`: one plain sentence, such as "Untyped `flow_run` parameter in `test_retries`".
Be strict. Every violation has to hold up when the user checks it. When one rule gives **more than 5
false alarms**, narrow its grep: add those false alarms as near-miss `pass` evals, run steps 4 and 5
again (verdicts already given are kept) and judge what's new. Then report.
## 7. Report
`SCRIPT report --out <out>`. Show its first lines: the rules nothing enforces, the PRs that broke a rule
with the rate for agents and for people, and "At your rate, N agent PRs a month means about K violations
merged a month". Then the violations table, the agent PRs by reason and the path to `AUDIT.md`. Say
that you judged the candidates and each violation should be confirmed before the report is shared.
## 8. Offer next steps
- **Keep the rules from being broken again:** copy `<out>/tests/` to `.agents/tests/` and run
`npx agentests init` for the pre-commit hook. Only when the user asks: it changes their repo.
- **Clean up:** `SCRIPT cleanup --out <out>` removes the worktree. The report and Tests stay.
## Tested
- 20 public repos (Prefect, Sentry, tldraw, n8n, OpenHands and others), 50 merged PRs each, keyless.
Bot PRs, match counts and agent PRs counted as people's (langfuse, prefect, mastra) are fixed.
- tldraw, last 30 days: 200 PRs (52 agent, 114 person, 34 bot). Its no-AI-attribution rule as a
message rule flagged all 52 agent PRs; 12 code candidates.
- `tests/agentests-audit/`: `fixture-replay`, `authors-swap-message` (bots, agents, a swapped `print()`)
and `agent-markers` (body markers and agent co-authors count; "cursor position" and Renovate don't).