worktree

A command that gives separate Git worktrees to agents working on GitHub issues. A worktree is an additional working copy of the same repository, so several tasks can be developed independently at once.

In plain words
What is it for?
Use it to implement one or more GitHub issues in parallel, with each task handled, tested, and verified in its own worktree.
Why use it?
It reduces clashes between parallel changes and keeps each issue's files and tests isolated. It also checks the repository before work begins and requires confirmation after showing the planned tasks.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/theshadow27/mcp-cli/worktree
Clone the repo
git clone --depth 1 https://github.com/theshadow27/mcp-cli

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,854 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01854
Opus 5 $0.00000 $0.00927
Sonnet 5 $0.00000 $0.00371
Haiku 4.5 $0.00000 $0.00185

Measured yesterday against content hash 14cb87599f1f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

worktree scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/worktree.md · 203 lines

How it starts

The opening of the file, as written. The whole thing — 203 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Worktree: Parallel Issue Orchestrator

Orchestrate implementation of one or more GitHub issues in parallel using worktree-isolated agents. Each issue gets its own git worktree, its own agent, and is independently implemented, tested, and verified.

Input

One or more GitHub issue numbers or descriptions, space-separated. Parse from: $ARGUMENTS

Examples:

  • /worktree 14 — single issue
  • /worktree 14 15 16 — parallel batch
  • /worktree "add shell completions" — free-text task

Workflow

Step 1: Gather Issues

For each issue number provided:

gh issue view <number> --json number,title,body,labels

For free-text descriptions, treat each as a standalone task.

Present a summary table to the user:

# Title Labels Approach
14 Add shell completions enhancement feat
15 Daemon crashes on bad config bug fix

Ask the user to confirm before proceeding. This is the last checkpoint — after confirmation, agents run autonomously.

Step 2: Check Preconditions

git rev-parse --is-inside-work-tree
git branch --show-current
git status --short
  • Must be in a git repo
  • Warn if not on main branch (agents branch from HEAD)
  • Warn if there are uncommitted changes — agents will branch from current HEAD, so uncommitted work won't be in their worktrees
  • Verify bun install works (agents will need deps)

Step 3: Implement in Parallel

For EACH issue, spawn an Agent with isolation: "worktree" running in the background. Each agent gets a detailed prompt that includes:

  1. The full issue context (number, title, body, labels)
  2. The complete /implement workflow instructions (inline — don't reference the command)
  3. Project conventions from CLAUDE.md

Use the Agent tool like this for each issue (all launched in a single message for true parallelism):

Agent(
  subagent_type: "general-purpose",
  isolation: "worktree",
  run_in_background: true,
  description: "Implement issue #<N>",
  prompt: "<detailed prompt with full issue context and implement workflow>"
)

Read the full file on GitHub · 203 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 203 lines · 0 tokens per session scan A 14cb87599f1f

Subscribe to this mod's changes

worktree is a command published in the GitHub repository theshadow27/mcp-cli (2 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,854 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.