worktrees

A command for managing Git worktrees, which are separate working directories linked to Git branches.

In plain words
What is it for?
For listing, creating, switching, and removing worktrees, and for reviewing their task status, activity, branches, and disk usage.
Why use it?
It helps developers isolate tasks and identify worktrees that are merged, stale, or no longer needed before cleaning them up.

Command

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/srstomp/pokayokay/worktrees
Clone the repo
git clone --depth 1 https://github.com/srstomp/pokayokay
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 849 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.00012 $0.00849
Opus 5 $0.00006 $0.00425
Sonnet 5 $0.00002 $0.00170
Haiku 4.5 $0.00001 $0.00085

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

Security

Grade A, and why

worktrees 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 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.

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/pokayokay/commands/worktrees.md · 139 lines

How it starts

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

Worktrees Management

Manage git worktrees used for task isolation.

Command: $ARGUMENTS (default: list)

Subcommands

List Worktrees (default)

Show all active worktrees with status.

git worktree list --porcelain

Parse and display:

Worktree Task Status Last Activity
story-12-user-auth task 42 in_progress 2 commits, 3h ago
task-51-email task 51 review 5 commits, 1d ago
story-8-billing task 38 blocked stale (7 days)

Include:

  • Total disk usage: du -sh .worktrees/
  • Count of worktrees

Cleanup

Remove stale and merged worktrees.

Criteria for cleanup:

  1. Merged: Branch has been merged to default branch
  2. Stale: No commits in 7+ days AND task is done/blocked
  3. Orphaned: Associated task no longer exists in ohno

Flow:

  1. List candidates with reason
  2. Prompt for confirmation
  3. Remove each worktree and branch
  4. Report freed disk space
# Check if merged
git branch --merged $(git symbolic-ref refs/remotes/origin/HEAD) | grep <branch>

# Check last commit date
git log -1 --format=%ci <branch>

# Remove worktree
git worktree remove .worktrees/<name>

# Delete branch
git branch -d <branch>  # -D if not merged

Switch

Change to a different worktree.

/pokayokay:worktrees switch story-12
  1. Find worktree matching pattern
  2. If multiple matches, show selection
  3. Output: cd /path/to/.worktrees/story-12-user-auth

Note: Claude Code cannot change the user's shell directory. Output the cd command for user to run, or if in an IDE context, use appropriate navigation.

Remove

Remove a specific worktree.

/pokayokay:worktrees remove story-12
  1. Find worktree matching pattern
  2. Check for uncommitted changes
  3. If changes exist, prompt: "Worktree has uncommitted changes. Remove anyway?"
  4. Remove worktree and optionally branch

Integration with ohno

Cross-reference worktrees with task status:

Read the full file on GitHub · 139 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 · 139 lines · 12 tokens per session scan A 01732aebf57a

Subscribe to this mod's changes

worktrees is a command published in the GitHub repository srstomp/pokayokay (9 stars, last pushed 1mo ago), licensed MIT. It adds 12 tokens to every session and 849 once invoked, about $0.0001 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.