claude --worktree: .claude/ subdirectories (skills, agents, docs, rules) not copied to worktree
Status Open
Reported on v2.1.51
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 7 comments · opened Feb 24, 2026
Bug Description
When using claude --worktree, the generated worktree's .claude/ directory only contains settings.local.json. All other subdirectories (skills/, agents/, docs/, rules/) and settings.json are missing, causing skills and custom agents to be unavailable in the worktree session.
Steps to Reproduce
- Set up a project with
.claude/directory containing skills, agents, docs, and rules - Run
claude --worktree - Check the worktree's
.claude/directory
Expected Behavior
The worktree's .claude/ directory should contain (or symlink to) all subdirectories from the main repo's .claude/:
skills/agents/docs/rules/settings.jsonsettings.local.json
Actual Behavior
Only settings.local.json is present in the worktree's .claude/ directory:
Main repo .claude/:
.claude/
├── agents/
│ ├── code-worker.md
│ └── grafana-log-search.md
├── docs/
│ ├── coding-guidelines.md
│ └── go-patterns.md
├── rules/
│ ├── db-schema.md
│ └── sync-rag-voicealf.md
├── settings.json
├── settings.local.json
├── skills/
│ ├── cleanup-stale-/
│ ├── commit-push-pr/
│ ├── llm-test/
│ └── worktree/
└── worktrees/
Worktree .claude/:
.claude/
└── settings.local.json
Environment
- Claude Code version: 2.1.51
- OS: macOS (Darwin 25.2.0)
- Shell: zsh
Suggested Fix
Either copy or symlink the skills/, agents/, docs/, rules/, and settings.json from the source project's .claude/ directory when creating the worktree's .claude/ directory.
Showing cached comments. Read the full discussion on GitHub ↗
5 Comments
It's painful because when I use this option, claude keeps trying to edit from main branch rather than worktree.
We'd expect Claude to copy its own
.claude/subdirectories (skills, agents, settings, etc.) to worktrees out of the box — that seems like a bug rather than a feature request.Beyond that, a more general solution could be to support a
.worktreeincludefile (or similar) that specifies additional files and directories to copy to new worktrees. This would cover other common needs like local config files, IDE settings, and tooling dependencies.For example:
This pattern is already used by tools like git-worktree-runner (via
.gtrconfig) to handle the same problem. Supporting it natively in Claude Code would avoid needing aWorktreeCreatehook that replaces the entiregit worktree addflow just to copy a few files.I tried to find solution with claude, it seems we have hook for worktree create / remove. And it seems overriding existing worktree features at all. (But I couldn't find same info from official doc, so I'm not sure. but when I test it, it was working)
So, my setup is currently like this. I tried to even separate worktree directory from
.claudebecause I know we can remove the directory from IDE, and also can .gitignore the directory too, but it was a bit annoying to have worktree inside of.claudedirectory inside of my project.1. Hook setting
setup-worktree.sh3.
cleanup-worktree.shI think the behavior should be even more generic.
By default, when claude-code detects that is run from a worktree it should just fetch all the settings from the main repo, without creating any symlinks.
But one should be able to add custom setting to the current worktree which will override the setting of the super repo, like it is done with git config and worktrees
Basically, git worktree behavior should be applied to claude worktrees.
Btw, even claude-code itself considers it as a bug :)
UPD: I have also noticed that when I use symlink fo
.claudefrom a worktree, claude-code often still tries to search in a base repo even I have extra instruction in CLAUDE.md to always work within current git worktree if existsProduction impact report — .claude/rules/ not available in worktrees
We run Claude Code with EnterWorktree on every session (~8-10 hours/day, business operations).
.claude/rules/contains our project instructions — logging rules, communication rules, session procedures, etc. These files are critical: without them, Claude doesn't know how to use our database, draft emails, or follow our workflows.What happens: When a worktree is created,
.claude/rules/is either missing or contains stale copies. If we update rules in the canonical repo, no worktree picks up the changes. On 25 March we did a database schema migration that required rule file updates — every subsequent session loaded stale rules and couldn't work with the new schema until we manually copied files.Time wasted: ~30 minutes diagnosing, plus ongoing confusion in every new session.
Our workaround: We added
!.claude/rules/to.gitignoreso rules are git-tracked and propagate via worktree creation. This works for rules but doesn't help other.claude/contents (scripts, hooks, settings).Suggested fix: At worktree creation time, copy (or symlink)
.claude/rules/,.claude/settings.json, and.claude/scripts/from the main repo into the new worktree. These are project-level config, not session state — they should always be current. A simplecp -rof these specific subdirectories duringEnterWorktreewould solve it completely.