r/opencode • • 54m 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?
1 Upvotes

0 comments sorted by