[FEATURE] Worktree sessions should start in the subdirectory they were opened from (monorepos)
Problem
In a monorepo, I open a session on a subproject (<repo>/Pricing) and tick worktree in the Claude desktop app, which runs --worktree / EnterWorktree. The worktree is a checkout of the whole repo, created at <repo>/Pricing/.claude/worktrees/<name>. The session then starts at the worktree root instead of <worktree>/Pricing. Because of that:
- the subproject's
CLAUDE.md/AGENTS.mdand.claude/settings.jsonare not loaded; - the subproject's
.claude/skillsare not loaded at startup, since nested skills only load once Claude reads a file there. A first message such as/my-subproject-skill argsfails as an unknown command, even though that skill is listed when the session runs without a worktree.
Reproduced on Claude Code 2.1.286 (desktop Code tab and claude -p from the worktree root).
Proposal
When a worktree session is created from a subdirectory of the repo, start it in the same relative path inside the new worktree, i.e. an implicit post-create cd <worktree>/<relative cwd>. Alternatively, provide a setting or hook output that does it, e.g. worktree.preserveSubdirectory: true, or let WorktreeCreate / SessionStart hooks return the start directory.
Current workaround
A SessionStart hook tells Claude to cd into the subproject, read its AGENTS.md (which lazy-loads the nested skills), then re-run the unresolved slash command through the Skill tool. This works, but it relies on the model following the instruction.
Related
- #27901 —
claude --worktree should preserve subdirectory context in monorepos, closed as a duplicate of #11239, which is a different bug (the Plan agent uses the main checkout path) - #44460, #45143 — the desktop app has no support for working in a monorepo subfolder; both closed or stale