feat: Add compatibility for .claude/commands/ directory (Claude Code migration support) #8606

Closed
opened 2026-02-16 18:10:22 -05:00 by yindo · 2 comments
Owner

Originally created by @taetaetae on GitHub (Feb 5, 2026).

Originally assigned to: @thdxr on GitHub.

Summary

Add support for loading custom commands from .claude/commands/ directory in addition to the existing .opencode/commands/ directory. This would make it easier for users migrating from Claude Code to OpenCode.

Environment

  • OpenCode Version: v1.1.51
  • Platform: Desktop App (macOS) - not CLI
  • Currently, custom commands in .claude/commands/ are not visible in the Desktop app command palette.

Motivation

Many developers have existing workflows and custom commands defined in .claude/commands/ for Claude Code. Currently, when switching to OpenCode, users must manually migrate their commands to .opencode/commands/.

Adding compatibility for .claude/commands/ would:

  1. Lower the barrier to adoption - Users can try OpenCode without restructuring their projects
  2. Enable gradual migration - Teams can use both tools during transition periods
  3. Reduce friction - Existing .claude/commands/*.md files work out of the box

Proposed Solution

Modify the command loading logic in packages/opencode/src/config/config.ts to also scan .claude/commands/ directories:

  1. Add .claude to scanned directories (around line 120-140)
  2. Update COMMAND_GLOB pattern (line 345) to include .claude/commands/
  3. Add path pattern (line 365) for /.claude/commands/

Code Changes (Draft)

// Line 345: Update glob pattern
const COMMAND_GLOB = new Bun.Glob("{command,commands}/**/*.md")
// Could remain the same if we add .claude to scanned directories

// Line 365: Add .claude pattern
const patterns = [
  "/.opencode/command/", 
  "/.opencode/commands/", 
  "/.claude/commands/",  // NEW
  "/command/", 
  "/commands/"
]

// Line 120-140: Add .claude to directory scan
const directories = [
  Global.Path.config,
  ...Filesystem.up({ targets: [".opencode", ".claude"], ... }),  // Add .claude
  ...
]

File Format Compatibility

Both OpenCode and Claude Code use the same format:

  • YAML frontmatter with description, name, argument-hint
  • Markdown body as template
  • Variable substitution: $ARGUMENTS, $1, $2, etc.

Priority / Precedence

When the same command exists in both directories:

  • .opencode/commands/ should take precedence over .claude/commands/
  • This allows users to override Claude Code commands with OpenCode-specific versions

Additional Context

Checklist

  • Add .claude directory scanning
  • Update path patterns for command loading
  • Add tests for .claude/commands/ loading
  • Update documentation

I'm happy to submit a PR for this feature if the approach is approved.

Originally created by @taetaetae on GitHub (Feb 5, 2026). Originally assigned to: @thdxr on GitHub. ## Summary Add support for loading custom commands from `.claude/commands/` directory in addition to the existing `.opencode/commands/` directory. This would make it easier for users migrating from Claude Code to OpenCode. ## Environment - **OpenCode Version**: v1.1.51 - **Platform**: **Desktop App (macOS)** - not CLI - Currently, custom commands in `.claude/commands/` are not visible in the Desktop app command palette. ## Motivation Many developers have existing workflows and custom commands defined in `.claude/commands/` for Claude Code. Currently, when switching to OpenCode, users must manually migrate their commands to `.opencode/commands/`. Adding compatibility for `.claude/commands/` would: 1. **Lower the barrier to adoption** - Users can try OpenCode without restructuring their projects 2. **Enable gradual migration** - Teams can use both tools during transition periods 3. **Reduce friction** - Existing `.claude/commands/*.md` files work out of the box ## Proposed Solution Modify the command loading logic in `packages/opencode/src/config/config.ts` to also scan `.claude/commands/` directories: 1. **Add `.claude` to scanned directories** (around line 120-140) 2. **Update `COMMAND_GLOB` pattern** (line 345) to include `.claude/commands/` 3. **Add path pattern** (line 365) for `/.claude/commands/` ### Code Changes (Draft) ```typescript // Line 345: Update glob pattern const COMMAND_GLOB = new Bun.Glob("{command,commands}/**/*.md") // Could remain the same if we add .claude to scanned directories // Line 365: Add .claude pattern const patterns = [ "/.opencode/command/", "/.opencode/commands/", "/.claude/commands/", // NEW "/command/", "/commands/" ] // Line 120-140: Add .claude to directory scan const directories = [ Global.Path.config, ...Filesystem.up({ targets: [".opencode", ".claude"], ... }), // Add .claude ... ] ``` ## File Format Compatibility Both OpenCode and Claude Code use the same format: - YAML frontmatter with `description`, `name`, `argument-hint` - Markdown body as template - Variable substitution: `$ARGUMENTS`, `$1`, `$2`, etc. ## Priority / Precedence When the same command exists in both directories: - `.opencode/commands/` should take precedence over `.claude/commands/` - This allows users to override Claude Code commands with OpenCode-specific versions ## Additional Context - Claude Code commands spec: https://docs.anthropic.com/en/docs/claude-code/skills - OpenCode already supports similar frontmatter fields - This is a non-breaking change - existing `.opencode/commands/` behavior remains unchanged ## Checklist - [ ] Add `.claude` directory scanning - [ ] Update path patterns for command loading - [ ] Add tests for `.claude/commands/` loading - [ ] Update documentation --- I'm happy to submit a PR for this feature if the approach is approved.
yindo closed this issue 2026-02-16 18:10:22 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 5, 2026):

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

  • #6985: [FEATURE]: Add .claude/commands/ compatibility (like .claude/skills/) - This requests the exact same feature to support loading commands from .claude/commands/ directory for Claude Code migration

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 5, 2026): This issue might be a duplicate of existing issues. Please check: - #6985: [FEATURE]: Add .claude/commands/ compatibility (like .claude/skills/) - This requests the exact same feature to support loading commands from `.claude/commands/` directory for Claude Code migration Feel free to ignore if none of these address your specific case.
Author
Owner

@taetaetae commented on GitHub (Feb 5, 2026):

Closing as duplicate of #6985. I'll follow up there. Thanks for the bot catching this!

@taetaetae commented on GitHub (Feb 5, 2026): Closing as duplicate of #6985. I'll follow up there. Thanks for the bot catching this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8606