Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Worktree AI MasterNew to Visual Studio Code? Get it now.
Git Worktree AI Master

Git Worktree AI Master

Aashish Prasad

| (0) | Free
Git worktrees for AI agent workflows: see which agent (Claude Code, Codex, Copilot…) is working or waiting in each worktree, catch conflicts between parallel agents early, review their changes, and clean up without losing work.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Worktree AI Master

Git worktrees for AI agent workflows. Run Claude Code, Codex, Copilot, Aider, Gemini CLI or Cursor agents in parallel, each in its own worktree, and keep track of all of them from one VS Code sidebar.

Card view: one card per worktree with agent status, changes, PR checks and conflict warnings

Built for parallel AI agents

Worktrees let several agents work on the same repo without touching each other's files. Using them that way brings new problems, and this extension is built around them:

Problem What Git Worktree AI Master does
"Which agent is still working, and which one is waiting for me?" Detects agent processes in each worktree and shows working (files changing) or idle. Notifies you when an agent goes idle; the view badge counts idle agents.
"Two agents edited the same file and I only found out at merge time." Conflict radar: files that several worktrees are changing, plus conflicts with main predicted by git merge-tree, before anything is merged.
"Which attempt is best?" Compare two worktrees in one multi-file diff, or Review All Changes a branch would contribute.
"I deleted a worktree and lost the agent's uncommitted work / my .env." Removal snapshots uncommitted work, at-risk ignored files and unmerged branch tips first. Restore them any time.
"Agents fight over port 3000 / the same database." Optional per-worktree env file with unique ports and COMPOSE_PROJECT_NAME.
"Setting up each worktree is tedious." Copies .env and .worktreeinclude files, symlinks node_modules, runs a setup command, then Start Agent launches your agent with the task as its prompt.
"15 forgotten worktrees are eating my disk." Disk usage, stale markers, and a cleanup that uses PR merged state and never touches busy or dirty worktrees.
"What was this worktree for?" Notes (the agent's task) and coloured labels, shared across windows.

List or cards

The Worktrees view comes in two layouts. Switch with the button in the view's title bar, or the worktreeMaster.viewStyle setting.

  • List (default): a compact tree like the Explorer. Expand a worktree to see its files, commits, PR and conflicts.

  • Cards: one colour-coded card per worktree, with:

    • a coloured stripe: your label's colour, otherwise red for predicted conflicts, blue for an agent working, yellow for an agent idle, orange for uncommitted changes, purple for a merged PR, green for clean
    • an icon showing its state (spinning while an agent works)
    • status chips, the note, conflict warnings and an expandable list of changed files
    • one-click buttons: open, terminal, start agent, review, compare, label, note, remove
    • right-click or ⋯ for every other action

    A filter box searches by branch, label, note or agent. Cards lay out in a grid when the sidebar or panel is wide.

The Worktrees view

In the list layout, each worktree row shows its branch plus a compact summary:

Badge Meaning
[review] + icon colour Your label for the worktree.
claude working / claude idle An agent process is running in this worktree. Its icon spins while files are changing. Idle means nothing has changed recently, so the agent is either done or waiting for input. The view badge counts idle agents.
this window / open in another window Which VS Code windows have it open.
✎3 Uncommitted files.
+5 Commits not in the base branch.
↑1 ↓2 Ahead/behind its upstream.
#123 ✓ / #123 ✗ / #123 merged GitHub PR state, checks and review (via gh).
⚠ conflicts with origin/main git merge-tree predicts conflicts when merging the base branch.
⚠ overlaps feature-y Another worktree modifies the same files, committed or not.
stale 21d ago No activity for longer than staleAfterDays.
1.2 GB Disk usage, after you run Show Disk Usage.

Expand a worktree to see:

  • Note: what the worktree is for. Click to edit.
  • Agent: its pid and the time of its last change.
  • Pull request: click to open it.
  • Conflict Radar: files that will conflict with the base branch, and the other worktrees that touch the same files. Click a file to diff it against the base branch or between the two worktrees.
  • Staged / Changes / Untracked / Merge Conflicts: click a file for its diff.
  • Commits not in origin/main: unpushed commits have a cloud-upload icon. Expand a commit to diff its files.

Actions

Create Worktree (+ button): from a new branch, a local branch, a remote branch, a GitHub PR number or a tag/commit. It asks what is this worktree for? and saves the answer as the note. Then it sets up the worktree:

  • copies copyFiles and anything matched by .worktreeinclude (Claude Code's convention, gitignore syntax)
  • symlinks symlinkFiles
  • writes a per-worktree env file with unique ports (see below)
  • runs postCreateCommand
  • opens the worktree or starts an agent in it

Start Agent: opens a terminal in the worktree and runs agents.command (default claude), passing the note as the prompt. It warns you if an agent is already running there.

Review All Changes: opens one multi-file diff of everything the worktree would contribute, i.e. commits since it branched from the base branch plus uncommitted work.

Compare With…: multi-file diff of this worktree against another worktree (both working trees, uncommitted changes included), the base branch, HEAD, or any ref. Useful when you've had several agents attempt the same task and want to pick the best one.

Labels & notes: shared across all VS Code windows on this machine.

Remove Worktree: before removing, it warns if an agent is running, if the worktree is open somewhere, about unpushed or unmerged commits, and about PR state. Nothing is lost silently:

  • Uncommitted work is saved as a snapshot first. So are small ignored files that git worktree remove would otherwise delete silently (an edited .env, notes.md, a scratch DB). Rebuildable folders (node_modules, .venv, dist, …) are skipped.
  • If you also delete the branch and it isn't merged, its tip is snapshotted before the force-delete.
  • Snapshots (at the bottom of the tree) can be viewed as a diff, restored as a new worktree (uncommitted work comes back as uncommitted changes), or deleted. They are local refs under refs/worktree-snapshots/, so git push doesn't send them.

Clean Up Merged & Stale Worktrees: fetches, then lists removable worktrees:

  • preselected: PR merged, no commits outside the base branch, or remote branch deleted (typical after a squash-merge)
  • listed but not preselected: PR closed without merging, or stale

It never lists worktrees that have uncommitted changes, are open in a window, have an agent running, or are locked.

Show Disk Usage: measures every worktree and offers cleanup.

Orphaned Folders: a worktree folder can lose its link to git when its record in .git/worktrees is deleted or pruned, or when its .git file gets emptied. Git then ignores the folder completely: its changes are invisible, and any repo that contains it reports thousands of untracked files. The extension finds such folders next to the repo (and in .claude/worktrees, .worktrees, or open in the window) and lists them under Orphaned Folders. Re-attach reconnects one without touching its files:

  • If the record survived, it restores the link (git worktree repair).
  • Otherwise it creates a new record on a branch you pick. Branches whose names match the folder are suggested first. git status then shows how the folder differs from that branch.

Exclude Nested Worktrees: worktrees inside the repo (e.g. .claude/worktrees/*) cause duplicate search results and slow file watching. The extension offers once to add them to files.exclude, search.exclude and files.watcherExclude.

Also: switch worktrees from the status bar, open in a new window or this one, add to workspace, open terminal, pull/push in a terminal, create/open PR, lock/unlock, move, prune, copy path/branch.

Running agents in parallel without collisions

Worktrees isolate files, but not ports, containers or databases. Set worktreeMaster.env.file (e.g. .env.worktree) and each new worktree gets a stable slot number:

WORKTREE_NAME=feature-x
WORKTREE_SLOT=2
WORKTREE_PORT_OFFSET=20
COMPOSE_PROJECT_NAME=myrepo-feature-x
PORT=3020          # from worktreeMaster.env.ports: { "PORT": 3000, "DB_PORT": 5432 }
DB_PORT=5452

Load it from your dev scripts or docker compose --env-file .env.worktree. The file is added to .git/info/exclude so agents won't commit it. Write Env File (right-click a worktree) regenerates it for existing worktrees.

How detection works

  • Agents: every agents.pollSeconds it lists processes whose executable (or script, for node/python launchers) matches agents.processNames, and maps each process's working directory to a worktree. Linux, WSL and macOS only.
  • Other windows: each window writes a small heartbeat file to the extension's global storage.
  • Working vs idle: based on the newest modification time across the worktree's changed files, its index and its HEAD reflog.
  • Refresh: it watches the shared .git directory for commits, checkouts, staging and branch changes in any worktree, refreshes on focus and save, and polls every autoRefreshInterval seconds while the view is visible.

Settings

Setting Default
pathTemplate ${repoParent}/${repoName}.${branch} Where new worktrees go, e.g. ${repoRoot}/.worktrees/${branch}.
baseBranch auto What "unmerged" means. Auto-detects origin/HEAD, then origin/main, origin/master, main, master, develop.
copyFiles / symlinkFiles [] Untracked files to copy or link into new worktrees.
postCreateCommand "" e.g. npm install.
openAfterCreate ask ask, newWindow, currentWindow, addToWorkspace, startAgent, none.
env.file, env.ports, env.portStep off, {PORT: 3000}, 10 Per-worktree env file.
agents.command claude Used by Start Agent; ${prompt} placeholder supported.
agents.detect, agents.processNames, agents.pollSeconds, agents.activeSeconds, agents.notifyWhenIdle on, common agents, 10, 90, on Agent detection.
github.enabled, github.ghPath on, gh PR status.
snapshotBeforeRemove on Safety net on removal.
regenerablePaths node_modules, .venv, … Ignored paths that are fine to lose.
staleAfterDays 14
sortBy name or activity.
viewStyle list list or cards.
autoRefreshInterval 30 Seconds; 0 disables polling.

All settings are under worktreeMaster..

Install

From the VS Code Marketplace: search for Git Worktree AI Master, or run code --install-extension AashishPrasad.git-worktree-master. Cursor, VSCodium and other Open VSX editors use the same ID.

Development

npm install
npm test          # compiles; runs tests against real temp repos (git, snapshots, conflicts, agents, PR parsing)
npm run package   # produces git-worktree-master.vsix
code --install-extension git-worktree-master.vsix --force

Press F5 in this folder to launch an Extension Development Host.

Releasing

Two GitHub Actions workflows do the work:

  • CI (.github/workflows/ci.yml) runs on every push to main and every pull request. It runs the tests on Linux and macOS, packages the extension, and attaches the .vsix as a build artifact.
  • Release (.github/workflows/release.yml) runs when a v*.*.* tag is pushed. It checks that the tag matches package.json, runs the tests, publishes to the VS Code Marketplace and Open VSX, and creates a GitHub Release with the .vsix and the CHANGELOG section as notes.

One-time setup, under the repo's Settings → Secrets and variables → Actions:

Secret Where to get it
VSCE_PAT Azure DevOps → User settings → Personal access tokens. Organization: All accessible organizations; scope: Marketplace → Manage.
OVSX_PAT open-vsx.org → Settings → Access Tokens (optional; Open VSX is skipped without it).

To cut a release:

# 1. Add a "## x.y.z" section at the top of CHANGELOG.md and commit it
npm version patch          # or minor / major: bumps package.json, commits, tags vX.Y.Z
git push --follow-tags     # the tag triggers the Release workflow

Re-running a release is safe: already-published versions are skipped. Actions → Release → Run workflow does a dry run (build and package only) by default.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft