[BUG] isolation: "worktree" does not create git worktrees for plugin-defined agent types
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
When spawning agents via the Agent tool with isolation: "worktree" and a plugin-defined subagent_type (e.g., "my-plugin:Software-Engineer"), no git worktrees are created. The parameter is accepted without error, but agents all share the main working directory.
Expected: Each agent gets its own worktree in .claude/worktrees/ with a separate branch, as documented in the Agent tool description.
Actual: git worktree list shows only the main worktree. All agents operate in the same directory and overwrite each other's branches.
## Evidence
PreToolUse hook logging confirms the parameter is present on the Agent tool call:
SUBAGENT_TYPE=my-plugin:Software-Engineer
TEAM_NAME=my-sprint
HAS_ISOLATION=yes ← parameter IS set
PostToolUse hook logging confirms no worktrees were created:
WORKTREE_COUNT=1 ← only main worktree exists
LIST=/path/to/project abc1234 [main]
Additionally, PostToolUse:Agent hook error is shown in the UI after every Agent spawn with plugin types, even when the PostToolUse hook script produces valid JSON output (247 bytes, verified via debug logging).
## Environment
- Claude Code CLI (latest)
- macOS (also expected on Linux/Windows)
- Plugin installed via git marketplace (
extraKnownMarketplacesin settings.json)
## Workaround
Manually create worktrees before spawning agents:
```bash
git worktree add .claude/worktrees/feature-a -b feature-a-branch
git worktree add .claude/worktrees/feature-b -b feature-b-branch
Then instruct agents to work in their assigned worktree directory.
Additional Notes
- The same PostToolUse:Agent hook error appears even for hooks that produce valid JSON with additionalContext — suggesting PostToolUse hooks may not be fully supported for the Agent tool.
- Built-in subagent_type values (e.g., "general-purpose", "Explore") were not tested with isolation: "worktree" in this scenario — the issue may be specific to plugin-defined types.
What Should Happen?
Each agent gets its own worktree in .claude/worktrees/ with a separate branch, as documented in the Agent tool description.
Error Messages/Logs
Steps to Reproduce
- Install a Claude Code plugin that defines custom agent types (via
plugin.jsonagentsfield) - Create a team with
TeamCreate - Spawn multiple agents using the plugin agent type with
isolation: "worktree":
Agent(
subagent_type: "my-plugin:Software-Engineer",
team_name: "my-team",
isolation: "worktree",
prompt: "..."
)
- Run
git worktree list— only the main worktree appears - All spawned agents share the same working directory
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.81 (Claude Code)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗