AGENTS.md directory

opencode

Open source coding agent, built for the terminal.

Twelve code blocks in 161 lines; most style rules show the wrong version beside the right one.

By the numbers

161
Lines
1,234
Words
about 6 min read
8.5kB
File size
13
Headings
36
Bullet rules
12
Code blocks
0
Links to other docs
207.1k
Repo stars

File measured on dev at commit f444236. Analysis written 2026-09-14. Star count is a snapshot from September 2026.

What kind of file this is

A style guide that argues against abstraction, followed by a set of runtime invariants for its session core. The highest ratio of code to prose in the directory.

Techniques in this file

Quoted lines are verbatim from the file. Open one to see it where it sits.

Paired examples throughout

Good and bad pairs

Destructuring, variable count, control flow and schema definitions each get a two-block comparison. The rule is stated in one line and then shown twice, marked good and bad.

A rule against extracting helpers

Behavioral framing

Logic stays in one function unless it is reused, hides a genuinely complex boundary, or has a name that improves the caller. The same instruction appears twice in the file, once in the general principles and once under complex logic.

Dependency direction in one sentence

A single line fixes the allowed direction across six packages, including which layers client runtime code may never reach. It can be checked at an import without opening a config file.

A four-line branch naming convention

At most three words, hyphenated, no slashes, no type prefixes, with three examples given.

Runtime invariants written as prose

The session core section states properties the type system does not hold: durable admission stays separate from model execution, one provider stream call per turn, no bridging through the legacy loop. They are written as standing constraints rather than as style.

Environment facts that prevent dead ends

The default branch is dev, a local main ref may not exist, and tests cannot run from the repository root because of a named guard. Three lines, each covering a state an agent would otherwise have to discover.

Takeaways for your own repo

  • Pair every style rule with a wrong example.
  • If agents over-abstract in your codebase, state it directly. "Do not extract single-use helpers" is an instruction.
  • State dependency direction in one sentence, even where a config file already enforces it.
  • Write down the branch naming convention with three examples.
  • Note the default branch if it is not main, and any command that fails from the repository root.

How the file is organized

  1. 01Repo and SDK generation notes
  2. 02Branch Names
  3. 03Commits and PR Titles
  4. 04Style Guide
  5. 05Destructuring, Imports, Variables, Control Flow
  6. 06Complex Logic
  7. 07Schema Definitions
  8. 08Testing
  9. 09Type Checking
  10. 10V2 Session Core
Read the full file on GitHub

Context your AGENTS.md cannot carry

opencode's file tells an agent how the codebase works. It cannot tell it which bug three customers hit this week. Modem keeps that context current and attaches it to the work.