rmwt
Remove a git worktree and clean up all associated resources.
Skill Path
Resolve the scripts directory once:
RMWT_SCRIPTS=$(python3 -c "import os; p='.claude/skills/rmwt/scripts'; print(os.path.abspath(p) if os.path.isdir(p) else os.path.expanduser('~/.agents/skills/rmwt/scripts'))")
Usage
/rmwt <name> — Remove worktree, branch, all handoff chat groups for that workspace, and all handoff database buckets for that project.
The <name> argument is required. If not provided, list worktrees and ask the user to pick one.
Workflow
-
Resolve the worktree. Run
git worktree listand find a worktree whose path contains<name>(case-insensitive). If no match, tell the user. If multiple matches, list them and ask the user to pick. -
Gather what will be cleaned up:
a. Worktree path — from
git worktree listoutput.b. Branch name — from
git worktree listoutput (shown in brackets).c. Handoff chat groups (all for workspace) — list all bot-owned groups tagged with the workspace (computed from worktree path):
python3 $RMWT_SCRIPTS/list_workspace_groups.py '<WORKTREE_PATH>'This MUST run with
dangerouslyDisableSandbox: truein Claude Code since it calls the Lark API. If handoff is not installed, this step is skipped.d. Handoff database directory — check if it exists:
python3 -c " import os project = '<WORKTREE_PATH>'.replace('/', '-') print(os.path.join(os.path.expanduser('~/.handoff/projects'), project)) "Then check whether that directory exists. If it exists, it may contain multiple bucket DBs (
default, named profiles,path-*). -
Safety checks — before showing the summary, check for uncommitted work:
a. Uncommitted changes — check if the worktree has any local changes:
git -C <WORKTREE_PATH> status --porcelainIf output is non-empty, warn the user: "This worktree has uncommitted changes."
b. Branch ahead of default branch — detect the default branch, then check if the branch has commits not merged:
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') git log ${DEFAULT_BRANCH}..<BRANCH_NAME> --onelineIf output is non-empty, warn the user: "This branch has N commit(s) not merged into <default_branch>."
c. Active handoff sessions in target project DBs — if
<PROJECT_HANDOFF_DIR>exists, inspect everyhandoff-data.dbfile under it and sumsessionsrow counts. If non-zero, warn the user that the target workspace still has active handoff sessions and removing it will disconnect them.Include warnings in the summary (step 4) only when they are material to the user's decision. Use
🚨only when there is real code-loss risk (for example unmerged commits or uncommitted work). If there is no code-loss risk, do not show warning signs; use a green check (for example✅) for safe status. -
Show summary and confirm with the user before proceeding:
Removing worktree
<name>:- Worktree:
<path> - Branch:
<branch> - Chat groups:
<N>found for workspace (or "none found" / "skipped — handoff not installed") - Handoff DB dir:
<project_handoff_dir>(or "none found")
Proceed?
- Worktree:
-
Execute cleanup in order:
a. Dissolve chat groups (if any found):
python3 $RMWT_SCRIPTS/dissolve_groups.py '<GROUPS_JSON>'This MUST run with
dangerouslyDisableSandbox: truein Claude Code since it calls the Lark API.b. Delete handoff project DB directory (if found):
rm -rf <PROJECT_HANDOFF_DIR>c. Remove worktree:
git worktree remove <WORKTREE_PATH>d. Delete branch:
git branch -d <BRANCH_NAME>If
-dfails (unmerged), tell the user and suggest-Dif they want to force-delete. Do NOT force-delete without explicit confirmation. -
Print summary of what was cleaned up.
Testing
Run the test suite to verify scripts work correctly:
python3 $RMWT_SCRIPTS/test_rmwt.py
The test suite verifies:
- Workspace ID calculation for different worktrees
- JSON output format from
list_workspace_groups.py - Critical: Workspace IDs are unique for different paths (prevents accidental deletion of wrong groups)
More from verneagent/tiny-skills
inscribe
Capture rules, conventions, or code style guidelines into documentation files. Use when the user says "inscribe", "learn", "remember this rule", "add convention", or wants to persist coding guidelines.
4lark-share
Share a knowledge insight or message with a team via Lark group chat webhook. Use when the user says "share", "lark-share", or wants to send a formatted message to a Lark group.
4multi-gh
Fix and standardize GitHub multi-account workflows with gh account switching, SSH host aliases, and safe remote setup. Use when creating repos, pushing code, or diagnosing GitHub auth mismatches across multiple identities.
2retro
Retrospective on mistakes or new conventions — analyze patterns, find root causes, and propose deterministic prevention (static checks > lint > tests > runtime > review > docs). Use when the user says "retro", "反省", "复盘", "怎么防", "how to prevent", or wants to enforce a new convention.
2wksp
Open a new iTerm2 tab with Claude in a worktree or folder, optionally entering handoff mode.
1netmap
Show all network interfaces, LAN neighbors, and Tailscale peers on the current machine. Use when the user asks about network status, neighbors, connected devices, or Tailscale peers.
1