You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/web/src/content/docs/rules.mdx
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Rules
3
3
description: Set custom instructions for opencode.
4
4
---
5
5
6
-
You can provide custom instructions to opencode by creating an `AGENTS.md` file. This is similar to `CLAUDE.md` or Cursor's rules. It contains instructions that will be included in the LLM's context to customize its behavior for your specific project.
6
+
You can provide custom instructions to opencode by creating an `AGENTS.md` file. This is similar to Cursor's rules. It contains instructions that will be included in the LLM's context to customize its behavior for your specific project.
7
7
8
8
---
9
9
@@ -58,24 +58,41 @@ opencode also supports reading the `AGENTS.md` file from multiple locations. And
58
58
59
59
### Project
60
60
61
-
The ones we have seen above, where the `AGENTS.md`is placed in the project root, are project-specific rules. These only apply when you are working in this directory or its sub-directories.
61
+
Place an `AGENTS.md` in your project root for project-specific rules. These only apply when you are working in this directory or its sub-directories.
62
62
63
63
### Global
64
64
65
65
You can also have global rules in a `~/.config/opencode/AGENTS.md` file. This gets applied across all opencode sessions.
66
66
67
67
Since this isn't committed to Git or shared with your team, we recommend using this to specify any personal rules that the LLM should follow.
68
68
69
+
### Claude Code Compatibility
70
+
71
+
For users migrating from Claude Code, OpenCode supports Claude Code's file conventions as fallbacks:
72
+
73
+
-**Project rules**: `CLAUDE.md` in your project directory (used if no `AGENTS.md` exists)
74
+
-**Global rules**: `~/.claude/CLAUDE.md` (used if no `~/.config/opencode/AGENTS.md` exists)
75
+
-**Skills**: `~/.claude/skills/` — see [Agent Skills](/docs/skills/) for details
76
+
77
+
To disable Claude Code compatibility, set one of these environment variables:
78
+
79
+
```bash
80
+
export OPENCODE_DISABLE_CLAUDE_CODE=1 # Disable all .claude support
81
+
export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1 # Disable only ~/.claude/CLAUDE.md
82
+
export OPENCODE_DISABLE_CLAUDE_CODE_SKILLS=1 # Disable only .claude/skills
83
+
```
84
+
69
85
---
70
86
71
87
## Precedence
72
88
73
-
So when opencode starts, it looks for:
89
+
When opencode starts, it looks for rule files in this order:
74
90
75
-
1.**Local files** by traversing up from the current directory
76
-
2.**Global file** by checking `~/.config/opencode/AGENTS.md`
91
+
1.**Local files** by traversing up from the current directory (`AGENTS.md`, `CLAUDE.md`, or `CONTEXT.md`)
92
+
2.**Global file** at `~/.config/opencode/AGENTS.md`
93
+
3.**Claude Code file** at `~/.claude/CLAUDE.md` (unless disabled)
77
94
78
-
If you have both global and project-specific rules, opencode will combine them together.
95
+
The first matching file wins in each category. For example, if you have both `AGENTS.md` and `CLAUDE.md`, only `AGENTS.md` is used. Similarly, `~/.config/opencode/AGENTS.md` takes precedence over `~/.claude/CLAUDE.md`.
0 commit comments