Skip to content

Conversation

@SeanZoR
Copy link

@SeanZoR SeanZoR commented Jan 5, 2026

Summary

Adds support for Claude Code compatible command paths, enabling seamless migration for users coming from Claude Code.

  • .claude/commands/ (project-level)
  • ~/.claude/commands/ (global)

OpenCode native paths take precedence over Claude-compatible paths.

Fixes #6985

Changes

  • config.ts: Added getClaudeDirectories() helper and integrated Claude command loading before OpenCode directories
  • config.test.ts: Added 3 tests for Claude command discovery, precedence, and nested paths
  • commands.mdx: Updated docs to list Claude-compatible paths with precedence note

Add support for Claude Code compatible command paths:
- .claude/commands/ (project-level)
- ~/.claude/commands/ (global)

OpenCode native paths take precedence over Claude-compatible paths.

Fixes anomalyco#6985
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Duplicate PR Search Results

POTENTIAL RELATED PR FOUND:

OTHER POTENTIALLY RELEVANT PRs:

Recommendation: Verify PR #6963 carefully, as it may already address some of the command discovery issues this PR is fixing, or they may be working on different aspects of the same feature.

@SeanZoR
Copy link
Author

SeanZoR commented Jan 5, 2026

Thanks for flagging #6963! I checked it - there's significant overlap in the config.ts changes.

Key difference:

I believe OpenCode should take precedence (matching how skills work), allowing users to override Claude Code commands with OpenCode-specific versions.

Happy to coordinate with the author of #6963 or close this if they update their PR with the correct precedence order.

Comment on lines +96 to 102
// Load Claude-compatible commands first (lower precedence)
// OpenCode commands loaded later will override these
for (const dir of await getClaudeDirectories()) {
result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
}

for (const dir of unique(directories)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude commands aren't opencode compatible, if we are gonna read them then we need to translate them

These tests document the expected behavior for translating Claude Code's
allowed-tools field to OpenCode's permission system.

Related: anomalyco#6990 (comment)

Tests:
- translates claude allowed-tools to opencode command permissions (FAILS)
- translates claude allowed-tools with multiple tool types (FAILS)
- claude commands without allowed-tools have no permission field (PASSES)
@SeanZoR
Copy link
Author

SeanZoR commented Jan 6, 2026

TODOs for allowed-tools Translation

Thanks for the feedback @rekram1-node! You're right - Claude commands have an allowed-tools field that needs translation.

I've added failing tests (TDD style) that document the expected behavior:

  • translates claude allowed-tools to opencode command permissions
  • translates claude allowed-tools with multiple tool types
  • claude commands without allowed-tools have no permission field

Claude Code allowed-tools format (from their repo):

allowed-tools: Bash(git checkout:*), Bash(git add:*), Bash(git commit:*), TodoWrite

Proposed Translation:

Claude Code OpenCode
Bash(git checkout:*) permission.bash: ["git checkout *"]
Bash(gh issue list:*) permission.bash: ["gh issue list *"]
TodoWrite permission.todowrite: "allow"

Implementation TODOs:

  • Add permission field to Command schema
  • Parse Claude's allowed-tools syntax in loadCommand()
  • Translate Bash(pattern:*) to bash permission patterns
  • Translate simple tool names (e.g., TodoWrite) to "allow"
  • Emit warning for untranslatable patterns
  • Make the failing tests pass

Let me know if you'd like me to proceed with the implementation or if you'd prefer a different approach!

@kaichen
Copy link

kaichen commented Jan 6, 2026

Thanks for flagging #6963! I checked it - there's significant overlap in the config.ts changes.

Key difference:

I believe OpenCode should take precedence (matching how skills work), allowing users to override Claude Code commands with OpenCode-specific versions.

Happy to coordinate with the author of #6963 or close this if they update their PR with the correct precedence order.

I think PR #6963 should drop the Claude command-loading changes and just focus on fixing the CWD issue. Thanks for calling it out.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add .claude/commands/ compatibility (like .claude/skills/)

3 participants