[BUG] Task list (TaskCreate/TodoWrite) state leaks across git worktrees

Resolved 💬 2 comments Opened Feb 10, 2026 by diegomrsantos Closed Mar 11, 2026

Bug Description

When running concurrent Claude Code sessions in different git worktrees of the same repository, the task list (TaskCreate/TaskUpdate/TodoWrite) is shared across all sessions. Tasks created in one worktree's session appear in other worktree sessions, causing confusion and interference.

Steps to Reproduce

  1. Create a git worktree:

``bash
git worktree add ../my-repo-feature feature-branch
``

  1. Open Claude Code in the main repo (my-repo/) — Session A
  2. Open Claude Code in the worktree (my-repo-feature/) — Session B
  3. In Session B, ask Claude to plan a multi-step task (triggering TaskCreate)
  4. Observe that Session A's task list now shows Session B's tasks

Expected Behavior

Each worktree session should have its own isolated task list, consistent with how worktrees provide isolated working directories. Since Claude Code explicitly supports parallel sessions via worktrees, shared mutable state between sessions is unexpected.

Actual Behavior

Task lists are scoped to the git repository (shared .git directory), not to the individual worktree. All concurrent sessions see and modify the same task list.

Workaround

Set a unique CLAUDE_CODE_TASK_LIST_ID per worktree to force separate storage:

CLAUDE_CODE_TASK_LIST_ID=my-feature claude

This shouldn't be necessary — worktree detection should scope task lists automatically.

Environment

  • macOS 15 (Darwin 25.1.0)
  • Claude Code (claude-code CLI)
  • Git worktrees via git worktree add

Related Issues

  • #17927 — Git worktree path resolution bug
  • #22396 — Worktree isolation for multi-terminal workflows (closed as duplicate)
  • #12748 — Add cwd parameter to Task tool for worktree support

View original on GitHub ↗

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