Duplicate skill registration in git worktrees
Description
When working inside a git worktree, Claude Code discovers and registers skills (.claude/commands/) from both the worktree directory and the main repository's working tree. This causes duplicate skill entries in the skill list.
Steps to Reproduce
- Have a git repo at
/path/to/main-repowith.claude/commands/todo.md - Create a worktree:
git worktree add /path/to/worktree some-branch - The worktree's branch also has
.claude/commands/todo.md(tracked in git) - Start Claude Code inside the worktree (
/path/to/worktree)
Expected Behavior
Only the worktree's .claude/commands/ should be loaded. The skill list should show one todo entry.
Actual Behavior
Claude Code follows the gitdir link in /path/to/worktree/.git (which points to /path/to/main-repo/.git/worktrees/<name>), resolves the main repo root, and loads .claude/commands/ from both locations. The skill list shows todo registered twice:
\\\`
- todo: Manage shared TODO ledger — add, list, solve, update, close, or show work items
- todo: Manage shared TODO ledger — add, list, solve, update, close, or show work items
\\\`
Root Cause
The skill/command discovery logic likely resolves the git common directory and walks up to the main repo's working tree to find .claude/. In a worktree setup, this pulls in commands from a completely separate working directory that may be on a different branch.
Environment
- Claude Code CLI
- Git worktree (standard
git worktree add) - Linux
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗