[FEATURE] Allow custom branch name for isolation: worktree in Task tool
Problem Statement
When using isolation: "worktree" in the Task tool to spawn agents in isolated git worktrees, the branch name is automatically generated as worktree-agent-{hash} and cannot be configured. The worktree path is also not configurable.
This makes it difficult to:
- Identify which worktree belongs to which task (branch names are opaque hashes)
- Integrate with existing branch naming conventions (e.g.,
feature/issue-123) - Resume work on a specific worktree after session interruption
- Manage worktrees manually (e.g.,
git worktree listshows only hash-based names)
Additionally, background team members spawned with isolation: "worktree" still have their pwd set to the main repository, meaning the isolation doesn't actually take effect for them.
Proposed Solution
Add optional parameters to the Task tool's isolation: "worktree" mode:
worktree_branch: Custom branch name for the worktree (e.g.,"S1-13-qq-channel")worktree_path: Custom path for the worktree directory
Example:
{
"isolation": "worktree",
"worktree_branch": "feature/my-task",
"worktree_path": "../worktrees/my-task"
}
Also ensure that background team members correctly inherit the worktree working directory.
Priority
Medium
Feature Category
Task tool / Agent Teams / Git integration
Environment
- Claude Code version: 2.1.50
- OS: Windows 10 Pro (Build 19045)
- Terminal: Windows Terminal
- Platform: Anthropic API
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗