One flag, one repo
claude --worktree billing-currency gives a Claude Code session its own checkout. According to the Claude Code worktree docs, the flag creates .claude/worktrees/billing-currency/ at the root of the repository you are in, on a new branch named worktree-billing-currency, cut from the default branch. The session edits that checkout and leaves your main one alone.
That covers a change that stays inside one repository. Adding a currency to invoices does not: the API stores and returns it, the web app shows it, and the invoice type lives in a shared types package that both import. That makes three repositories, and each needs a worktree on the same branch. The single Claude Code session also has to see all three. --worktree creates one worktree in the current repo and has no option for the other two.
The short answer: create the worktrees yourself, or ask the agent for the change and let it run a tool for multi-repo worktrees for coding agents. This post shows both, with ivar 0.21.0 for the second. Why worktrees stop at the repository boundary in the first place is covered in Git worktrees are great. They stop at the repo boundary.
The manual way
Add a worktree in each repo, on one branch name:
$ git -C api worktree add -b billing-currency ../api-billing-currency
Preparing worktree (new branch 'billing-currency')
HEAD is now at 7dc02b3 init
$ git -C web worktree add -b billing-currency ../web-billing-currency
Preparing worktree (new branch 'billing-currency')
HEAD is now at b38caa4 init
$ git -C types worktree add -b billing-currency ../types-billing-currency
Preparing worktree (new branch 'billing-currency')
HEAD is now at f15f9de init
Then start Claude Code in one of them and hand it the others with --add-dir:
cd api-billing-currency
claude --add-dir ../web-billing-currency ../types-billing-currency
This works, and for a one-off it is enough. It gets harder in these places:
-
Everything is writable. If
typesshould only be read on this feature,--add-dirhas no read-only mode. The only thing that keeps the session out of it is a sentence in the prompt. -
Scope changes are manual. If you started with
typesonmainfor reading and it turns out to need the change, you cut the branch, add the worktree and hand the new path to the session yourself. -
Cleanup happens per repo. Each repo needs its own
git worktree removeandgit branch -Dwhen the feature lands or is dropped. A second run of the commands above fails while the first branch still exists:fatal: a branch named 'billing-currency' already exists. - Delivery is per repo. Three pushes and three pull requests, each opened by hand.
People have written tools around this. mwt creates multi-repo worktrees for concurrent Claude Code sessions and starts Claude with each repo passed through --add-dir. A feature request on the Claude Code tracker asked for a workspace mode that spans repositories.
The ivar way
With ivar you describe the change and the agent runs ivar. The only command you type is the install:
curl -fsSL 'https://ivar.run/install?ref=claude-code-git-worktree' | sh
ivar keeps the list of repositories in a hall, a git repo with an ivar.json manifest. The one-time hall setup for api, web and types is in the quickstart. After that, open Claude Code in the hall and ask for the change in your own words:
Add a currency to invoices. The api stores and returns it, the web app shows it.
That spans two repos, so I'll open one feature for it.
Created feature billing-currency (branch: billing-currency) in /tmp/demo/acme
Promoted api onto feature billing-currency (branch: billing-currency)
Promoted web onto feature billing-currency (branch: billing-currency)
Promoting a repo creates the billing-currency branch in it, off that repo's default branch, and a real git worktree for it. types stays on main, because nothing in the request said it changes. session connect attaches the running agent to a session for the feature, so the conversation goes on where it was.
The session works from a view dir: a directory of symlinks to real worktrees, plus a generated CLAUDE.md:
CLAUDE.md
api -> /tmp/demo/acme/.ivar/repos/api/billing-currency
state.json
types -> /tmp/demo/acme/.ivar/repos/types/main
web -> /tmp/demo/acme/.ivar/repos/web/billing-currency
api and web point at their feature worktrees. types points at its main checkout, which is guarded read-only. All three repos sit under one directory, so there is no --add-dir to pass.
When scope grows
Halfway through, the agent finds that the invoice type in types needs the new field. It promotes the repo itself and keeps going:
The invoice type lives in types, so it has to change too.
Promoted types onto feature billing-currency (branch: billing-currency)
The session's types symlink now points at the new worktree:
types -> /tmp/demo/acme/.ivar/repos/types/billing-currency
You did not open a terminal, type a path or restart the session.
One branch, every repo
Before delivering, the agent checks the feature and previews the delivery:
The status it reads back has one branch in every promoted repo:
Feature `billing-currency` (branch: billing-currency) in /tmp/demo/acme:
REPO STATE WORKTREE BASE PR
api ready present main
types ready present main
web ready present main
The preview lists one push and one pull request per promoted repo, and a fingerprint that the apply step must match. A feature without an approved plan is blocked here; the agent writes the plan with the ivar-plan skill, which stops for your approval after requirements, analysis and plan. Your part is to read the preview and answer:
ship it
The agent applies the delivery and names the pull requests it opened. The full delivery flow is in One feature, three repos: a walkthrough.
What you have now
You asked for one change and reviewed one preview. The agent created the branch in every repo that needed it, widened the scope when the work required it and opened the pull requests. The repos the feature changes are writable worktrees on the same branch, billing-currency; the repos it does not change are guarded on their default branch. Branches, worktrees, the plan and the session record stay on disk after the conversation ends, so the next conversation picks the feature up where this one stopped.
Limits
-
The kernel guard needs a session ivar launched, on Linux. On Linux 5.13 or later with Landlock, a harness that
ivar session startlaunches cannot write outside the session's writable set; a shell command getsEACCEStoo. An agent that was already running and attached itself withivar session connect, as above, has only the tool guard: a Claude Code hook that denies Edit and Write calls outside the writable set and tells the agent why. A shell command can still write. The same holds on macOS, where there is no kernel sandbox at all. The details are on ivar's limitations page. - No Windows. The view dir is built from symlinks, and WSL is untested.
-
One repo does not need this. When the change stays in a single repository,
claude --worktreeis enough. Useivaronce a feature needs more than one repo on the same branch.
Top comments (0)