Skip to content

v2: no CLAUDE.md fallback (compatibility issue, as migrate-v1 asks) #53402

Closed

Description

@nkoynov

Description

V1 used CLAUDE.md when a project had no AGENTS.md, and ~/.claude/CLAUDE.md when there was no ~/.config/opencode/AGENTS.md. V2 only looks for AGENTS.md (packages/core/src/config/plugin/instruction.ts). The migration guide says to file a compatibility issue for this, so here it is.

Our setup: we use Claude Code and OpenCode on the same repos, and the instructions are written for Claude Code: a global ~/.claude/CLAUDE.md and project CLAUDE.md files. Today a local plugin injects them into V2.

Ask: bring back the V1 fallback, with the V1 off switches (OPENCODE_DISABLE_CLAUDE_CODE, OPENCODE_DISABLE_CLAUDE_CODE_PROMPT, see #36990), or add it as an opt-in setting.

Plugins

none

OpenCode version

2.0.22. instruction.ts behaves the same in 2.0.23 and on v2 @ ef07075.

Steps to reproduce

  1. mkdir p && cd p && git init && echo 'The project codeword is TEAL-42.' > CLAUDE.md
  2. opencode run --standalone "What is the project codeword? Answer from your context only, no tools."
  3. V1 answers TEAL-42. V2 doesn't know it.
  4. The same happens with the codeword in ~/.claude/CLAUDE.md and no ~/.config/opencode/AGENTS.md.

Screenshot and/or share link

n/a

Operating System

NixOS 26.11 (Linux 6.18)

Terminal

n/a (also happens through opencode serve)

Activity

  1. github-actions commented on Oct 5, 2026

    @github-actions
    Contributor

    This issue might overlap with existing issues. Please check:

  2. opencodejr commented on Oct 27, 2026

    @opencodejr
    Contributor

    Thanks for the clear report. I could reproduce this on 2.0.22, and it still happens on the latest dev (f7d0ce1).

    What I did, with a simulated model:

    • A git project with only CLAUDE.md (The project codeword is TEAL-42.), no AGENTS.md.
    • A ~/.claude/CLAUDE.md with a second codeword, and no ~/.config/opencode/AGENTS.md.
    • One prompt from the TUI, then a check of the request sent to the model.

    Neither file's content was in that request. When I put the same text in a project AGENTS.md, it does show up, so only the CLAUDE.md fallback is missing. In the code, packages/core/src/config/plugin/instruction.ts only looks for AGENTS.md (the global file and the walk up the directory tree); nothing reads CLAUDE.md.

    The script below reproduces it. It logs whether each codeword reached the model; set CONTROL=1 to run the AGENTS.md comparison.

    Related: #36990 tracks V1 environment variable compatibility, including OPENCODE_DISABLE_CLAUDE_CODE and OPENCODE_DISABLE_CLAUDE_CODE_PROMPT. Bringing back the fallback would also give _PROMPT something to turn off again.

    Reproduction script (drive.ts)
    // Repro for #53402: V2 ignores CLAUDE.md (project) and ~/.claude/CLAUDE.md (global) fallbacks.
    // Neither AGENTS.md exists, so V1 would load both files into the system prompt.
    // Set CONTROL=1 to write the same text to AGENTS.md instead: V2 then does include it.
    import { Effect, Stream } from "effect"
    import { mkdirSync, writeFileSync } from "node:fs"
    import { join } from "node:path"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        project: { git: true, files: { [process.env.CONTROL ? "AGENTS.md" : "CLAUDE.md"]: "The project codeword is TEAL-42.\n" } },
        tui: { recording: true },
      },
      ({ artifacts, ui, llm }) =>
        Effect.gen(function* () {
          // OPENCODE_TEST_HOME is the artifacts dir: this is ~/.claude/CLAUDE.md for the run.
          mkdirSync(join(artifacts, ".claude"), { recursive: true })
          writeFileSync(join(artifacts, ".claude", "CLAUDE.md"), "The global codeword is NAVY-7.\n")
          const requests: string[] = []
          // Give the file watcher a moment to pick up the new global file.
          yield* Effect.sleep("2 seconds")
          yield* llm.serve((request: unknown) => {
            requests.push(JSON.stringify(request))
            return Stream.make(Llm.text("done"))
          })
          yield* ui.submit("What is the project codeword?")
          yield* ui.waitFor("done", { timeout: 60000 })
          const body = requests.join("\n")
          const hasProject = body.includes("TEAL-42")
          const hasGlobal = body.includes("NAVY-7")
          const hasAgentsMention = /AGENTS\.md|Instructions from/.test(body)
          yield* Effect.log(`requests=${requests.length} project codeword (TEAL-42) in model request=${hasProject} global codeword (NAVY-7, ~/.claude/CLAUDE.md) in model request=${hasGlobal}`)
          yield* Effect.log(`home=${artifacts} AGENTS/instructions mentioned=${hasAgentsMention}`)
          if (!hasProject || !hasGlobal) yield* Effect.log("REPRODUCED: CLAUDE.md fallback not applied")
        }),
    )

    Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.

  3. Lukk17 commented on Nov 17, 2026

    @Lukk17

    #63830 brings this back in a configurable way: with instruction_files set to ["AGENTS.md", "CLAUDE.md"], v2 reads CLAUDE.md again in the global config folder and in the upward walk. It is behind an experimental flag for now.
    Feedback or a thumbs up on the PR would help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions