worktree

worktree is a skill for Claude Code from psd401/psd-claude-plugins. It costs 43 tokens per session (2,387 once invoked), scanned A, original, MIT.

A tool for managing Git worktrees, which are separate checkouts of one repository that let you work on several branches at once. It can create, list, remove, prune, and clean up worktrees and related branches.

In plain words
What is it for?
Use it to start parallel feature or bug-fix work, view active worktrees, remove finished ones, and clean up branches after merging.
Why use it?
It avoids repeatedly switching branches or stashing unfinished changes when developing in parallel.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter; names the AskUserQuestion tool; positional $N argument.

Part of the psd-coding-system plugin — 9 skills shipped together

Good fit Use it to start parallel feature or bug-fix work, view active worktrees, remove finished ones, and clean up branches after merging.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/psd401/psd-claude-plugins/worktree
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.

Any agent
npx skills add psd401/psd-claude-plugins --skill worktree
Clone the repo
git clone --depth 1 https://github.com/psd401/psd-claude-plugins

Made for: Claude Code.

Or install psd-coding-system, the plugin that ships this one along with the rest of its 9 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for worktree

README.md
[![agentmods](https://agentmods.dev/badge/skills/psd401/psd-claude-plugins/worktree/github.svg)](https://agentmods.dev/skills/psd401/psd-claude-plugins/worktree)
Your own site
<a href="https://agentmods.dev/skills/psd401/psd-claude-plugins/worktree"><img src="https://agentmods.dev/badge/skills/psd401/psd-claude-plugins/worktree/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for worktree

Your own site · 80×15
<a href="https://agentmods.dev/skills/psd401/psd-claude-plugins/worktree"><img src="https://agentmods.dev/badge/skills/psd401/psd-claude-plugins/worktree.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,387 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00043 $0.02387
Opus 5.5 $0.00017 $0.00955
Sonnet 5.5 $0.00009 $0.00477
Haiku 4.5 $0.00004 $0.00239

Measured 14d ago against content hash 13a72c1d7ed9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 14d ago.

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.

plugins/psd-coding-system/skills/worktree/SKILL.md · 230 lines

How it starts

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

Worktree Command

You manage parallel development using git worktrees. Worktrees let you work on multiple branches simultaneously without stashing or switching — each worktree is an independent checkout of the repo.

Arguments: $ARGUMENTS

Phase 1: Parse Arguments & Detect Intent

ARGS="$ARGUMENTS"

# Detect subcommand
case "$ARGS" in
  list|ls)
    SUBCOMMAND="list"
    ;;
  prune)
    SUBCOMMAND="prune"
    ;;
  clean|sweep|tidy)
    SUBCOMMAND="clean"
    ;;
  remove\ *|rm\ *)
    SUBCOMMAND="remove"
    TARGET=$(echo "$ARGS" | sed 's/^remove //;s/^rm //')
    ;;
  *)
    SUBCOMMAND="create"
    TARGET="$ARGS"
    ;;
esac

echo "Subcommand: $SUBCOMMAND"
echo "Target: ${TARGET:-N/A}"

Phase 2: Execute

If list:

echo "=== Active Worktrees ==="
git worktree list

echo ""
echo "=== Branches in Worktrees ==="
git worktree list --porcelain | grep "^branch" | sed 's/branch refs\/heads\//  /'

If prune (worktrees only — lightweight):

echo "=== Pruning stale worktrees ==="
git worktree prune --verbose

echo ""
echo "=== Remaining worktrees ==="
git worktree list

If clean (post-merge hygiene — restores what /clean-branch used to do):

Sweeps merged branches (local and remote, squash-merge-aware), stale worktrees, and issues that should be closed. Gather the candidates first; the destructive steps (remote-branch deletion, issue closing) are confirmed before running.

echo "=== /worktree clean — post-merge hygiene ==="
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null || echo main)
if git ls-remote --exit-code --heads origin dev >/dev/null 2>&1; then BASE=dev; else BASE="$DEFAULT_BRANCH"; fi
CUR=$(git branch --show-current); PROT='^(main|master|dev|HEAD)$'

git fetch --prune origin --quiet 2>/dev/null || true   # drop tracking refs for branches already deleted on the remote

echo "--- 1. local branches whose work is merged (safe to delete) ---"
LOCAL_DELETE=""
for b in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
  echo "$b" | grep -qE "$PROT" && continue
  [ "$b" = "$CUR" ] && continue
  # normal-merged into base, OR its PR is merged (covers squash merges, which change the SHA)
  if git merge-base --is-ancestor "$b" "origin/$BASE" 2>/dev/null \
     || [ -n "$(gh pr list --head "$b" --state merged --limit 1 --json number --jq '.[].number' 2>/dev/null)" ]; then
    LOCAL_DELETE="$LOCAL_DELETE $b"
  fi
done
echo "${LOCAL_DELETE:-(none)}"

echo "--- 2. worktrees (remove any on a merged/gone branch) ---"
git worktree list

echo "--- 3. remote branches whose PR is MERGED/CLOSED (dependabot excluded) ---"
REMOTE_DELETE=""
for rb in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin/ | sed 's#^origin/##'); do
  echo "$rb" | grep -qE "$PROT" && continue
  echo "$rb" | grep -qE '^dependabot/' && continue     # Dependabot manages its own branches
  S=$(gh pr list --head "$rb" --state all --limit 1 --json state --jq '.[].state' 2>/dev/null)
  case "$S" in MERGED|CLOSED) REMOTE_DELETE="$REMOTE_DELETE $rb" ;; esac
done
echo "${REMOTE_DELETE:-(none)}"

echo "--- 4. issues still OPEN whose linked PR already merged ---"
ORPHANS=""
for pr in $(gh pr list --state merged --limit 30 --json number --jq '.[].number' 2>/dev/null); do
  for issue in $(gh pr view "$pr" --json closingIssuesReferences --jq '.closingIssuesReferences[].number' 2>/dev/null); do
    [ "$(gh issue view "$issue" --json state --jq '.state' 2>/dev/null)" = "OPEN" ] && ORPHANS="$ORPHANS #${issue}(PR#${pr})"
  done
done
echo "${ORPHANS:-(none)}"

Read the full file on GitHub · 230 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. 14d ago Changed · -1 lines 13a72c1d7ed9
  2. 1mo ago Changed d858ad8f7543
  3. 2mo ago First seen · 231 lines · 43 tokens per session scan A fbddf2d14e1b

Subscribe to this mod's changes

worktree is a skill published in the GitHub repository psd401/psd-claude-plugins (2 stars, last pushed 9d ago), licensed MIT. It adds 43 tokens to every session and 2,387 once invoked, about $0.0002 per session on Opus 5.5. 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.

Related

Other skills, from other repositories

merge-batch

Prepare and merge an owner-selected PR batch with contributor credit and exact-candidate admission. Use for a pasted PR list; combined focused validation is diagnostic, and every actual landing still requires its applicable checks and authorization.

diegosouzapw/OmniRoute · 46 tokens

prowler-commit

Creates professional git commits for Prowler following conventional-commits format, with prek pre-commit hooks. Trigger: When creating commits, after completing code changes, when user asks to commit.

prowler-cloud/prowler · 44 tokens

gh-auth-isolation

Safely manage multiple GitHub identities (EMU + personal) in agent workflows.

github/gh-aw · 20 tokens

github-skill

Work with GitHub via the gh CLI — clone repositories, create/list/merge pull requests, create/list issues, and run any other gh command (API calls, workflow runs, releases, repo administration). List operations return parsed JSON.

zeenie-ai/OpenCompany · 51 tokens

comet-github

A routing guide for Comet-related GitHub work. It directs requests about pull requests, issues, CI failures, ideas, and fixes to the appropriate review or implementation process.

rpamis/comet · 72 tokens

re0-merge

Review and land an external contribution the way this suite does: gate it against the thesis, land it with the author's credit intact, complete a new skill rather than merging it raw, then approve, credit, and explain before closing. Use when reviewing a pull request, as any collaborator or maintainer, not only the…

LilMGenius/paperthin · 70 tokens