Instruction files are guidance you write once and every session reads, such as AGENTS.md, CLAUDE.md or Cursor rules. Notes a harness saves on its own are on the Memories page.
What gets loaded
| Question | OpenCodechecked at 2.0.30 |
|---|---|
| Which files it reads | Since 2.3.1, automatic discovery reads AGENTS.md with CLAUDE.md as a per-directory fallback when AGENTS.md is absent. The global fallback is ~/.claude/CLAUDE.md when the global AGENTS.md is missing. Configured instructions also load files, globs and HTTP(S) URLs. 2.3.2 source confirms per-directory AGENTS.md preference, global CLAUDE.md fallback and CLI environment opt-outs. Discovery composition accepts a separate claude option; custom hosts may set a different policy. The fallback also applies to nested discovery. Older 2.0.30 evidence remains historical; no model-delivery probe. |
| Where it looks, and when nested files load | At startup it loads If the workspace is outside the project root, only the global file is loaded. Inside home the walk can go past the repository root, so an 2.3.2 source confirms per-directory AGENTS.md preference, global CLAUDE.md fallback and CLI environment opt-outs. Discovery composition accepts a separate claude option; custom hosts may set a different policy. The fallback also applies to nested discovery. Older 2.0.30 evidence remains historical; no model-delivery probe. |
| When several apply, which wins | All applicable files are combined, not overridden: the global file first, then project files nearest-first, each as an Since 2.0.30, configured sources follow the global and project files in the baseline instruction list. |
| Size limits | For the historically reviewed file loader, each instruction file is included whole without a documented truncation limit. API-managed session instruction entries have a separate 256 KiB UTF-8 JSON value limit in 2.2.0. 2.2.0 source: the 256 KiB per-value limit belongs to API-managed instruction entries, not to the independently reviewed file loader. No total instruction-budget guarantee is inferred. |
Writing them
| Question | OpenCodechecked at 2.0.30 |
|---|---|
| One file for several harnesses | Partly AGENTS.md can be shared across harnesses. Since 2.3.1, CLAUDE.md is also discovered as a per-directory fallback, plus ~/.claude/CLAUDE.md when global AGENTS.md is missing. Set OPENCODE_DISABLE_CLAUDE_CODE or OPENCODE_DISABLE_CLAUDE_CODE_PROMPT to skip automatic CLAUDE.md fallback in the CLI. 2.3.2 source confirms per-directory AGENTS.md preference, global CLAUDE.md fallback and CLI environment opt-outs. Discovery composition accepts a separate claude option; custom hosts may set a different policy. The fallback also applies to nested discovery. Older 2.0.30 evidence remains historical; no model-delivery probe. |
| Rules for some paths, or only on request | Partly Nested AGENTS.md files load when the agent reads or lists their subtree. Since 2.0.30, configured globs select additional instruction files to load; those globs don't make an instruction apply only while matching files are edited. There are no frontmatter activation rules. 2.3.2 source confirms per-directory AGENTS.md preference, global CLAUDE.md fallback and CLI environment opt-outs. Discovery composition accepts a separate claude option; custom hosts may set a different policy. The fallback also applies to nested discovery. Older 2.0.30 evidence remains historical; no model-delivery probe. |
| Include other files | Partly AGENTS.md content is sent as-is; @path references inside it are not expanded. Since 2.0.30, use the instructions config array to load extra files, glob matches or HTTP(S) URLs. Relative patterns search upward from the workspace to the project root; ~/ and absolute paths are accepted. 2.2.0 source fixes absolute instruction globs with wildcard directories: when the parent is not a literal directory, scan the whole absolute pattern rather than only its basename. |
| Add instructions from config or flags | Since 2.0.30, opencode.json instructions entries load files, globs and HTTP(S) URLs. Config entries are combined and deduplicated by source string. URLs are fetched on config load/change with a five-second timeout; a failed fetch retains the last successful copy or skips that URL. Clients can still set per-session instruction entries through the server API. 2.2.0 source: ctx.session.instructions.entry.put/list/remove and server endpoints manage persistent JSON values under api/<key>. Keys match lowercase alphanumerics with . _ -, starting alphanumeric; each JSON-encoded value is limited to 256 KiB UTF-8. Values render as context blocks; updates/removals appear at the next model step without starting a turn. Compaction advances the baseline; reverting history does not delete current entry rows. This is session guidance, not enforced policy. |
| Generate a starter file |
Control
| Question | OpenCodechecked at 2.0.30 |
|---|---|
| See what loaded, and apply edits | Partly Global and upward AGENTS.md edits are watched. Since 2.0.30, matched configured local instruction files are watched too; config.updated triggers a rescan and URL refetch. Remote content is not polled on every file rescan. These sources appear as Instructions from: <path> blocks; older nested-file evidence remains separately pinned. |
| Turn them off or skip some | Partly Set Nested In 2.0.30, explicit absolute paths and URLs can still load even when discovery scopes are disabled. Relative configured patterns use project discovery when enabled, otherwise the global config directory when global discovery is enabled. Disabling project discovery is not a blanket ban on configured instructions. |
| Enforce instructions for an organisation | Partly Since 2.0.30, instructions entries from managed config documents also contribute guidance. The same loader combines entries from other config scopes, so managed instructions do not create an exclusive instruction set. A system-directory AGENTS.md is not automatically discovered. Source establishes loading, not model compliance. |