Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/cli/src/server-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
content: process.env.OPENCODE_CONFIG_CONTENT,
},
instructions: {
claude: !truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE),
// As in V1, the prompt flag only skips ~/.claude/CLAUDE.md.
claudeGlobal: !(
claude: !(
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE) ||
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT)
),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/plugin/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Plugin = define({
// ~/.claude/CLAUDE.md stands in for the global AGENTS.md when it is missing.
const claudeGlobalFile = yield* fs.resolve(join(home, ".claude", "CLAUDE.md"))
const names = InstructionDiscovery.filenames(discovery)
const globalFiles = discovery.claudeGlobal ? [globalFile, claudeGlobalFile] : [globalFile]
const globalFiles = discovery.claude ? [globalFile, claudeGlobalFile] : [globalFile]
const loaded: { current: Loaded } = { current: { type: "available", files: [] } }
const configured: { sources: string[]; remote: Map<string, InstructionDiscovery.File> } = {
sources: [],
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/instruction-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ export interface Interface extends State.Transformable<Editor> {
// Move it into plugin config once plugins can consume their own options.
readonly project: boolean
readonly global: boolean
// Also read CLAUDE.md where no AGENTS.md exists.
// Read CLAUDE.md where no AGENTS.md exists, and ~/.claude/CLAUDE.md when the global AGENTS.md is missing.
readonly claude: boolean
// Read ~/.claude/CLAUDE.md when the global AGENTS.md is missing.
readonly claudeGlobal: boolean
readonly list: () => Effect.Effect<File[] | Instructions.Unavailable>
readonly load: () => Effect.Effect<Instructions.List>
}
Expand All @@ -53,7 +51,6 @@ export const Options = Schema.Struct({
project: Schema.optional(Schema.Boolean),
global: Schema.optional(Schema.Boolean),
claude: Schema.optional(Schema.Boolean),
claudeGlobal: Schema.optional(Schema.Boolean),
})
export type Options = typeof Options.Type

Expand Down Expand Up @@ -106,7 +103,6 @@ export const layer = (options?: Options) =>
project: options?.project !== false,
global: options?.global !== false,
claude: options?.claude !== false,
claudeGlobal: options?.claudeGlobal !== false,
transform: state.transform,
reload: state.reload,
list,
Expand Down
17 changes: 5 additions & 12 deletions packages/core/test/instruction-discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const instructionLayer = (input: {
http?: HttpClient.HttpClient
project?: boolean
claude?: boolean
claudeGlobal?: boolean
}) => {
const watcher = Watcher.testLayer
const config = Config.testLayer(input.instructions ? [configured(input.instructions)] : [])
Expand All @@ -55,7 +54,6 @@ const instructionLayer = (input: {
InstructionDiscovery.configured({
project: input.project,
claude: input.claude,
claudeGlobal: input.claudeGlobal,
}),
),
Global.node.replace(
Expand Down Expand Up @@ -439,16 +437,16 @@ describe("ConfigInstructionPlugin.Plugin", () => {
const claudeGlobal = path.join(home, ".claude", "CLAUDE.md")
const projectAgents = path.join(project, "AGENTS.md")
const packageClaude = path.join(directory, "CLAUDE.md")
const load = (options: { claude?: boolean; claudeGlobal?: boolean } = {}) =>
const load = (claude?: boolean) =>
Effect.gen(function* () {
const discovery = yield* start()
return (yield* readInitial(yield* discovery.load())).text
}).pipe(Effect.provide(layer(options)), Effect.scoped)
const layer = (options: { claude?: boolean; claudeGlobal?: boolean }) =>
}).pipe(Effect.provide(layer(claude)), Effect.scoped)
const layer = (claude?: boolean) =>
instructionLayer({
config: global,
home,
...options,
claude,
locationServiceLayer: Layer.succeed(
Location.Service,
Location.Service.of(
Expand All @@ -474,11 +472,6 @@ describe("ConfigInstructionPlugin.Plugin", () => {
].join("\n\n"),
)

// The prompt flag only drops the global fallback, as in V1.
const withoutGlobal = yield* load({ claudeGlobal: false })
expect(withoutGlobal).not.toContain("claude global")
expect(withoutGlobal).toContain(`Instructions from: ${packageClaude}\npackage claude`)

yield* Effect.promise(async () => {
await fs.mkdir(global, { recursive: true })
await fs.writeFile(path.join(global, "AGENTS.md"), "global agents")
Expand All @@ -487,7 +480,7 @@ describe("ConfigInstructionPlugin.Plugin", () => {
expect(preferred).toContain(`Instructions from: ${path.join(global, "AGENTS.md")}\nglobal agents`)
expect(preferred).not.toContain("claude global")

const disabled = yield* load({ claude: false, claudeGlobal: false })
const disabled = yield* load(false)
expect(disabled).not.toContain("CLAUDE.md")
expect(disabled).toContain(`Instructions from: ${projectAgents}\nproject agents`)
})
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/session-generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ const discovery = Layer.mock(InstructionDiscovery.Service, {
project: true,
global: true,
claude: true,
claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skills = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/session-runner-recorded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ const instructionContext = Layer.mock(InstructionDiscovery.Service, {
project: true,
global: true,
claude: true,
claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skillInstructions = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/session-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ const layer = Layer.unwrap(
project: true,
global: true,
claude: true,
claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skillInstructions = Layer.mock(SkillInstructions.Service, {
Expand Down
4 changes: 1 addition & 3 deletions packages/server/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export const ServerOptions = Schema.Struct({
),
instructions: Schema.optional(
Schema.Struct({
// false skips the per-directory CLAUDE.md fallback.
// false skips the per-directory and ~/.claude/CLAUDE.md fallbacks.
claude: Schema.optional(Schema.Boolean),
// false skips the ~/.claude/CLAUDE.md fallback.
claudeGlobal: Schema.optional(Schema.Boolean),
}),
),
windows: Schema.optional(
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ function makeRoutes<AuthError, AuthServices>(
InstructionDiscovery.configured({
project: options.config?.project,
claude: options.instructions?.claude,
claudeGlobal: options.instructions?.claudeGlobal,
}),
),
ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
Expand Down
6 changes: 3 additions & 3 deletions services/site/src/docs/content/instructions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ In any directory without an `AGENTS.md`, OpenCode reads `CLAUDE.md` instead. Wit
`~/.config/opencode/AGENTS.md`, it reads `~/.claude/CLAUDE.md`. A directory's `AGENTS.md` always wins over its
`CLAUDE.md`, so a symlink between the two loads once.

Set `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1` to skip only `~/.claude/CLAUDE.md`, or `OPENCODE_DISABLE_CLAUDE_CODE=1` to
skip every `CLAUDE.md` and `.claude` skills. The server reads both when it starts. For the background service, persist
them with `opencode service set env` and run `opencode service restart`.
Set `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1` to skip every `CLAUDE.md`, or `OPENCODE_DISABLE_CLAUDE_CODE=1` to also skip
`.claude` skills. The server reads both when it starts. For the background service, persist them with
`opencode service set env` and run `opencode service restart`.

## Discovery

Expand Down
4 changes: 2 additions & 2 deletions services/site/src/docs/content/migrate-v1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ Existing `AGENTS.md` files stay in place. V2 discovers the global `~/.config/ope
files from the current directory up to home. For projects outside home, discovery stops at the project root.

V2 keeps the V1 `CLAUDE.md` fallback: a directory without `AGENTS.md` uses its `CLAUDE.md`, and `~/.claude/CLAUDE.md`
stands in for a missing global `AGENTS.md`. As before, `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` skips only
`~/.claude/CLAUDE.md` and `OPENCODE_DISABLE_CLAUDE_CODE` skips every `CLAUDE.md`. Unlike V1, which stopped at the
stands in for a missing global `AGENTS.md`. `OPENCODE_DISABLE_CLAUDE_CODE` skips every `CLAUDE.md`, and so does
`OPENCODE_DISABLE_CLAUDE_CODE_PROMPT`, which in V1 skipped only `~/.claude/CLAUDE.md`. Unlike V1, which stopped at the
first file name found anywhere up the tree, V2 picks per directory, so an `AGENTS.md` at the root no longer hides a
nested `CLAUDE.md`. See [Instructions](/instructions).

Expand Down
Loading