/clear resets working directory when inside a worktree

Resolved 💬 2 comments Opened Apr 2, 2026 by sambaek-unlearn Closed May 11, 2026

Bug Description

Running /clear while inside a git worktree (created via EnterWorktree) resets the working directory back to the project root instead of preserving the current worktree path.

Expected Behavior

/clear should reset conversation context (message history, tasks, plans) but preserve the current working directory.

Actual Behavior

/clear resets both conversation context AND the working directory — moving from the worktree back to the main project root.

Steps to Reproduce

  1. Enter a worktree (e.g., via EnterWorktree or navigating to an existing one at .claude/worktrees/<id>)
  2. Confirm you're in the worktree directory on the feature branch
  3. Run /clear
  4. Observe the status line now shows the main project root and main branch instead of the worktree path and feature branch

Screenshots

Before /clear:

  • Working directory: ~/dev/atelier/.claude/worktrees/agent-<hash>
  • Branch: some-branch

After /clear:

  • Working directory: ~/dev/<repo>
  • Branch: main

Environment

  • macOS (Darwin 25.3.0)
  • Claude Code CLI

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗