git-worktree-clean

📁 ag-grid/ag-charts 📅 Today
1
总安装量
1
周安装量
#76140
全站排名
安装命令
npx skills add https://github.com/ag-grid/ag-charts --skill git-worktree-clean

Agent 安装分布

amp 1
cline 1
opencode 1
cursor 1
continue 1
kimi-cli 1

Skill 文档

Worktree Clean

Clean up a worktree branch by fetching fresh state from origin and hard-resetting to a target branch.

Usage

/worktree-clean [branch]

Arguments:

  • branch (optional): Target branch to reset to. Default: origin/latest

Help

If the user provides help as an argument:

  • Explain how to use this command
  • Explain prerequisites
  • DO NOT proceed, exit immediately

Prerequisites

  1. Git CLI must be available
  2. Working directory should be a git worktree (not the main repository)
  3. No critical uncommitted changes – warn user if dirty

Workflow

STEP 1: Verify Environment

# 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.

STEP 2: Fetch Fresh State

# Fetch latest from origin
git fetch origin

STEP 3: Hard Reset to Target

# Default to origin/latest if no argument provided
TARGET_BRANCH="${ARGUMENTS:-origin/latest}"

# Hard reset to target
git reset --hard "$TARGET_BRANCH"

STEP 4: Verify Clean State

# Show current state
git log --oneline -1
git status

Definition of Done

  • Working tree is clean
  • HEAD matches target branch
  • User informed of reset result