Skip to content
Skill

Worktrees

Creates git worktrees in tmux sessions and starts an AI agent on a prompt

Worktrees is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
39
Last commit
License
MIT
Listing updated

Similar skills

About Worktrees

This skill sets up an isolated git worktree for a branch, opens it in a new tmux session, and launches an AI agent there with a prompt. The agent runs in the fourth tmux window, and the session is marked recent without switching to it, so work can continue in the current session.

The skill chooses between three prompt sources: an existing issue, plan, design doc or spec file; a generated temporary prompt file written to /tmp; or no prompt at all, in which case the worktree is created and the current session keeps working in it. It assumes a base branch of main unless told otherwise, and it runs a worktree-branch helper script from the user's Scripts folder. The skill also advises checking the fourth tmux window afterward to confirm the agent started and received its prompt.

It expects a git repository with a main worktree, tmux, and the worktree-branch script installed. The examples use the oc binary as the agent launcher.

When your agent uses it

This skill creates git worktrees with tmux sessions and spawns an AI agent with a prompt. Triggers: "create a worktree", "new worktree", "worktree for branch", "spawn worktree", "parallel branch", "work on branch in new session", "worktree-branch script". Creates isolated worktree directories with an AI agent running automatically. Not for regular git branching or checkout operations.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (3 KB) on GitHub on 5 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Copy the skill folder to ~/.claude/skills/worktrees to use it in all your projects:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/worktrees &&
cp -R "$tmp/built/ai-agents/opencode/skills/worktrees" ~/.claude/skills/worktrees &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/worktrees inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/worktrees to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/worktrees &&
cp -R "$tmp/built/ai-agents/opencode/skills/worktrees" ~/.agents/skills/worktrees &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/worktrees inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/worktrees to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/worktrees &&
cp -R "$tmp/built/ai-agents/opencode/skills/worktrees" ~/.cursor/skills/worktrees &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/worktrees inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/richardgill/nix.git --path built/ai-agents/opencode/skills/worktrees

Or copy the folder to ~/.gemini/skills/worktrees yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/worktrees:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/richardgill/nix.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/worktrees &&
cp -R "$tmp/built/ai-agents/opencode/skills/worktrees" ~/.copilot/skills/worktrees &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/worktrees inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/richardgill/nix.git

Then copy nix/built/ai-agents/opencode/skills/worktrees into your agent's skills folder as worktrees. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Worktree creation
Creates a sibling git worktree from local main HEAD or from an explicit source ref.
Tmux session setup
Opens the new worktree in a tmux session without switching the current session to it.
Automatic agent launch
Starts an AI agent in the fourth tmux window with the chosen prompt file.
Prompt file selection
Chooses between an existing spec file, a generated temp prompt, or no prompt.
Startup verification
Advises checking the agent window to confirm it started and received the prompt.

Good for

  • Start a parallel branch for a feature while keeping my current session free
  • Spin up a worktree from a planning document and let an agent begin implementing it
  • Create a new branch from a remote feature branch in its own worktree and session
  • Hand a bug description to an agent in a fresh isolated worktree

Worktrees FAQ

When does Worktrees trigger?

It triggers on phrases such as create a worktree, new worktree, worktree for branch, spawn worktree, parallel branch, or work on branch in new session. It is not meant for regular git branching or checkout.

What does Worktrees need to run?

It needs a git repository with a main worktree, tmux, and the worktree-branch script from the user's Scripts folder. The examples call the oc agent binary.

Which base branch does Worktrees use?

By default it uses main, creating the new branch from local ./main HEAD unless an explicit source ref is given.

Does Worktrees switch my tmux session to the new worktree?

No. The new session is created and marked recent but not switched to.

How do I install Worktrees in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/worktrees to use it in all your projects, or to .claude/skills/worktrees in one project.

Does Worktrees run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Worktrees?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Worktrees?

The closest alternatives to Worktrees are Worktrees, Git worktree, Create worktree, Tmux pi and Wt.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from richardgill/nix

  1. Lets your agent manage Todoist tasks through the todoist command-line tool

    • Open source
    • 39 GitHub stars
    • Productivity
  2. Plans a clean-room rewrite of existing behavior, from requirements through phased

    • Open source
    • 39 GitHub stars
    • Developer tools
  3. Delegates work to supervised Pi agents running in tmux sessions and worktrees

    • Open source
    • 39 GitHub stars
    • Developer tools
  4. Lets your agent run web searches, fetch page content and quick answers via Kagi CLI

    • Open source
    • 39 GitHub stars
    • Web search and scraping
  5. Lets an agent handle Gmail tasks through the gws command-line tool

    • Open source
    • 39 GitHub stars
    • Communication
  6. Lets your agent work with Google Calendar through the gws command-line tool

    • Open source
    • 39 GitHub stars
    • Productivity