A pool of git worktrees for agentic coding sessions
canopy manages a pool of git worktrees so agent sessions โ Claude Code, Codex, or anything else you point it at โ each get their own isolated checkout instead of colliding in one working tree.
A single locked state.json tracks who holds each worktree, whether that holder is still alive, and whether the worktree is clean. Claiming, releasing, pruning stale sessions, and destroying worktrees for good are all first-class commands โ and lifecycle hooks can wire claim/release straight into a session's start and stop, with no manual steps.
Reuses idle worktrees or grows a new one on demand, up to a configurable max โ no more manually juggling git worktree add for every parallel session.
A single flock-protected state.json tracks every claim, so concurrent sessions never race each other for the same worktree.
Every claim records its holder's PID. If that process dies without releasing, canopy knows โ and prune reclaims it automatically once it's clean.
Ships with Claude Code and Codex hook scripts (plus a one-command installer) that claim on session start and release on session stop โ no manual bookkeeping.
prune reclaims stale-and-clean worktrees back to the pool; destroy permanently removes one, gated behind explicit flags for unmerged branches or uncommitted changes.
canopy enter <path> drops a shell straight into any worktree for hands-on inspection, without touching its claim.
Two supported install paths: go install for anyone with a Go toolchain, or a curl-to-install script for everyone else. Linux and macOS, amd64 and arm64 โ no Windows.
go install github.com/nexus-lab-org/canopy/cmd/canopy@latest
Installs a canopy binary to $(go env GOPATH)/bin (typically ~/go/bin) โ make sure it's on your PATH.
curl -fsSL https://raw.githubusercontent.com/nexus-lab-org/canopy/main/install.sh | sh
Downloads the prebuilt binary matching your OS/architecture from the latest GitHub Release and installs it to /usr/local/bin (if writable) or ~/.local/bin.
canopy init inside a git repo, then canopy claim --holder my-session and canopy status.
canopy ships hook scripts that claim a worktree when an agent session starts and release it when the session stops, so you never run claim/release by hand. The easiest way to get this (and the rest of canopy) set up is to hand a coding agent the canopy skill instead of running the install/hook commands yourself โ it walks the agent through installing canopy, wiring the hooks, and driving init/status/prune/destroy on its own.
It's a standard Agent Skill, so it installs with the skills CLI like any other:
npx skills add nexus-lab-org/canopy --skill canopy
This copies the skill into whichever coding agents you have installed (Claude Code, Codex, Cursor, and 70+ others โ see npx skills add --help for the full list). After that, asking your agent to "set up canopy in this repo" or "install canopy" is enough for it to run the skill โ including wiring the hooks, which requires jq on PATH and edits your user-level hook config (~/.claude/settings.json, ~/.codex/hooks.json) via ./hooks/install.sh, never a project-level one, so opening an untrusted repo can never smuggle in its own hook commands.
Stop hook never fires, the claim isn't lost forever: canopy tracks the holder's PID, so canopy status reports it stale once that process dies, and canopy prune reclaims it automatically if the worktree is clean.
Prefer not to install anything first? See the blog post for a ready-to-paste prompt that points any repo-aware agent at this repo directly, or hooks/README.md for the manual hook-install path and full payload-field reference.
| Command | What it does |
|---|---|
canopy init |
Sets up the worktree pool for the current repo |
canopy claim --holder <id> |
Hands you an idle worktree, or grows a new one, up to --max |
canopy release --holder <id> |
Frees a worktree back to the pool (--force if the holder looks dead) |
canopy status |
Lists every worktree with its holder, live/stale, and clean/dirty state (--json available) |
canopy prune |
Reclaims stale-and-clean worktrees back to the idle pool |
canopy destroy <path> |
Permanently removes a worktree (--include-unlanded/--include-dirty to override safety checks, --all-idle for bulk) |
canopy enter <path> |
Drops a shell into a worktree for manual inspection, without touching its claim |
canopy claim --holder my-session โ work in the printed path โ canopy release --holder my-session
View the full license on GitHub.