Duplicate skill registration in git worktrees

Resolved 💬 3 comments Opened Feb 20, 2026 by tesslerc Closed Feb 24, 2026

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

  1. Have a git repo at /path/to/main-repo with .claude/commands/todo.md
  2. Create a worktree: git worktree add /path/to/worktree some-branch
  3. The worktree's branch also has .claude/commands/todo.md (tracked in git)
  4. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗