AGENTS.md files, and dynamic sources
such as skill, reference, MCP, and session context. It stores source values as
durable deltas, then renders initial instructions and chronological updates when
assembling each model request.
AGENTS.md
UseAGENTS.md for persistent guidance such as build commands, architecture,
code conventions, and verification requirements. Commit project files so the
whole team receives the same instructions.
V2 loads:
- The global file at
$XDG_CONFIG_HOME/opencode/AGENTS.md, normally~/.config/opencode/AGENTS.md. - Every
AGENTS.mdfrom the current Location up to and including the project root.
packages/web, OpenCode can load all three
project files below:
OPENCODE_DISABLE_PROJECT_CONFIG=1 also skips project AGENTS.md
discovery but does not disable the global file.
Current V2 discovery only recognizes
AGENTS.md. The CLAUDE.md fallback
and related precedence described by older OpenCode documentation do not apply.Nested instructions
AnAGENTS.md below the Location is not part of the initial upward scan. When
the read tool successfully reads a file or lists a directory, OpenCode discovers
AGENTS.md files from that target upward to, but not including, the Location.
It adds newly discovered files to the session in nearest-first order.
Each nested file is injected once per session and recorded in durable session
history. Reading the same area again does not inject it again. Consequently,
editing an already injected nested AGENTS.md does not replace its earlier
session entry automatically; start a new session if the updated text must apply
immediately.
Config entries
The V2 config schema accepts aninstructions array of strings:
opencode.jsonc
instructions, the highest-precedence, closest config’s
entire array is selected; arrays are not merged.
See Config for config locations and general precedence.
Ordering
The selected agent or provider system prompt is sent first. OpenCode then sends the session’s initial instructions, composed in this order:- Built-in environment and date context.
- Ambient
AGENTS.mddiscovery. - Available skill, reference, and MCP guidance.
- Session-specific instruction entries supplied through the API.
AGENTS.md files discovered by reads are chronological session entries rather
than part of the initial instructions.
Changes
Before promoting pending input, V2 compares live instruction sources with the latest admitted source values:- A new or changed ambient
AGENTS.mdaggregate is announced as a system update that replaces the previous ambient aggregate. - Removing all ambient files announces that the previous ambient instructions no longer apply.
- A temporary read or discovery failure preserves the session’s last known instructions instead of treating them as deleted. If no instruction epoch exists yet, pending input waits until every source is available.
- Completed conversation compaction advances the instruction epoch, making the currently admitted values initial without rereading sources or authoring an instruction event.
- Moving a session or committing a revert clears the instruction fold. The next safe boundary requires one complete source read before promoting input.