worktree-status

0
0
Source

Audit all git worktrees in the current project. Use when the user asks about worktree status, which branches are merged, which have uncommitted changes, or which worktrees can be safely cleaned up.

Install

mkdir -p .claude/skills/worktree-status && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4552" && unzip -o skill.zip -d .claude/skills/worktree-status && rm skill.zip

Installs to .claude/skills/worktree-status

About this skill

worktree-status

Report the status of every git worktree for the current project, covering dirty state and merge status.

When to use

  • User asks "which worktrees can I clean up?"
  • User asks "what's the status of my worktrees / branches?"
  • Before batch-cleaning worktrees, to avoid losing uncommitted work

Procedure

1. Pull latest main (MANDATORY)

You MUST pull latest main before any status checks. Without this, merge detection (both ancestry and content diff) will produce stale results and you may mistakenly conclude a branch is not merged.

cd "$(git rev-parse --show-toplevel)" && git pull origin main

2. Collect worktree info

PROJECT_DIR="$(git rev-parse --show-toplevel)"

for wt in $(git worktree list --porcelain | grep "^worktree " | sed 's/^worktree //' | grep -v "$PROJECT_DIR$"); do
  branch=$(git -C "$wt" branch --show-current 2>/dev/null)
  [ -z "$branch" ] && branch="(detached)"
  name=$(basename "$wt")

  # dirty?
  if [ -z "$(git -C "$wt" status --short 2>/dev/null)" ]; then
    dirty="clean"
  else
    dirty="DIRTY"
  fi

  # merged into origin/main?
  # NOTE: This project uses squash merges exclusively. `git merge-base
  # --is-ancestor` does NOT detect squash-merged branches. Always follow
  # up with a content diff (step 3) for branches that appear "not merged".
  if [ "$branch" != "(detached)" ]; then
    if git merge-base --is-ancestor "$branch" origin/main 2>/dev/null; then
      merged="merged"
    else
      merged="not merged (verify with content diff)"
    fi
  else
    merged="n/a"
  fi

  echo ""
  echo "[$name]  branch=$branch  $dirty  $merged"
  if [ "$dirty" = "DIRTY" ]; then
    git -C "$wt" status --short 2>/dev/null | sed 's/^/  /'
  fi
done

3. Detect squash-merged branches (content diff)

For any branch that shows "not merged", check whether the branch's changes are already in main. The correct method is:

  1. Find the files the branch actually changed (relative to merge-base).
  2. For each changed file, compare the branch version with main. If all files are identical, the branch was squash-merged.

⚠️ Do NOT use git diff origin/main <branch> — that compares the two tips directly, so commits added to main after the branch diverged will show up as false differences.

BRANCH="<branch>"
BASE=$(git merge-base origin/main "$BRANCH")

# List files the branch touched
FILES=$(git diff --name-only "$BASE" "$BRANCH")

# Compare each file between branch and current main
for f in $FILES; do
  d=$(git diff "$BRANCH" origin/main -- "$f" | wc -l)
  if [ "$d" != "0" ]; then
    echo "❌ $f — differs"
  else
    echo "✅ $f — identical in main"
  fi
done
# All ✅ = squash-merged

4. (Optional) Check for associated tmux sessions

Only run this if tmux is available and relevant (e.g. worktrees were created by codex-worker or similar tooling). Skip if not applicable.

tmux ls 2>/dev/null | grep -E 'codex-worker|<other-pattern>' || true

5. Present results

Always present results as a Markdown table. Every worktree must appear as a row. Never use abbreviated or prose-only summaries.

WorktreeBranchDirtyMergedCan clean?
example-wtfeat-foo✅ clean✅ squash-merged
another-wtfix-bar⚠️ 3 files❌ not merged❌ dirty + not merged
detached-wt(detached)⚠️ 14 filesn/a❌ has uncommitted changes

Column definitions:

  • Dirty: ✅ clean or ⚠️ N files
  • Merged: ✅ merged / ✅ squash-merged (confirmed via content diff) / ❌ not merged / n/a
  • Can clean?: only when merged (or squash-merged) AND clean

Add extra columns (e.g. tmux session, notes) only when relevant.

6. Cleanup (only when asked)

Only clean worktrees the user explicitly approves. For each:

NAME="<worktree-name>"
git worktree remove "/path/to/$NAME"
git branch -D "<branch>"  # only if the branch is no longer needed

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

641968

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

590705

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318395

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

450339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.