Skip to content
jlopezPublic

About

Spawn parallel Claude Code agents in git worktrees, grouped in your cmux sidebar

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

grove 🌳

Spawn parallel Claude Code agents in git worktrees, grouped in your cmux sidebar.

grove is a thin glue layer over worktrunk (wt) + cmux + Claude Code. One command creates an isolated worktree and opens a cmux workspace running Claude on a prompt — filed under the repository's collapsible sidebar group, so a dozen parallel agents stay organized.

grove go fix/login-flow please fix the login redirect bug

→ creates the fix/login-flow worktree, opens a cmux tab running claude "please fix the login redirect bug", and files it under the repo's group (whose header is your main checkout).

Why

Running many AI agents in parallel means many worktrees. Existing tools either bury worktrees in a hidden directory (breaking per-directory env like multi-account gh) or give you no cockpit to see which agent is working vs. waiting. grove leans on three focused tools instead:

  • worktrunk owns worktree lifecycle (create, list, merge, remove) and agent-activity markers.
  • cmux is the sidebar cockpit — a two-level Repository → Worktrees tree, with a native per-tab "working / waiting" indicator and gh PR status.
  • Claude Code is the agent.

grove wires them together and gets out of the way.

Install

Homebrew

brew install jlopez/tap/grove   # (tap published with the first release)
grove init

curl

curl -fsSL https://raw.githubusercontent.com/jlopez/grove/main/install.sh | sh
grove init

This drops grove into ~/.local/bin. Then grove init wires the optional bits (see below).

Usage

grove go <branch> [prompt...]        Create a worktree + spawn a cmux Claude agent
grove rm [--force] [-D] [--keep-branch] [--reap] [--no-fetch] [--path <worktree>] [<branch>]
                                     Done with a feature: remove the worktree +
                                     close its cmux tab (defaults to the current worktree)
grove sync [list|check|add|rm]       Manage the untracked paths carried into worktrees
grove init [--with-multi-account]    Optional wiring (wt alias, cmux plugin, direnv)
grove doctor                         Check dependencies and wiring
grove version

Run grove go from inside a cmux tab — it spawns the new workspace into the same window.

grove init (optional)

grove go works on its own. init adds conveniences:

  • installs the cmux Claude Code plugin (activity markers for wt list),
  • adds a wt go alias so you can type wt go <branch> <prompt>,
  • with --with-multi-account, adds a worktrunk hook that gives each worktree the same gh account as your main checkout (see below).

Config

grove reads a small layered config, low → high precedence: ~/.config/grove/config.json (machine-wide) → <repo>/.grove.json (committed) → <repo>/.grove.local.json (gitignored, personal). Files deep-merge, last layer wins per key. This drives the per-repo group color/icon ({ "color"?, "icon"? } — color is #RRGGBB, "auto", or "inherit"; icon is an SF Symbol); grove restyle can write .grove.json for you. It also drives the agent grove launches ({ "agent": { "command"?, "args"? } } — command defaults to claude, args is an array of argv tokens passed before the prompt). grove init gitignores .grove.local.json.

Synced untracked paths (.env & friends)

Some files every worktree needs are exactly the ones git never carries. List them and grove copies them from the main checkout into each new worktree:

{ "sync": { "paths": [".env", ".env.local", ".claude/settings.local.json"] } }

An allow-list, not wt step copy-ignored's deny-list — nothing drags node_modules/ along. An existing file in the worktree is never overwritten (yours wins), and only gitignored paths are synced — a tracked path is already carried by git, and copying an untracked-but-not- ignored file would leave the worktree dirty and make wt remove refuse.

The other half is teardown. .env lives only on disk, so git can't preserve it and wt's dirty-tree check can't even see it — deleting the worktree would take an edited secret with it, silently. So grove rm diffs each synced path against the main checkout first and refuses if any differs, printing a colored diff:

grove: sync: .env differs from the main checkout (- main, + worktree):
@@ -1,3 +1,4 @@
 API_KEY=abc
-PORT=3000
+PORT=3001
+EXTRA=yes
grove: synced paths differ from the main checkout (above) — copy what you need,
       then re-run 'grove rm --force'

grove sync is the same machinery as a verb, for when the config changes after the agents are already running:

grove sync                    # fill the gaps in both directions; merge dotenv keys
grove sync check              # diff against the main checkout (exit 1 if any differ)
grove sync list               # each path's config + worktree state
grove sync add [--local] .env # edit .grove.json, so hand-editing the array is optional
grove sync rm  [--local] .env

Bare grove sync covers the case grove go can't: you add .env to the main checkout after spawning five agents, and the attach gate rightly refuses to re-run grove go for any of them. check exits 1 on divergence, so it composes into scripts and hooks. add refuses a tracked path outright and warns (but still writes) on one that isn't gitignored or exists in neither checkout — and it gap-fills the path it just added, so adding a .env that already exists here is one command.

sync fills gaps in both directions, because a path is often born on the branch that introduces it: missing here is copied from the main checkout, missing there is seeded from this worktree. Nothing is ever overwritten — only which side may be the source changed. When both sides have a .env and they differ, the keys are merged: whatever only one side has is appended verbatim to the other (each file keeps its own order, comments and quoting), and KEY=foo / KEY="foo" count as the same value. A key both sides define differently is a conflict — that path is left alone and grove sync exits 1 after processing the rest, reporting TOKEN: differs (main 41 chars, worktree 4 chars): the keys, never the values, so syncing on a shared screen can't spray your .env across it. grove sync check still shows the full diff when you ask for it. Files that aren't dotenv-shaped keep the old behaviour: they're reported, not touched.

Look at it, decide you don't care, grove rm -f. The check is stateless — it compares against the main checkout rather than a hash taken at copy time — so a rotated .env in main shows up as divergence too, which is what you want to see before deleting. grove doctor lists the configured paths and flags any that are absent from the main checkout, already tracked, or not gitignored.

Multi-account gh in worktrees

If you use direnv to switch gh accounts per directory (e.g. export GH_CONFIG_DIR=…), worktrees created outside those directories lose the account. grove init --with-multi-account installs a worktrunk pre-start hook that asks the main checkout's direnv what it resolves and writes a matching .envrc into each new worktree — no mapping tables, no drift. It's a no-op for repos that don't use direnv.

Requirements

Tool Required Install
worktrunk (wt) ✅ brew install worktrunk
cmux ✅ install cmux.app
jq ✅ brew install jq
Claude Code ✅ claude on PATH
direnv optional brew install direnv (multi-account)

grove doctor checks all of these.

How it works

grove go <branch> <prompt>:

  1. wt switch -c <branch> — creates the worktree (firing any worktrunk hooks).
  2. reads the new worktree path from wt list --format json.
  3. cmux workspace create --cwd <worktree> --command 'claude "<prompt>"'.
  4. files the workspace under the repo's group via cmux workspace-group add, creating the group (anchor = main checkout) on first use.

cmux is reachable because grove runs from a cmux tab and inherits CMUX_* env, so the new workspace lands in the right window.

grove rm <branch> is the inverse. It finds the worktree by the room's own record first — the path its tab was spawned with (GROVE_WORKTREE_PATH) — and only then by wt list, so a room that checked out another branch inside its worktree is still found. Such a room is removed by path, and both branches are settled: the checked-out branch is deleted when merged into the default branch (wt's rule), the room branch when merged or pushed to origin/<branch> (-D deletes both regardless, --keep-branch keeps both); a branch it keeps comes with the exact git branch -D to run. The worktree goes first and the tab last — and if no worktree is found, the tab is left open (exit 1) rather than closed over a worktree grove couldn't see. Point grove at the worktree directly with grove rm --path <worktree>.

Env

  • GROVE_COMMAND — command to launch instead of claude (overrides agent.command; handy for testing, e.g. GROVE_COMMAND=echo).
  • GROVE_CMUX — path to the cmux CLI (default: auto-detect).

License

MIT © Jesus Lopez

About

Spawn parallel Claude Code agents in git worktrees, grouped in your cmux sidebar

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages