[FEATURE] Allow project context to follow working directory changes (git worktree workflow)

Resolved 💬 3 comments Opened Jan 2, 2026 by evolsb Closed Feb 17, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When using git worktrees with Claude Code CLI, the workflow is:

  1. Start Claude in main repo: cd ~/project && claude
  2. Create worktree mid-session: git worktree add ../project-feature -b feature/x
  3. Change to worktree: cd ../project-feature
  4. Continue working...

Current behavior: Claude's project context stays locked to the original directory (~/project). The status line shows project:main even though I'm working in a worktree on branch feature/x. File operations default to the original project root.

Expected behavior: When I cd to a different git repository or worktree, Claude should:

  • Update the project context to the new directory
  • Show the correct branch in the status line
  • Default file operations to the new working directory

Why this matters for git worktree workflows

Git worktrees are ideal for parallel feature work, but the current behavior forces me to:

  • Exit Claude and restart from the worktree directory (losing conversation context)
  • Or work with confusing status line showing wrong branch
  • Or use absolute paths everywhere

The conversation context from the original session is often directly relevant to the worktree work (e.g., "now implement what we just discussed in a feature branch").

Proposed Solution

Add a command or automatic detection:

Option A: Explicit command

/switch-project ../project-feature

Option B: Automatic detection
When CWD changes to a different git root, prompt:

"You've changed to a different git repository. Switch project context? [Y/n]"

Option C: Follow CWD setting

{
  "projectContext": "followCwd"  // vs "fixed" (current behavior)
}

Priority

Nice to have - Enhancement to existing functionality

Feature Category

CLI commands and flags

Additional Context

Related closed/locked issue: #1628

Current workaround: Exit Claude and run cd ../worktree && claude but this loses conversation context.

View original on GitHub ↗

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