Worktree rules loaded twice when worktree is inside .claude/worktrees/
Resolved 💬 1 comment Opened Feb 28, 2026 by KaizenTamashi Closed Feb 28, 2026
Description
When using claude -w <name> to create a worktree, it is placed inside .claude/worktrees/<name>/ — a subdirectory of the main repo. Claude Code's rule discovery walks up from CWD and finds both the worktree project root and the main repo project root, causing every rule file to be loaded twice into context.
Reproduction
claude -w myworktree(creates worktree at.claude/worktrees/myworktree/)- Observe the context — every file appears twice:
/path/to/repo/CLAUDE.md/path/to/repo/.claude/worktrees/myworktree/CLAUDE.md/path/to/repo/.claude/rules/*.md(each file)/path/to/repo/.claude/worktrees/myworktree/.claude/rules/*.md(each file duplicated)
Expected behavior
Rules, skills, CLAUDE.md, and AGENTS.md should be loaded once per project. The worktree is the same git repo (same git rev-parse --git-common-dir) — Claude Code should detect this and deduplicate.
Impact
- Every
.claude/rules/*.mdfile,CLAUDE.md,AGENTS.md, and.agents/skill docs are sent twice per message in worktree sessions - This consumes unnecessary context window space and increases input costs
- The duplication grows linearly with the number/size of rule files
Environment
- macOS (Darwin 24.6.0)
- Claude Code CLI (latest)
- Worktrees created via
claude -w
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗