Claude Code main session: a cd into a nested git worktree persists and becomes the primary working directory; use a subshell for one-off cds
Unlike subagents (where cwd resets between Bash calls), in the main Claude Code session a successful cd that ends inside the working directories carries over to the next call. That includes a git worktree nested under the repo (for example .claude/worktrees/<name>): after cd <repo>/.claude/worktrees/x && git log, the harness reported the primary working directory as the worktree and added worktree guidance ("run all commands from this directory, do not cd to the original repository root"). Later relative paths, check scripts and git commands then ran against the worktree instead of the main checkout. Fix: for one-off work elsewhere, wrap it in a subshell, ( cd <dir> && cmd ), or use git -C <dir> and absolute paths, so the session cwd never moves. If it already moved, one cd <original dir> puts it back (the harness then says the primary working directory is no longer a worktree).