Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save zeke/9927445e67b28cd97a1afa916dbdd444 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](https://opencode.ai) and [Claude Code](https://docs.anthropic.com/en/docs/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`](https://github.com/anomalyco/opencode/blob/c87939ad122a79150fa6360dacfdef63ea396b2d/packages/opencode/src/session/system.ts#L70-L73):
```typescript
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:
```bash
export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1
```
## What's documented vs undocumented
The [official Rules documentation](https://opencode.ai/docs/rules/) 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](https://opencode.ai/docs/skills/), as shown in [`packages/opencode/src/skill/skill.ts`](https://github.com/anomalyco/opencode/blob/c87939ad122a79150fa6360dacfdef63ea396b2d/packages/opencode/src/skill/skill.ts#L78-L79):
```typescript
// 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