[BUG] Skills/commands appear duplicated when using git worktrees
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
When running Claude Code inside a git worktree, skills defined in.claude/commands/ appear twice in the /skills list. Claude Code
loads commands from both the current worktree directory and the main
worktree directory, causing duplicates.
Expected Behavior
Each skill/command should appear once in the list.
Actual Behavior
Commands from .claude/commands/ appear twice — once loaded from
the main worktree's .claude/commands/ and once from the current
worktree's .claude/commands/.
Example duplicate entries in the system prompt:
- chlog: Update the docs/changelog.md file based on changes in the current branch.
- commit: Create a git commit for the current changes following project conventions.
- pr-review: Review the current branch changes based on the mpl2 Pull Request Checklist.
- rebase-main: Fetch the latest changes from origin and rebase the current branch from main.
- chlog: Update the docs/changelog.md file based on changes in the current branch.
- commit: Create a git commit for the current changes following project conventions.
- pr-review: Review the current branch changes based on the mpl2 Pull Request Checklist.
- rebase-main: Fetch the latest changes from origin and rebase the current branch from main.
Environment
- Claude Code CLI
- Windows 11, bash shell
- Git worktrees created via
git worktree add
Suggested fix
Deduplicate skills by name when loading from multiple .claude/
directories (e.g., prefer the current worktree's version, or
deduplicate by command name).
What Should Happen?
Each skill/command should appear once in the list.
Error Messages/Logs
Steps to Reproduce
- Have a git repository with
.claude/commands/containing command
files (e.g., commit.md, chlog.md)
- Create a git worktree:
git worktree add ../my-worktree feature-branch - Open Claude Code in the worktree directory
- Run
/skills
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.49
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗