Skip to content

bug: OPENCODE_DISABLE_CLAUDE_CODE 不应禁用 .agents/skills/ 技能加载 #25119

Closed

Description

@devcxl

Description

设置 OPENCODE_DISABLE_CLAUDE_CODE=1 环境变量后,.agents/skills/xxx/SKILL.md 文件无法被加载。

Root Cause

在 packages/core/src/flag/flag.ts 中,标志级联链路为:

OPENCODE_DISABLE_CLAUDE_CODE=1
  → OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = true   (line 22-23)
    → OPENCODE_DISABLE_EXTERNAL_SKILLS = true     (line 50)

在 packages/opencode/src/skill/index.ts:155 中:

if (!Flag.OPENCODE_DISABLE_EXTERNAL_SKILLS) {
  // 扫描 ~/.claude/skills/**/SKILL.md 和 ~/.agents/skills/**/SKILL.md
  // 扫描项目祖先目录中的 .claude/ 和 .agents/
}

OPENCODE_DISABLE_EXTERNAL_SKILLS 为 true 后,.claude/skills/ 和 .agents/skills/ 都被跳过了。

问题

.agents/ 目录是 opencode 自身的惯例(见 skill/index.ts:23: EXTERNAL_DIRS = [".claude", ".agents"]),不应受 OPENCODE_DISABLE_CLAUDE_CODE 影响。

  • .claude/ 是 Claude Code 的目录约定,禁用是合理的
  • .agents/ 是 opencode 自己的约定,将两者捆绑在一起会导致:用户只想禁用 Claude Code 兼容行为,却无意中连 opencode 自身的 .agents/ 技能也禁用了

Suggested Fix

将 EXTERNAL_DIRS 按来源拆分,让 .agents/ 的扫描不受 OPENCODE_DISABLE_CLAUDE_CODE 影响:

  1. .claude/skills/ — 受 OPENCODE_DISABLE_CLAUDE_CODE 控制(现状合理)
  2. .agents/skills/ — 应有独立 flag(如 OPENCODE_DISABLE_AGENTS_SKILLS)或不受此 flag 影响

Steps to Reproduce

  1. export OPENCODE_DISABLE_CLAUDE_CODE=1
  2. 在项目目录创建 .agents/skills/test-skill/SKILL.md(含合法 name、description frontmatter)
  3. 启动 opencode
  4. 检查 available skills — 该技能不会出现

Operating System

Linux

Activity

  1. github-actions commented on Apr 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 30, 2026
  3. devcxl commented on Apr 30, 2026

    @devcxl
    Author

    English translation of the issue:

    Setting OPENCODE_DISABLE_CLAUDE_CODE=1 prevents .agents/skills/xxx/SKILL.md files from being loaded.

    Root Cause

    In packages/core/src/flag/flag.ts, the flag cascade chain is:

    OPENCODE_DISABLE_CLAUDE_CODE=1
      → OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = true   (line 22-23)
        → OPENCODE_DISABLE_EXTERNAL_SKILLS = true     (line 50)
    

    In packages/opencode/src/skill/index.ts:155:

    if (!Flag.OPENCODE_DISABLE_EXTERNAL_SKILLS) {
      // scans ~/.claude/skills/**/SKILL.md and ~/.agents/skills/**/SKILL.md
      // scans ancestor directories for .claude/ and .agents/
    }

    When OPENCODE_DISABLE_EXTERNAL_SKILLS is true, both .claude/skills/ and .agents/skills/ are skipped entirely.

    The Problem

    .agents/ is opencode's own convention (see skill/index.ts:23: EXTERNAL_DIRS = [".claude", ".agents"]) and should NOT be affected by OPENCODE_DISABLE_CLAUDE_CODE.

    • .claude/ is a Claude Code directory convention — disabling it makes sense
    • .agents/ is opencode's own convention — tying them together means users who only want to disable Claude Code compatibility inadvertently lose opencode's own .agents/ skills

    Suggested Fix

    Separate the EXTERNAL_DIRS handling so that .agents/ scanning is not affected by OPENCODE_DISABLE_CLAUDE_CODE:

    1. .claude/skills/ — controlled by OPENCODE_DISABLE_CLAUDE_CODE (current behavior is fine)
    2. .agents/skills/ — should have its own independent flag (e.g. OPENCODE_DISABLE_AGENTS_SKILLS) or not be affected by this flag at all

    Steps to Reproduce

    1. export OPENCODE_DISABLE_CLAUDE_CODE=1
    2. Create .agents/skills/test-skill/SKILL.md in a project directory (with valid name and description frontmatter)
    3. Launch opencode
    4. Check available skills — the skill will not appear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions