Problem
When Arbor creates a git worktree and launches an agent preset (e.g. Claude Code) inside it, the agent may edit files in the main repository instead of the worktree. This happens because Claude Code does not always respect the CWD of linked git worktrees it didn't create itself (known upstream issue — multiple reports in anthropics/claude-code).
The user has no way to pass worktree-specific context to the agent command, since preset commands are static strings.
Proposed Solution
Support placeholders in agent preset commands that expand at runtime:
| Variable |
Expands to |
Example value |
{{cwd}} |
Active worktree path |
/Users/me/.arbor/worktrees/myrepo/feature-x |
{{worktree_name}} |
Worktree directory name |
feature-x |
{{repo_root}} |
Main repository root |
/Users/me/projects/myrepo |
{{branch}} |
Current branch name |
feature-x |
This would allow users to leverage Claude Code's native worktree support in their preset:
claude --worktree {{worktree_name}}
Or for other agents that accept a working directory flag, pass the path explicitly.
Variables would only expand when present in the command string — existing presets without placeholders remain unchanged.
Context
Claude Code has built-in --worktree <name> support that creates an isolated worktree with proper directory tracking. Letting Arbor pass the worktree name through a template variable would combine Arbor's worktree management UI with Claude Code's native worktree awareness.
Upstream references on worktree directory confusion:
Question for the maintainer
@penso — do you use Claude Code with Arbor-managed worktrees? If so, have you run into the same issue where Claude edits files in the main repo instead of the worktree?
Problem
When Arbor creates a git worktree and launches an agent preset (e.g. Claude Code) inside it, the agent may edit files in the main repository instead of the worktree. This happens because Claude Code does not always respect the CWD of linked git worktrees it didn't create itself (known upstream issue — multiple reports in anthropics/claude-code).
The user has no way to pass worktree-specific context to the agent command, since preset commands are static strings.
Proposed Solution
Support placeholders in agent preset commands that expand at runtime:
{{cwd}}/Users/me/.arbor/worktrees/myrepo/feature-x{{worktree_name}}feature-x{{repo_root}}/Users/me/projects/myrepo{{branch}}feature-xThis would allow users to leverage Claude Code's native worktree support in their preset:
Or for other agents that accept a working directory flag, pass the path explicitly.
Variables would only expand when present in the command string — existing presets without placeholders remain unchanged.
Context
Claude Code has built-in
--worktree <name>support that creates an isolated worktree with proper directory tracking. Letting Arbor pass the worktree name through a template variable would combine Arbor's worktree management UI with Claude Code's native worktree awareness.Upstream references on worktree directory confusion:
Question for the maintainer
@penso — do you use Claude Code with Arbor-managed worktrees? If so, have you run into the same issue where Claude edits files in the main repo instead of the worktree?