[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_
Showing cached comments. Read the full discussion on GitHub ↗
4 Comments
fwiw I have a repro archive here: https://github.com/anthropics/claude-code/issues/28182#issuecomment-3951356856
Confirmed bug, appeared recently. @bobmaerten and I suffer from it.
It does not seem to appear when using
claude --worktree; only when we create a worktree ourselves with.claudecontaining skills & commands.I'm getting this, too.
//help.I'm creating worktrees myself. I haven't tested whether
--worktreefixes but that's consistent.One interesting quirk seems to be the number of times that the command appears - not necessarily twice as @breki suggests.
Take a project where I'm using GitHub's spec kit, for example. One might assume that the failure mode is for the command to be loaded twice: once from the main copy of the repo and once from the worktree - but I'm getting it multiple times.
E.g. I type a slash right now, and I can see one spec kit command appearing duplicated six times.
@ledurnan Yes, it appears multiple times for me, too. And I, too, have worktrees created manually, not using Claude Code's new
--worktreefeature. And the weird thing is, my worktrees are all siblings of themain(so not inside themaindirectory like Claude does it), so Claude has to somehow go and fetch the.claudedirectories of siblings to detect all these skills multiple times. Or there is an issue with how it caches things, I don't know.