Agent skill

Git Worktree

by davidondrej in davidondrej/skills

Use Git worktrees to isolate parallel coding tasks. An agent skill from davidondrej/skills.

MITAuto-check: notesAgent Workflows

Install Git Worktree

skills CLI
$ npx skills add davidondrej/skills --skill git-worktree -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install davidondrej/skills git-worktree --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/davidondrej/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/agent-orchestration/git-worktree .claude/skills/git-worktree && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
git-worktree
GitHub stars
4.1k
Token cost
~1.1k tokens
SKILL.md length
455 words
Files
2
Skills in repo
51
Repo updated
First seen
Licence
MIT

At a glance

Use Git worktrees to isolate parallel coding tasks. An agent skill from davidondrej/skills.

  • Works in 6 steps: Env/secret files — copy .env,… → Dependencies — install locally (npm ci,… → Databases and services — choose shared… → …
  • Setting up a task checkout
  • SKILL.md covers Start here, Working model, Creating and removing and Complete the setup, plus 2 more sections
  • Calls git, npm and pnpm

What it does

Git Worktree is an agent skill from davidondrej/skills. Use Git worktrees to isolate parallel coding tasks. Use when setting up a task checkout, working in a shared repo, or managing existing worktrees.

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in Agent Workflows, covering Git worktrees. It works with Git. The repository describes itself as: access to david ondrej's personal agent skills. The licence is MIT.

When your agent uses it

  • Setting up a task checkout
  • Working in a shared repo
  • Managing existing worktrees

Example prompts

  • “/git-worktree”

Requirements

  • Docker

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Env/secret files — copy .env, .env.local, and similar files from the primary checkout. Never symlink them: edits would change the originals.
  2. Dependencies — install locally (npm ci, pnpm install, uv sync, bundle install). Never symlink node_modules from the primary checkout…
  3. Databases and services — choose shared or per-worktree state. For shared services, pin their identity to avoid duplicate instances and…
  4. Ports — run dev/test servers and debuggers one at a time, or configure separate ports per worktree.
  5. Generated files and caches — rebuild gitignored output in the worktree (npm run build, codegen).
  6. Git hooks — core.hooksPath and .git/config are shared; verify hook scripts don't assume the primary checkout's path.

What it can do on your machine

Read from SKILL.md and the folder at commit ea32e5f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • npm
    • pnpm
    • uv
    • bundle

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, npm, pnpm and uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktree loads about 1.1k tokens when it runs. Until then it costs about 40 tokens; SKILL.md has 455 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:50
    1. **Env/secret files** — copy `.env`, `.env.local`, and similar files from the primary checkout. Never symlink them: ed
  • NoteMentions a .env fileSKILL.md:65
    "cp $ROOT_WORKTREE_PATH/.env.local .env.local"

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from davidondrej/skills at commit ea32e5f, republished under its MIT licence (© davidondrej). 455 words, ~1,098 tokens.

Download SKILL.mdSave it as .claude/skills/git-worktree/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
git-worktree
description
Use Git worktrees to isolate parallel coding tasks. Use when setting up a task checkout, working in a shared repo, or managing existing worktrees.
disable-model-invocation
true
triggers
user, model

Git Worktrees for Parallel Agents

Start here

Detect where you are before editing:

bash
[ "$(git rev-parse --path-format=absolute --git-dir)" = "$(git rev-parse --path-format=absolute --git-common-dir)" ] \
  && echo "primary checkout" || echo "worktree"
  • Primary checkout → create a task-named worktree, complete the setup below, and cd into it before editing.
  • Worktree (including one created by Cursor) → proceed with the task.

Working model

Worktrees have separate working files and branches but share Git history, stashes, config, and refs.

  • One task = one worktree = one agent session. Never share a working directory between agents.
  • Keep the primary checkout on main, only for review, merging, and pushing.
  • Nothing auto-merges. The human reviews each diff before merging or discarding the worktree.
  • Keep task branches local and short-lived. Push only main unless the user explicitly asks to push a task branch.
  • Merge one worktree at a time. If main moved, rebase the task branch before merging.

Creating and removing

bash
git worktree add ../myrepo-task-x          # new worktree + branch "myrepo-task-x"
git worktree add ../fix-y -b fix-y main    # explicit branch off main
git worktree list                          # see all worktrees
git worktree remove ../myrepo-task-x       # delete when merged/abandoned
git worktree prune                         # clean up stale registrations

A branch can be checked out in only one worktree, including main.

In Cursor, use the Agents Window or /worktree <task>. /apply-worktree applies results to the main checkout; /delete-worktree discards them. /best-of-n model1,model2 <task> runs the same task in parallel worktrees, one per model. Cursor auto-deletes older worktrees, so preserve results promptly; pushing task branches still requires explicit approval.

Complete the setup

A fresh worktree contains tracked files only. Bootstrap it before task work:

  1. Env/secret files — copy .env, .env.local, and similar files from the primary checkout. Never symlink them: edits would change the originals.
  2. Dependencies — install locally (npm ci, pnpm install, uv sync, bundle install). Never symlink node_modules from the primary checkout: bundlers such as Next.js/Turbopack reject paths outside the worktree. If it is a symlink, remove it with rm -f node_modules and install normally.
  3. Databases and services — choose shared or per-worktree state. For shared services, pin their identity to avoid duplicate instances and port conflicts. For shared Docker Compose services, pin the project name, for example with a top-level name:; otherwise each worktree's folder name creates a separate project. Copy or re-seed per-worktree state such as SQLite files.
  4. Ports — run dev/test servers and debuggers one at a time, or configure separate ports per worktree.
  5. Generated files and caches — rebuild gitignored output in the worktree (npm run build, codegen).
  6. Git hooks — core.hooksPath and .git/config are shared; verify hook scripts don't assume the primary checkout's path.
Show full SKILL.md (82 more words)Show less

Automate setup

In Cursor, .cursor/worktrees.json runs setup on creation ($ROOT_WORKTREE_PATH is the primary checkout):

json
{
  "setup-worktree": [
    "npm ci",
    "cp $ROOT_WORKTREE_PATH/.env.local .env.local"
  ]
}

Otherwise, put the checklist in scripts/setup-worktree.sh and run it first in each new worktree. Find the primary checkout from a worktree with:

bash
dirname "$(git rev-parse --path-format=absolute --git-common-dir)"

Merge and clean up

bash
# from the primary checkout, after reviewing the worktree's diff:
git merge --no-ff task-branch     # or: git merge --squash task-branch
git worktree remove ../myrepo-task-x
git branch -d task-branch

In Cursor, use /apply-worktree, then review and commit.

  • Delete merged worktrees to reclaim their files and dependencies.
  • Rebase or restart worktrees that have stalled for days.
  • Commit early and often. Deleting a worktree loses uncommitted work; commits remain in the shared repository.

© davidondrej, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/agent-orchestration/git-worktree of davidondrej/skills.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit ea32e5f

Compare with similar skills

Git Worktree next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktree compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree this skilldavidondrej/skills4.1k—~1.1kAutomated safety check: NotesMIT
Using Git Worktreesfarm-fe/farm5.6k13 repos~2kAutomated safety check: PassMIT
Agtx Task Sweepfynnfluegge/agtx1.7k—~1.7kAutomated safety check: PassApache-2.0
PRP Workstream OrchestratorWirasm/prp2.3k—~3.5kAutomated safety check: PassMIT
Squad Agent Collaboration Patternsmicrosoft/waza1.4k4 repos~500Automated safety check: PassMIT
Vspawnvlinx-io/VelaTerm259—~2.5kAutomated safety check: PassMIT

Similar skills

  • A skill your agent uses when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git…

    5.6k GitHub starsUsed in 13 repos~2k tokens
    Agent WorkflowsAuto-check passed
  • Agtx Task Sweep

    fynnfluegge/agtx

    Breaks a conversation's results into feature-level tasks and pushes them to the agtx kanban board, where each task gets its own worktree and agent session.

    1.7k GitHub stars~1.7k tokensUpdated 5 days ago
    Agent WorkflowsAuto-check passed
  • Coordinates several PRP workstreams in isolated Git worktrees from one session, verifying proof, holding merge gates and sequencing the merges.

    2.3k GitHub stars~3.5k tokensUpdated 5 days ago
    Agent WorkflowsAuto-check passed
  • Official

    Shared collaboration rules for a team of squad agents covering worktree awareness, writing decisions to an inbox, cross-agent requests and reviewer lockout.

    1.4k GitHub starsUsed in 4 repos~500 tokens
    Agent WorkflowsAuto-check passed
  • Vspawn

    vlinx-io/VelaTerm

    Explicitly spawn a standalone child session under the current vlx-term session, passing the task in as its first message (mirrors spawntask).

    259 GitHub stars~2.5k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Guides decisions for agents working in an aweb team: when to check shared state, claim tasks, take locks, read team roles and instructions, and open separate worktrees.

    115 GitHub stars~4k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from davidondrej/skills

All 51 skills in this repo
  • Nagent

    davidondrej/skills

    Launch a new bb worker thread with the right project, model, worktree, and task brief.

    4.1k GitHub stars~1.7k tokensUpdated today
    Auto-check: notes
  • Browser Harness

    davidondrej/skills

    Direct browser control via CDP. An agent skill from davidondrej/skills.

    4.1k GitHub starsUsed in 2 repos~3k tokens
    Auto-check passed
  • Persistent Localhost

    davidondrej/skills

    Manage persistent dev servers, APIs, and other local processes on a port using macOS LaunchAgents.

    4.1k GitHub stars~618 tokensUpdated today
    Auto-check passed
  • Reset Cursor Acp

    davidondrej/skills

    Reset a stuck Cursor ACP thread in <chat-system and reload its configuration.

    4.1k GitHub stars~728 tokensUpdated today
    Auto-check passed
  • Anti Sleep

    davidondrej/skills

    Keep a Mac awake for a set duration or while a process runs.

    4.1k GitHub stars~640 tokensUpdated today
    Auto-check: warnings
  • Bb CLI

    davidondrej/skills

    Use this when controlling bb. An agent skill from davidondrej/skills.

    4.1k GitHub stars~823 tokensUpdated today
    Auto-check passed

Works with

Questions about Git Worktree

What does Git Worktree do?

Use Git worktrees to isolate parallel coding tasks. An agent skill from davidondrej/skills. Git Worktree is an agent skill from davidondrej/skills. Use Git worktrees to isolate parallel coding tasks.

When should I use Git Worktree?

Git Worktree fits situations like: setting up a task checkout; working in a shared repo; managing existing worktrees.

How do I install Git Worktree in Claude Code?

Run `npx skills add davidondrej/skills --skill git-worktree -a claude-code`. Or copy the skill folder (skills/agent-orchestration/git-worktree in davidondrej/skills) into .claude/skills/git-worktree in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktree in Codex?

Run `npx skills add davidondrej/skills --skill git-worktree -a codex`. Or copy the skill folder (skills/agent-orchestration/git-worktree in davidondrej/skills) into .agents/skills/git-worktree in your project. Codex loads it when a task matches its description.

Can I use Git Worktree in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add davidondrej/skills --skill git-worktree -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-worktree, .gemini/skills/git-worktree, .github/skills/git-worktree and .opencode/skills/git-worktree in your project.

What does Git Worktree need to run?

Going by SKILL.md and its folder, Git Worktree needs the command-line tools its instructions call (git, npm, pnpm, uv and bundle). Our summary lists: Docker.

Does Git Worktree access the network?

SKILL.md contains no URLs. Its commands use git, npm and uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktree safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Git Worktree use?

Git Worktree is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktree use?

About 1.1k tokens (SKILL.md is roughly 4.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Worktree?

Skills that share tags, products or a category with Git Worktree: Using Git Worktrees (farm-fe/farm, 5.6k stars), Agtx Task Sweep (fynnfluegge/agtx, 1.7k stars), PRP Workstream Orchestrator (Wirasm/prp, 2.3k stars) and Squad Agent Collaboration Patterns (microsoft/waza, 1.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktree?

davidondrej (a GitHub user) maintains it in davidondrej/skills, which has 4,105 GitHub stars. The repository holds 51 skills in this directory. The repository was last updated on October 6, 2026.

Source: davidondrej/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.