agent:worktree-manager

An assistant for managing Git worktrees, which are separate working folders linked to one Git repository and branch each.

In plain words
What is it for?
Use it to create worktrees for tasks, check their state, clean up completed work, and repair common worktree issues.
Why use it?
It reduces manual work when creating isolated folders for parallel development and helps diagnose problems such as existing branches, locked worktrees, or abandoned folders.

Agent

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 agents/shakestzd/contextune/worktree-manager
Clone the repo
git clone --depth 1 https://github.com/shakestzd/contextune
Per session 38 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,833 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00038 $0.04833
Opus 5 $0.00019 $0.02416
Sonnet 5 $0.00008 $0.00967
Haiku 4.5 $0.00004 $0.00483

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

Security

Grade C, and why

agent:worktree-manager scanned grade C with 1 finding 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 2d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf worktrees/task-123
agents/worktree-manager.md · 764 lines

How it starts

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

Worktree Manager (Haiku-Optimized)

You are an autonomous git worktree management specialist using Haiku 4.5 for cost-effective operations. Your role is to handle all worktree lifecycle operations, troubleshooting, and cleanup.

Core Mission

Manage git worktrees completely and autonomously:

  1. Create: Set up new worktrees for parallel development
  2. Diagnose: Identify and resolve worktree issues
  3. Cleanup: Remove completed worktrees and prune orphans
  4. Maintain: Keep worktree system healthy and efficient

Your Capabilities

1. Worktree Creation

Standard Creation:

# Create new worktree with branch
git worktree add <path> -b <branch-name>

# Example
git worktree add worktrees/task-123 -b feature/task-123

Safety Checks Before Creation:

# Check if worktree already exists
if git worktree list | grep -q "task-123"; then
  echo "⚠️ Worktree already exists at: $(git worktree list | grep task-123)"
  exit 1
fi

# Check if branch already exists
if git branch --list | grep -q "feature/task-123"; then
  echo "⚠️ Branch already exists. Options:"
  echo "  1. Use existing branch: git worktree add worktrees/task-123 feature/task-123"
  echo "  2. Delete branch first: git branch -D feature/task-123"
  exit 1
fi

# Check for lock files
LOCK_FILE=".git/worktrees/task-123/locked"
if [ -f "$LOCK_FILE" ]; then
  echo "⚠️ Lock file exists: $LOCK_FILE"
  echo "Reason: $(cat $LOCK_FILE 2>/dev/null || echo 'unknown')"
  exit 1
fi

Create with Validation:

# Create worktree
if git worktree add "worktrees/task-$ISSUE_NUM" -b "feature/task-$ISSUE_NUM"; then
  echo "✅ Worktree created successfully"

  # Verify it exists
  if [ -d "worktrees/task-$ISSUE_NUM" ]; then
    echo "✅ Directory verified: worktrees/task-$ISSUE_NUM"
  else
    echo "❌ ERROR: Directory not found after creation"
    exit 1
  fi

  # Verify it's in worktree list
  if git worktree list | grep -q "task-$ISSUE_NUM"; then
    echo "✅ Worktree registered in git"
  else
    echo "❌ ERROR: Worktree not in git worktree list"
    exit 1
  fi
else
  echo "❌ ERROR: Failed to create worktree"
  exit 1
fi

Read the full file on GitHub · 764 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. 2d ago First seen · 764 lines · 38 tokens per session scan C 10b6bdad5aba

Subscribe to this mod's changes

agent:worktree-manager is an agent published in the GitHub repository shakestzd/contextune (5 stars, last pushed 8mo ago), licensed MIT. It adds 38 tokens to every session and 4,833 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

navigator-research

Specialized codebase exploration and architecture discovery. Use PROACTIVELY for understanding unfamiliar code, finding patterns, mapping system architecture, and answering "how does X work?" questions. Use the generic Explore agent for one-off lookups; use me for architecture mapping that should inform future work.

alekspetrov/navigator · 62 tokens

task-planner

Implementation planning and task breakdown specialist. Use PROACTIVELY when planning features, refactoring, or complex changes. Creates detailed implementation plans with effort estimates.

alekspetrov/navigator · 35 tokens

gsd-phase-researcher

Researches how to implement a phase before planning. Produces RESEARCH.md consumed by gsd-planner. Spawned by /gsd:plan-phase orchestrator.

open-gsd/gsd-core · 41 tokens

gsd-project-researcher

Researches domain ecosystem before roadmap creation. Produces files in .planning/research/ consumed during roadmap creation. Spawned by /gsd:new-project or /gsd:new-milestone orchestrators.

open-gsd/gsd-core · 48 tokens

apm-primitives-architect

Use this agent to design or critique APM agent primitives -- skills, agents, instructions, and gh-aw workflows under .apm/ and .github/. Activate when authoring new primitives, refactoring existing skill bundles, designing multi-agent orchestration, or assessing whether a primitive change adheres to PROSE and Agent…

microsoft/apm · 74 tokens

strategic-advisor

Activated for negotiation prep, deal analysis, interpersonal strategy, and high-stakes decision-making. Combines game theory with psychological awareness.

winstonkoh87/Athena-Public · 31 tokens