01 / Good and bad pairs
Paired examples throughout
Destructuring, variable count, control flow and schema definitions each get good and bad examples within one fenced block. The rule is stated in one line and then shown twice, marked good and bad.

Open source coding agent, built for the terminal.
OpenCode argues against premature abstraction, then states rules its session core must always preserve. Five examples put bad and good code side by side; a sixth shows the intended helper-based flow.
├── └── packages ├── app │ ├── e2e │ │ └── performance │ │ └── │ └── ├── core │ └── src │ └── tool │ └── ├── desktop │ └── ├── effect-drizzle-sqlite │ └── ├── llm │ └── ├── opencode │ ├── src │ │ ├── server │ │ │ └── routes │ │ │ └── instance │ │ │ └── httpapi │ │ │ └── │ │ └── session │ │ └── llm │ │ └── │ └── ├── schema │ └── └── stats └──
01 / Good and bad pairs
Destructuring, variable count, control flow and schema definitions each get good and bad examples within one fenced block. The rule is stated in one line and then shown twice, marked good and bad.
02 / Behavioral framing
Keep logic inline unless it is reused, hides a real boundary, or has a name that improves the caller. The file repeats this rule in both general and complex-logic sections.
Source excerpt starting at line 26.- Do not extract single-use helpers preemptively. Inline the logic at the call site unless the helper is reused, hides a genuinely complex boundary, or has a clear independent name that improves the caller.
03
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.
Source excerpt starting at line 3.- Keep runtime dependencies directed from Schema to Core and Protocol, then from Core and Protocol to Server. Client runtime code may depend on Schema and Protocol but never Core or Server; `sdk-next` composes Client, Core, and Server.
04
At most three words, hyphenated, no slashes, no type prefixes, with three examples given.
05
The session core records invariants the type system cannot hold: separate durable admission from model execution, allow one provider stream per turn, and never bridge through the legacy loop.
Source excerpt starting at line 157.- Preserve one explicit `llm.stream(request)` call per provider turn and reload projected history before durable continuation. Do not bridge through legacy `SessionPrompt.loop(...)` or delegate orchestration to an in-memory tool loop.
06
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.
These instructions explain how to work in opencode. Modem shows your agents what customers said, who is affected, and what changed.