Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 542c9d5

Browse files
authored
feat(flags): allow disabling .claude prompt and skills loading (anomalyco#7205)
1 parent d5f0e3f commit 542c9d5

4 files changed

Lines changed: 31 additions & 20 deletions

File tree

packages/opencode/src/flag/flag.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export namespace Flag {
1313
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
1414
export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")
1515
export const OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH")
16+
export const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")
17+
export const OPENCODE_DISABLE_CLAUDE_CODE_PROMPT =
18+
OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT")
19+
export const OPENCODE_DISABLE_CLAUDE_CODE_SKILLS =
20+
OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_SKILLS")
1621
export const OPENCODE_FAKE_VCS = process.env["OPENCODE_FAKE_VCS"]
1722
export const OPENCODE_CLIENT = process.env["OPENCODE_CLIENT"] ?? "cli"
1823

packages/opencode/src/session/system.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export namespace SystemPrompt {
6262
"CLAUDE.md",
6363
"CONTEXT.md", // deprecated
6464
]
65-
const GLOBAL_RULE_FILES = [
66-
path.join(Global.Path.config, "AGENTS.md"),
67-
path.join(os.homedir(), ".claude", "CLAUDE.md"),
68-
]
65+
const GLOBAL_RULE_FILES = [path.join(Global.Path.config, "AGENTS.md")]
66+
if (!Flag.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT) {
67+
GLOBAL_RULE_FILES.push(path.join(os.homedir(), ".claude", "CLAUDE.md"))
68+
}
6969

7070
if (Flag.OPENCODE_CONFIG_DIR) {
7171
GLOBAL_RULE_FILES.push(path.join(Flag.OPENCODE_CONFIG_DIR, "AGENTS.md"))

packages/opencode/src/skill/skill.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Log } from "../util/log"
77
import { Global } from "@/global"
88
import { Filesystem } from "@/util/filesystem"
99
import { exists } from "fs/promises"
10+
import { Flag } from "@/flag/flag"
1011

1112
export namespace Skill {
1213
const log = Log.create({ service: "skill" })
@@ -80,22 +81,24 @@ export namespace Skill {
8081
claudeDirs.push(globalClaude)
8182
}
8283

83-
for (const dir of claudeDirs) {
84-
const matches = await Array.fromAsync(
85-
CLAUDE_SKILL_GLOB.scan({
86-
cwd: dir,
87-
absolute: true,
88-
onlyFiles: true,
89-
followSymlinks: true,
90-
dot: true,
91-
}),
92-
).catch((error) => {
93-
log.error("failed .claude directory scan for skills", { dir, error })
94-
return []
95-
})
96-
97-
for (const match of matches) {
98-
await addSkill(match)
84+
if (!Flag.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS) {
85+
for (const dir of claudeDirs) {
86+
const matches = await Array.fromAsync(
87+
CLAUDE_SKILL_GLOB.scan({
88+
cwd: dir,
89+
absolute: true,
90+
onlyFiles: true,
91+
followSymlinks: true,
92+
dot: true,
93+
}),
94+
).catch((error) => {
95+
log.error("failed .claude directory scan for skills", { dir, error })
96+
return []
97+
})
98+
99+
for (const match of matches) {
100+
await addSkill(match)
101+
}
99102
}
100103
}
101104

packages/web/src/content/docs/cli.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,9 @@ OpenCode can be configured using environment variables.
566566
| `OPENCODE_DISABLE_LSP_DOWNLOAD` | boolean | Disable automatic LSP server downloads |
567567
| `OPENCODE_ENABLE_EXPERIMENTAL_MODELS` | boolean | Enable experimental models |
568568
| `OPENCODE_DISABLE_AUTOCOMPACT` | boolean | Disable automatic context compaction |
569+
| `OPENCODE_DISABLE_CLAUDE_CODE` | boolean | Disable reading from `.claude` (prompt + skills) |
570+
| `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` | boolean | Disable reading `~/.claude/CLAUDE.md` |
571+
| `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | boolean | Disable loading `.claude/skills` |
569572
| `OPENCODE_CLIENT` | string | Client identifier (defaults to `cli`) |
570573
| `OPENCODE_ENABLE_EXA` | boolean | Enable Exa web search tools |
571574

0 commit comments

Comments
 (0)