r/opencodeCLI • u/Ok-Buyer-9421 • 11h ago
How do you regression-test your AGENTS.md rules when switching models in OpenCode?
How do you know whether the new model still follows your engineering conventions?
I've been building an approach where written rules become executable tests, independently of the coding agent or model.
For example:
- Never mock our own hooks.
- Never use
time.sleep()in tests. - Always use our internal error class.
Each rule gets explicit passing and failing examples.
Glob and grep handle what can be checked deterministically. Specialized decision models handle what requires semantic judgment. Checks run at commit time or in CI.
In one of my experiments, 97.6% of checks could be handled before making a model call.
The idea isn't to replace linters or CI, but to make written conventions testable without having to implement every new rule manually.
I'm building this as an open-source project called Agentests: https://github.com/feuersteiner/agentests
Would love some feedback from people regularly switching between models.
2
u/CIYUANAIHUB 7h ago
I’d add a paired fixture for each rule: one case where it should apply and one where it shouldn’t. For the hook rule, use one test that imports an internal hook and another that uses an external dependency you do allow mocking. Run both in fresh sessions on the old and new models with the same repo snapshot, then inspect the diff for the actual mock target. That catches a model that passes by avoiding every mock. Score the pair separately from whether the tests pass.
2
u/lincolnthalles 3h ago
Linters are always better than a 400-line AGENTS.md block.
But model instructions are not an issue unless you make them so.
Write instructions targeting small models (procedural, imperative, one word, one meaning, condition first over trailing conditions, apply a no-op test to cut out crap or make it executable), and occasionally reconcile contradictions and gaps, and it will just work.
If the project is too big, apply high-signal routing in AGENTS.md so the model loads instructions on a need-to-know basis without bloating the context at once.
This may sound like outdated prompt-engineering advice, but top-performing models enrich your prompt internally, so applying a dumb-proof prompt won't worsen them and will level the field for dumber models.
1
u/Ariquitaun 7h ago
Ah, a solution in search of a problem