Harness Notes

Instructions

Updated 2026-11-22,

On this page

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

QuestionOpenCodechecked 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 ~/.config/opencode/AGENTS.md (or $OPENCODE_CONFIG_DIR/AGENTS.md) and every AGENTS.md from the workspace directory up to your home directory, or up to the project root if the workspace is outside home. AGENTS.md files below the workspace are added during the session when the agent reads a file or lists a directory in that area.

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 AGENTS.md in ~/code/ or ~ is loaded too.

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 Instructions from: <path> block after the agent prompt and environment context. Nested files found later are added to the session history in discovery order, and OpenCode does not resolve conflicts between them.

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

QuestionOpenCodechecked 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

Yes. /init runs a guided setup that creates or improves AGENTS.md for the project; text after /init is passed as extra focus.

Control

QuestionOpenCodechecked 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 OPENCODE_DISABLE_PROJECT_CONFIG=1 (also read as OPENCODE_CONFIG_PROJECT_DISABLE) to skip project AGENTS.md discovery while keeping the global file. There is no switch for the global file and no exclude list.

Nested AGENTS.md files are still added when the agent reads files below the workspace.

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.

Notes and sources

OpenCode, 31 sources
Which files it reads, 7
Where it looks, and when nested files load, 8
When several apply, which wins, 4
Size limits, 4
One file for several harnesses, 6
Rules for some paths, or only on request, 7
Include other files, 4
Add instructions from config or flags, 16
Generate a starter file, 2
See what loaded, and apply edits, 4
Turn them off or skip some, 4
Enforce instructions for an organisation, 5