worktree-manager

A guide for managing Git worktrees, which are separate working directories linked to branches in the same repository.

In plain words
What is it for?
Use it to create, switch, list, merge, or remove worktrees during parallel development. It also describes safety checks and what to do if the required Worktrunk command is missing.
Why use it?
It helps developers work on multiple branches in parallel while keeping branch creation, switching, merging, and removal organized and safe.

Skill for Claude CodeCodex

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 skills/jtsang4/efficient-coding/worktree-manager
Any agent
npx skills add jtsang4/efficient-coding --skill worktree-manager
Clone the repo
git clone --depth 1 https://github.com/jtsang4/efficient-coding

Made for: Claude Code, Codex.

Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,111 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.00041 $0.01111
Opus 5 $0.00020 $0.00556
Sonnet 5 $0.00008 $0.00222
Haiku 4.5 $0.00004 $0.00111

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

Security

Grade A, and why

worktree-manager 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.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/install_worktrunk.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/worktree-manager/SKILL.md · 97 lines

How it starts

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

Worktree Manager

Overview

Use Worktrunk (wt) as the single interface for Git worktree management: create/switch worktrees, list global status, merge back to the default branch, and remove worktrees safely. Prefer safe operations; never use destructive flags unless the user explicitly requests them.

Workflow Decision Tree

Recovery: If a wt command fails because wt is missing

Do not preflight-check wt on every invocation. Instead, attempt the requested wt command. If it fails with an error like "command not found: wt" (or equivalent), then:

  1. Ask the user: "I can't run wt because it isn't installed. Should I install Worktrunk now (recommended)?"
  2. If the user says yes:
    • Run the installer script: scripts/install_worktrunk.sh
      • Example: bash <SKILL_DIR>/scripts/install_worktrunk.sh
    • Verify: wt --version
    • Re-run the original wt ... command.
  3. Do not install shell integration without confirmation (it edits shell rc files):
    • Ask before running: wt config shell install

Step 1: Always run guardrails before merge/remove

Before wt merge / wt remove / anything with --force / -D:

  1. Confirm repo context:
    • git rev-parse --show-toplevel
    • pwd
  2. Confirm working tree cleanliness (if dirty, ask what to do; do not proceed):
    • git status --porcelain
  3. Confirm the current worktree and branch:
    • git branch --show-current
    • wt list (use as the global source of truth for other worktrees)

Step 2: Handle the user request via the matching workflow

A) Create or switch worktrees (most common)

Goal: "Put branch X into its own directory and switch into it."

  1. If the user gave a branch/worktree name:
    • wt switch <name>
  2. If the user asked to create a new branch/worktree:
    • Default (this repo): create the worktree by copying the current working state from the current worktree, so experiments are isolated but start "warm" (deps + uncommitted changes).
    • Implement with Worktrunk by creating from the current worktree as the base (use --base=@ unless the user explicitly wants a clean base).
    • Run: wt switch --create <name> --base=@
  3. If the user gave no name:
    • Show options with wt list and ask which one to switch to.

Read the full file on GitHub · 97 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 97 lines · 41 tokens per session scan A 2a76187cf018

Subscribe to this mod's changes

worktree-manager is a skill published in the GitHub repository jtsang4/efficient-coding (2 stars, last pushed 7d ago), licensed MIT. It adds 41 tokens to every session and 1,111 once invoked, about $0.0002 per session on Opus 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.