Duplicate slash commands in git worktrees

Resolved 💬 8 comments Opened Feb 19, 2026 by andyspacepants Closed Apr 8, 2026

Description

When running Claude Code inside a git worktree, every slash command in .claude/commands/ appears twice in the / menu. Both copies show as (project). This does not happen in the main repository — only in worktrees.

Reproduction steps

  1. Have a repo with .claude/commands/ containing slash commands
  2. Create a git worktree:

``bash
git worktree add ../my-worktree -b test-branch
``

  1. Open Claude Code in the worktree directory:

``bash
cd ../my-worktree
claude
``

  1. Type / to open the command menu
  2. Every command appears twice (e.g., /code-review listed twice, both marked (project))

No custom configuration or file copying is needed — a plain git worktree add is sufficient to reproduce.

Expected behavior

Each command should appear exactly once, same as in the main repository.

Actual behavior

Every command from .claude/commands/ is listed twice in the menu. Both entries are tagged (project).

Root cause hypothesis

In a git worktree, the .git entry is a file (not a directory) pointing back to the main repo:

gitdir: /path/to/main-repo/.git/worktrees/<name>

Claude Code likely discovers .claude/commands/ from both:

  1. The worktree's own .claude/commands/ (the current working directory)
  2. The main repository's .claude/commands/ (by following the .git file back to the main repo root)

Since both paths contain the same commands (same git repo), every command appears twice.

Environment

  • Claude Code version: 2.1.47
  • OS: macOS (Darwin 25.2.0)
  • Shell: zsh

Related issues

  • #3939 — Duplicate custom commands (fixed in v1.0.61, but not for worktrees)
  • #2316 — Commands duplicated from home directory (fixed in v1.0.61)
  • #10105 — Claude confuses worktree directories with main repository
  • #13019 — Tool permissions not recognized in git worktrees

View original on GitHub ↗

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