worktree-statuslisted
Install: claude install-skill Pythoughts-labs/pythinker-code
# 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.
```bash
cd "$(git rev-parse --show-toplevel)" && git pull origin main
```
### 2. Collect worktree info
```bash
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