BUG: Directory paths containing "opencode" are displayed as "Claude" when using Anthropic models #7558

Open
opened 2026-02-16 18:07:35 -05:00 by yindo · 2 comments
Owner

Originally created by @deanbrittain on GitHub (Jan 25, 2026).

Originally assigned to: @rekram1-node on GitHub.

Image

Description
OpenCode performs a global string replacement of "opencode" → "Claude" in directory paths, but only when using Anthropic/Claude models. This appears to be part of the Claude Code compatibility/branding layer but incorrectly transforms user-controlled directory names.

Steps to Reproduce

  1. Create a directory containing "opencode" in the name:
    mkdir ~/Documents/opencode11223opencode
    cd ~/Documents/opencode11223opencode

  2. Start opencode with an Anthropic/Claude model:
    opencode

  3. Ask the AI: "What does my env info say?"

  4. Observe the working directory in the response


Expected Behavior
The working directory should display the actual directory name:
Working directory: /Users/username/Documents/opencode11223opencode

Actual Behavior
When using Anthropic/Claude models, the directory name is transformed:
Working directory: /Users/username/Documents/Claude11223Claude
The replacement appears to be:

  • Case-insensitive: opencode → Claude
  • Global: All instances are replaced
  • Model-specific: Only affects Anthropic models

Model Used Directory Name Displayed As Status
GPT-4.5 opencode11223opencode opencode11223opencode Correct
Claude Sonnet 4.5 opencode11223opencode Claude11223Claude Wrong
Screenshot
(Attach the screenshot showing Claude11223Claude)

Evidence
Test Results

Environment

  • OpenCode Version: 1.1.35
  • OS: macOS (darwin)
  • Shell: zsh
  • Installation Method: Homebrew

Investigation Findings
What I Tried

  1. Environment variables (no effect):
    export OPENCODE_DISABLE_CLAUDE_CODE=true
    export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=true
    export OPENCODE_DISABLE_CLAUDE_CODE_SKILLS=true

  2. Binary analysis - Found Anthropic-specific code:
    function header(providerID) {
    if (providerID.includes("anthropic"))
    return [anthropic_spoof_default.trim()];
    return [];
    }

  3. The Instance.directory value itself is correct (verified by checking with GPT models)
    Root Cause
    The replacement happens during Anthropic-specific system prompt construction, likely as part of the Claude Code compatibility layer. The exact replacement code could not be located in binary strings, suggesting it may be:

  • In compiled/minified code
  • Applied via a plugin hook
  • Part of a larger prompt transformation

Impact
Severity: Medium
User Impact:

  • Confuses users about their actual working directory
  • Could cause issues if users rely on the AI's understanding of the path
  • Breaks the principle that branding should not affect user data/paths
    Affected Users: Anyone using:
  • Anthropic/Claude models
  • Directory names containing "opencode"

Suggested Fix
The Claude Code branding compatibility should:

  1. Only affect UI/prompt text that describes the tool itself
  2. Never transform user-controlled data like directory paths, file names, or content
  3. Respect the OPENCODE_DISABLE_CLAUDE_CODE flag for all branding transformations
    Proposed solution:
  • Remove the global string replacement for Anthropic models
  • OR scope the replacement to only specific parts of the system prompt header
  • OR make it respect the existing disable flags

Workaround
Until fixed, users can:

  1. Avoid naming directories with "opencode" in the name
  2. Use non-Anthropic models (GPT, etc.) when working in such directories

Related Issues

  • #6551 - CLAUDE_CONFIG_DIR environment variable (related to Claude Code compatibility)

Additional Context
The transformation preserves case patterns:

  • opencode → Claude
  • OpenCode → Claude
  • OPENCODE → CLAUDE (assumed based on pattern)
    This suggests a regex-based replacement like /opencode/gi is being applied.
Originally created by @deanbrittain on GitHub (Jan 25, 2026). Originally assigned to: @rekram1-node on GitHub. <img width="1113" height="562" alt="Image" src="https://github.com/user-attachments/assets/4340a172-64e6-4ec0-a514-024bf9ca0857" /> Description OpenCode performs a global string replacement of "opencode" → "Claude" in directory paths, but only when using Anthropic/Claude models. This appears to be part of the Claude Code compatibility/branding layer but incorrectly transforms user-controlled directory names. --- Steps to Reproduce 1. Create a directory containing "opencode" in the name: mkdir ~/Documents/opencode11223opencode cd ~/Documents/opencode11223opencode 2. Start opencode with an Anthropic/Claude model: opencode 3. Ask the AI: "What does my env info say?" 4. Observe the working directory in the response --- Expected Behavior The working directory should display the actual directory name: Working directory: /Users/username/Documents/opencode11223opencode --- Actual Behavior When using Anthropic/Claude models, the directory name is transformed: Working directory: /Users/username/Documents/Claude11223Claude The replacement appears to be: - Case-insensitive: opencode → Claude - Global: All instances are replaced - Model-specific: Only affects Anthropic models --- Evidence Test Results | Model Used | Directory Name | Displayed As | Status | |-----------|----------------|--------------|---------| | GPT-4.5 | opencode11223opencode | opencode11223opencode | ✅ Correct | | Claude Sonnet 4.5 | opencode11223opencode | Claude11223Claude | ❌ Wrong | Screenshot (Attach the screenshot showing Claude11223Claude) --- Environment - OpenCode Version: 1.1.35 - OS: macOS (darwin) - Shell: zsh - Installation Method: Homebrew --- Investigation Findings What I Tried 1. Environment variables (no effect): export OPENCODE_DISABLE_CLAUDE_CODE=true export OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=true export OPENCODE_DISABLE_CLAUDE_CODE_SKILLS=true 2. Binary analysis - Found Anthropic-specific code: function header(providerID) { if (providerID.includes("anthropic")) return [anthropic_spoof_default.trim()]; return []; } 3. The Instance.directory value itself is correct (verified by checking with GPT models) Root Cause The replacement happens during Anthropic-specific system prompt construction, likely as part of the Claude Code compatibility layer. The exact replacement code could not be located in binary strings, suggesting it may be: - In compiled/minified code - Applied via a plugin hook - Part of a larger prompt transformation --- Impact Severity: Medium User Impact: - Confuses users about their actual working directory - Could cause issues if users rely on the AI's understanding of the path - Breaks the principle that branding should not affect user data/paths Affected Users: Anyone using: - Anthropic/Claude models - Directory names containing "opencode" --- Suggested Fix The Claude Code branding compatibility should: 1. Only affect UI/prompt text that describes the tool itself 2. Never transform user-controlled data like directory paths, file names, or content 3. Respect the OPENCODE_DISABLE_CLAUDE_CODE flag for all branding transformations Proposed solution: - Remove the global string replacement for Anthropic models - OR scope the replacement to only specific parts of the system prompt header - OR make it respect the existing disable flags --- Workaround Until fixed, users can: 1. Avoid naming directories with "opencode" in the name 2. Use non-Anthropic models (GPT, etc.) when working in such directories --- Related Issues - #6551 - CLAUDE_CONFIG_DIR environment variable (related to Claude Code compatibility) --- Additional Context The transformation preserves case patterns: - opencode → Claude - OpenCode → Claude - OPENCODE → CLAUDE (assumed based on pattern) This suggests a regex-based replacement like /opencode/gi is being applied.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

This issue appears to be unique - no exact duplicates found in the issue tracker. However, several related issues exist in the Claude Code compatibility area that may provide context:

  • #6551: opencode doesn't respect CLAUDE_CONFIG_DIR environment variable (also Claude/Anthropic path handling)
  • #8892: Anthropic models ignore Custom Instructions (related to Anthropic-specific prompt construction)
  • #10096: Smart Rules - Context-aware instruction injection with Claude Code compatibility
  • #8158: Support loading Claude Code plugins from .claude/ directory

These issues suggest a broader pattern of Anthropic/Claude-specific behavior differences in the system prompt construction layer.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue appears to be unique - no exact duplicates found in the issue tracker. However, several related issues exist in the Claude Code compatibility area that may provide context: - #6551: opencode doesn't respect CLAUDE_CONFIG_DIR environment variable (also Claude/Anthropic path handling) - #8892: Anthropic models ignore Custom Instructions (related to Anthropic-specific prompt construction) - #10096: Smart Rules - Context-aware instruction injection with Claude Code compatibility - #8158: Support loading Claude Code plugins from .claude/ directory These issues suggest a broader pattern of Anthropic/Claude-specific behavior differences in the system prompt construction layer.
Author
Owner

@NamedIdentity commented on GitHub (Feb 3, 2026):

I can confirm this issue. it has been persistent for many weeks.

In addition to causing failures of commands like directory searches or changes, or causing the agent to output documents into a "claude" folder instead of the projects directory, when performing git commits in folders with 'opencode' in the directory path, in test builds using XDG it causes a bun crash which requires restarting open code.

efforts to use AGENTS.md instructions to inform the agent of it's project directory, or that it has been improperly hallucinating directory paths containing opencode, and other system instructions meant to try to correct model behavior, have failed.

@NamedIdentity commented on GitHub (Feb 3, 2026): I can confirm this issue. it has been persistent for many weeks. In addition to causing failures of commands like directory searches or changes, or causing the agent to output documents into a "claude" folder instead of the projects directory, when performing git commits in folders with 'opencode' in the directory path, in test builds using XDG it causes a bun crash which requires restarting open code. efforts to use AGENTS.md instructions to inform the agent of it's project directory, or that it has been improperly hallucinating directory paths containing opencode, and other system instructions meant to try to correct model behavior, have failed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7558