r/opencodeCLI • • 3h ago

Are agents.md essentially a wishlist?

I audited 20 open-source repos to see how often their written agent rules were actually followed. Four of them banned AI co-author lines in AGENTS.md.

But found that agent PRs added them anyway, 102 times in a month.

So, I've been working on an approach that turns AGENTS.md rules into executable checks:

  • Glob selects the relevant files.
  • Grep catches deterministic violations.
  • A model judges anything that requires interpretation.

The checks live in the repo and don't depend on which coding agent you use.
How do you enforce your AGENTS.md rules beyond putting them in the agent's context?? Tips wanted :)

4 Upvotes

5 comments sorted by

6

u/Starks1293 3h ago

rules in AGENTS.md are a wishlist, rules in tests arent. what works for me in a big repo: when a rule matters, it becomes a test that reads the source. "this module never imports that one" is a test that checks the imports. "every stylesheet sticks to the tokens" is a test that reads every css file. for ur co-author example, thats a commit-msg hook, not a sentence. the agent can ignore a sentence, it cant ignore a red build

what stays in AGENTS.md is the why and the where, which file owns what, so the agent knows where things go and which test will shout if it gets it wrong

id keep the model-as-judge part small, its the one that drifts. if a rule can be a grep, make it a grep

(context, i build a mac app for running these agents, AI Bridge, and most of its rules file by now points at the test that pins each rule)

1

u/Ok-Buyer-9421 3h ago

Definitely. Especially on keeping the model-as-judge part small. In one of my audits, 97.6% of checks were handled by glob and grep alone.
Really like your approach of AGENTS.md pointing to the tests that enforce each rule. Will check out AI Bridge :)

4

u/vpz 3h ago

Anything in a context file is a suggestion. Doesn't matter what kind of context file. Enforcement depends on the harness. For example agent lifecycle hooks like PreToolUse, Stop, etc. If it's a custom harness/app, it can use deterministic code to apply enforcement at appropriate workflow gates like in a graph-based workflow. If working with git then pre-commit hooks in the local repo like format, lint, test, etc. And then CI related code/tests on PR submission which can include code to send evidence to a human reviewer like screenshots showing a rule was followed. It isn't one thing enforcing rules, it's a system of layered enforcement that tries to catch drift quickly and provide useful feedback to the agent every there is a violation. So don't just block, respond with why and what to do instead if possible.

1

u/Ok-Buyer-9421 3h ago

Really like your point about not just blocking but explaining why and what to do instead. The challenge with layered enforcement is keeping the rules consistent across hooks, CI and different agent harnesses. Ideally, you'd define the rule once and enforce it at different stages. Thanks for sharing :)