[BUG] Skills/commands appear duplicated when using git worktrees

Status Fixed / completed
Reported on v2.1.49
Maintainer reply None cached
Activity 5 comments · opened Feb 20, 2026 · closed Aug 19, 2026

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

  1. Have a git repository with .claude/commands/ containing command

files (e.g., commit.md, chlog.md)

  1. Create a git worktree: git worktree add ../my-worktree feature-branch
  2. Open Claude Code in the worktree directory
  3. 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_

View original on GitHub ↗

4 Comments

dfaivre-pcs · 6 months ago
czj · 6 months ago

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 .claude containing skills & commands.

ledurnan · 6 months ago

I'm getting this, too.

  • in the skill/command autofill suggestions that populate below the input box when you type /
  • the command are also appearing multiple times in /help.
It does not seem to appear when using claude --worktree; only when we create a worktree ourselves with .claude containing skills & commands.

I'm creating worktrees myself. I haven't tested whether --worktree fixes 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.

breki · 6 months ago
I'm creating worktrees myself. I haven't tested whether --worktree fixes 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.

@ledurnan Yes, it appears multiple times for me, too. And I, too, have worktrees created manually, not using Claude Code's new --worktree feature. And the weird thing is, my worktrees are all siblings of the main (so not inside the main directory like Claude does it), so Claude has to somehow go and fetch the .claude directories of siblings to detect all these skills multiple times. Or there is an issue with how it caches things, I don't know.

Showing cached comments. Read the full discussion on GitHub ↗