AGENTS.md files, and dynamic sources
such as skill, reference, MCP, and session context into a durable instruction
baseline.
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 instruction baseline, 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 baseline.
Changes
Before each model step, V2 compares live instruction sources with what that session’s model was last told:- 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 baseline exists yet, the first model step waits until required sources are available.
- Completed conversation compaction creates a fresh baseline from the current sources. Moving a session or committing a revert also resets its instruction checkpoint so the next step establishes a new baseline.