r/opencode • • 7d ago

Vague rules vs. checkable rules in AGENTS.md: a few rewrites

I've been thinking about how to write instructions files for coding agents. The docs say OpenCode loads AGENTS.md from the project and the global config, and combines the files without reconciling them. So if two files disagree, nothing resolves the conflict. That made me want to keep each rule short and testable.

My working test for a line is: "Could someone check, in under a minute, whether the agent followed this?" If not, it's probably too vague to help.

Some rewrites:

VagueCheckable
Write clean codeFunctions over ~40 lines get split. Run npm run lint before finishing
Add testsEvery bug fix adds a test that fails without the fix
Be careful with the databaseNever edit files in migrations/ that are already committed. Add a new migration instead
Follow our conventionsAPI handlers live in src/routes/, one file per resource. Use zod for input validation
Don't break thingsRun npm test and report the result. If it fails, say which test and stop

Two other things I try to follow:

  • Don't write rules a tool can enforce. If a formatter or linter can do it, I'd rather run that than ask the model to remember it.
  • Put the commands in. "How to run tests / lint / build" is often the most useful part, because otherwise the agent guesses.

The docs also mention an instructions array in the config that can point to other files, and that nested AGENTS.md files load when the agent reads something in that directory. I haven't used that for anything big, so I'd like to hear how others split things up. [Optional: add one real example of a rule that helped or didn't. Delete if none.]

Questions for people who use it daily:

  1. How long is your AGENTS.md, and do you prune it?
  2. Do you use one root file, or nested files per folder?
  3. What's a rule you added that the agent still ignores?
  4. Do you keep a global file for personal preferences?
5 Upvotes

1 comment sorted by

1

u/Ok-Buyer-9421 21h ago

Really agree with the distinction between rules that tools can enforce and those that require judgment. One thing I'd add: even when a rule is clearly written and checkable, that doesn't mean the agent will follow it. I've been exploring this - turning engineering rules into executable assertions, using deterministic checks wherever possible and specialized decision models like Jev for the semantic ones. The goal is to test compliance rather than rely on instructions alone.
Btw this is the project I'm working on if you wante dto have a look https://github.com/feuersteiner/agentests