external/ag-shared/prompts/skills/git-worktree-clean/SKILL.md
Clean up a worktree branch by fetching fresh state from origin and hard-resetting to a target branch.
/git-worktree-clean [branch]
Arguments:
branch (optional): Target branch to reset to. Default: origin/latestIf the user provides help as an argument:
# Check if we're in a git worktree
git rev-parse --is-inside-work-tree || exit 1
# Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: Uncommitted changes detected"
git status --short
fi
If uncommitted changes exist, STOP and ask user for confirmation before proceeding.
# Fetch latest from origin
git fetch origin
# Default to origin/latest if no argument provided
TARGET_BRANCH="${ARGUMENTS:-origin/latest}"
# Hard reset to target
git reset --hard "$TARGET_BRANCH"
# Show current state
git log --oneline -1
git status