worktree-status
Checks the status of Git worktrees for uncommitted changes and merge status to ensure safe removal.
Install
mkdir -p .claude/skills/worktree-status && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4552" && unzip -o skill.zip -d .claude/skills/worktree-status && rm skill.zipInstalls to .claude/skills/worktree-status
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
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.Key capabilities
- →Audit all git worktrees in a project
- →Detect uncommitted changes in worktrees
- →Verify if branches are merged into main
- →Perform content diffs to identify squash-merged branches
- →Report worktree status in a Markdown table
How it works
It iterates through all worktrees, checks for dirty states, and performs a content diff against origin/main to confirm if branches are merged.
Inputs & outputs
When to use worktree-status
- →Checking status of all git branches
- →Identifying safe worktrees to delete
- →Auditing uncommitted changes across worktrees
- →Verifying merge status of features
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:
- Find the files the branch actually changed (relative to merge-base).
- 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.
| Worktree | Branch | Dirty | Merged | Can clean? |
|---|---|---|---|---|
example-wt | feat-foo | ✅ clean | ✅ squash-merged | ✅ |
another-wt | fix-bar | ⚠️ 3 files | ❌ not merged | ❌ dirty + not merged |
detached-wt | (detached) | ⚠️ 14 files | n/a | ❌ has uncommitted changes |
Column definitions:
- Dirty:
✅ cleanor⚠️ 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
When not to use it
- →When the user has not pulled the latest main branch
- →When the user wants to clean worktrees without prior verification
Prerequisites
Limitations
- →Requires pulling latest main to avoid stale merge results
- →Content diffs are necessary for squash-merged branches
How it compares
It provides a safe, automated audit of worktree status including squash-merge detection, whereas manual checks often miss squash-merged branches.
Compared to similar skills
worktree-status side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| worktree-status (this skill) | 1 | 6mo | Review | Beginner |
| tmux | 20 | 2mo | Review | Intermediate |
| tmux | 0 | 3mo | Review | Intermediate |
| worktree-parallel | 0 | 7mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by MoonshotAI
View all by MoonshotAI →You might also like
tmux
openclaw
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
tmux
Anhvu1107
ALWAYS use this when the request matches Tmux: Expert tmux session, window, and pane management for terminal multiplexing, persistent remote workflows, and shell scripting automation.
worktree-parallel
noah-rivard
Create and manage a git worktree for parallel feature development, then open the new worktree in the editor (code/Cursor) for a second Codex session. Use when the user asks to work on another feature simultaneously, spin up a parallel workspace, or open a new worktree even if they do not mention wor
bash-linux
davila7
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
create-worktree-skill
disler
Use when the user explicitly asks for a SKILL to create a worktree. If the user does not mention "skill" or explicitly request skill invocation, do NOT trigger this. Only use when user says things like "use a skill to create a worktree" or "invoke the worktree skill". Creates isolated git worktrees with parallel-running configuration.
domain-dns-ops
steipete
Domain/DNS ops across Cloudflare, DNSimple, Namecheap for Peter. Use for onboarding zones to Cloudflare, flipping nameservers, setting redirects (Page Rules/Rulesets/Workers), updating redirect-worker mappings, and verifying DNS/HTTP. Source of truth: ~/Projects/manager.