/clear resets working directory, losing worktree context
Resolved 💬 3 comments Opened Mar 7, 2026 by llamallamaredpajama Closed Mar 11, 2026
Problem
When working inside a git worktree (or any directory navigated to during a session), running /clear resets the working directory back to the original launch directory instead of preserving the current working directory.
This is particularly dangerous with git worktrees because:
- You think you're still in the worktree on a feature branch
- You're actually back in the main project directory on
main - Any file edits or git operations now affect
maininstead of the worktree branch
Steps to Reproduce
- Launch
claudefrom a project root (e.g.,~/dev/my-project/) - Create or enter a worktree:
cd .claude/worktrees/my-feature/ - Do some work on the worktree branch
- Run
/clearto free up context - Check
pwdandgit branch— you're back in the original project root onmain
Expected Behavior
/clear should preserve the current working directory so that:
pwdremains the same after clear- Git branch context is maintained
- File operations continue targeting the correct directory
Actual Behavior
/clear resets the session to the directory where claude was originally invoked, silently changing the git branch and file context.
Impact
- Silent data hazard: edits and commits land on
maininstead of the feature branch - Worktree workflow broken: worktrees are designed for isolated work, but
/clearbreaks that isolation - Forces users to either avoid
/clearentirely or remember tocdback every time
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗