OAuth token expiry triggered by worktree cleanup failure
Related: #33811
Reproduction: OAuth token expiry triggered by worktree cleanup failure
I'm hitting repeated logouts mid-session. The pattern I've identified:
- A background agent completes work in a worktree and a PR is merged
- Claude attempts to delete the branch, but fails because it's still referenced by the worktree:
````
failed to delete local branch 'fix/352-clean-polluted-test-user' used by worktree at
'/Users/.../auth-service/.claude/worktrees/agent-a07e6fe9'
- Worktree removal then fails with:
````
fatal: Unable to read current working directory: No such file or directory
- Immediately after the cleanup errors, the session drops to
Not logged in - Please run /login
After running /login successfully, the issue sometimes recurs within minutes — the session enters a login loop where every action triggers another Not logged in prompt, forcing me to exit the session entirely and lose context.
Environment: macOS (Darwin 25.3.0), Claude Code CLI, using worktree-based agents
Impact: Loss of full conversation context each time the session must be restarted.
It appears the worktree cleanup cascade (shell working directory deleted out from under the process) is corrupting session state and causing the OAuth token refresh to fail.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗