Our review
Automates the cleanup of a git worktree by detecting the current branch, checking for uncommitted changes, removing the worktree, and checking out the base branch.
Strengths
- Saves time by automating multi-step cleanup process
- Prevents accidental deletion of local and remote branches
- Handles common error cases like uncommitted changes with clear feedback
- Allows specifying a base branch and forcing execution when needed
Limitations
- Only works when run from within a worktree directory
- Does not delete local or remote branches
- Requires all changes to be committed by default
Use after completing work in a worktree and before switching branches to maintain a clean development environment.
Do not use if you intend to keep the worktree directory for future work, or if you have uncommitted changes and cannot force.
Security analysis
CautionThe skill uses Bash with extensive permissions to run a cleanup script that performs git operations (remove worktree, checkout base branch). While the intended actions are safe and non-destructive, the broad Bash access poses a moderate risk if the script were to be modified or misused. No destructive or exfiltrating instructions are directly included.
- •Broad Bash access (Bash(bash:*)) could permit execution of arbitrary commands if the cleanup script is compromised.
Examples
I'm done with this worktree, please clean it up and switch back to main.Clean up the current worktree and checkout the develop branch.Force clean up this worktree even if there are uncommitted changes, but I want to keep the branch.name: worktree-cleanup description: Automatically cleanup the worktree and return to the base branch. Keeps local and remote branches intact. Check after creating PR or pushing. allowed-tools: Bash(git:), Bash(cd:), Bash(pwd:), Bash(bash:)
Worktree Cleanup
Automatically cleans up the worktree after development is complete.
Overview
This skill performs the following steps automatically:
- Detects the current worktree directory and branch
- Checks for uncommitted changes
- Removes the worktree
- Checks out the base branch (default: main)
Important: Local and remote branches are preserved (not deleted).
Usage
Basic Usage
# Run from within the worktree directory
bash scripts/worktree_cleanup.sh
Options
# Specify a base branch
bash scripts/worktree_cleanup.sh --base develop
# Skip confirmation prompt
bash scripts/worktree_cleanup.sh --yes
# Ignore uncommitted changes (not recommended)
bash scripts/worktree_cleanup.sh --force
Prerequisites
- Must be run from within a worktree directory
- All changes must be committed (or use the
--forceoption)
Error Handling
Uncommitted Changes Detected
The script will stop and prompt you to commit. You can force execution with --force, but this is not recommended.
Worktree Removal Failed
Manual removal instructions will be displayed.
Running Outside a Worktree
A warning is displayed and the process is aborted.
Details
See REFERENCE.md for internal processing flow, troubleshooting, and best practices.
Next.js App Router Expert
Development
A skill that turns Claude into a Next.js App Router expert.
README Generator
Development
Creates professional and comprehensive README.md files for your projects.
API Documentation Writer
Development
Generates comprehensive API documentation in OpenAPI/Swagger format.