Skip to content

Instantly share code, notes, and snippets.

@zeke
Created January 13, 2026 18:05
Show Gist options
  • Select an option

  • Save zeke/c6bed98a445e559b0d3563087b5e6764 to your computer and use it in GitHub Desktop.

Select an option

Save zeke/c6bed98a445e559b0d3563087b5e6764 to your computer and use it in GitHub Desktop.
OpenCode reads ~/.claude/CLAUDE.md (undocumented Claude Code compatibility)

OpenCode reads ~/.claude/CLAUDE.md (undocumented)

If you use both OpenCode and Claude Code, you may notice that OpenCode automatically picks up your ~/.claude/CLAUDE.md file.

This is intentional but undocumented behavior for Claude Code compatibility.

How it works

OpenCode loads instruction files from multiple locations:

  1. Project-level (documented): AGENTS.md, CLAUDE.md, or CONTEXT.md in your project directory
  2. Global (documented): ~/.config/opencode/AGENTS.md
  3. Claude Code compat (undocumented): ~/.claude/CLAUDE.md

The relevant code is in packages/opencode/src/session/system.ts:

const GLOBAL_RULE_FILES = [path.join(Global.Path.config, "AGENTS.md")]
if (!Flag.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT) {
  GLOBAL_RULE_FILES.push(path.join(os.homedir(), ".claude", "CLAUDE.md"))
}

Disabling this behavior

If you don't want OpenCode to read your ~/.claude/CLAUDE.md file, set the environment variable:

export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1

What's documented vs undocumented

The official Rules documentation only mentions:

  • Project-level AGENTS.md files
  • Global ~/.config/opencode/AGENTS.md

It does not mention the ~/.claude/CLAUDE.md compatibility feature.

Why this matters

If you have different instructions for Claude Code vs OpenCode, you may get unexpected behavior. Your Claude Code instructions will be applied to OpenCode sessions automatically.

Skills too

OpenCode also scans ~/.claude/skills/ for agent skills, as shown in packages/opencode/src/skill/skill.ts:

// Also include global ~/.claude/skills/
const globalClaude = `${Global.Path.home}/.claude`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment