# Cleaning-Up Skill (Vanilla Reference) Tear down the throwaway workspace after a task's pull request has merged, so nothing lingers. > Vanilla reference skill — adapt the placeholders to your project. ## When this runs **After the PR merges.** This is the final step of a task's lifecycle: the work is reviewed, approved, and landed on the base branch. Only then do you dismantle the disposable workspace that the task was built in. Running earlier risks deleting the only copy of work that hasn't shipped yet. ## What gets cleaned up A task that ran in an isolated workspace typically leaves three kinds of residue: 1. A **git worktree** — a throwaway checkout at `` used to keep the task's changes separate from the main checkout. 2. A **local branch** — ``, created for the task and now merged. 3. A **plan document** — under `~/plans//`, describing the work that was just completed. The goal is to return the environment to a clean state: no orphaned worktrees, no stale merged branches, no active plan sitting in the "to do" area. ## Method ### 1. Verify the merge actually landed Before deleting anything local, confirm the work reached the base branch. Deleting a worktree or branch that hasn't merged destroys the only copy of that work. - Fetch the latest state of the base branch. - Confirm the task's commits are present on the base branch (the PR shows as merged, or the commits are reachable from the base branch tip). - If the merge did **not** land, stop. Do not delete anything. Resolve the merge first. ### 2. Confirm you're removing the right worktree Path-scoped operations only. Never run a whole-tree destructive command in a shared checkout. - List the existing worktrees and confirm `` is the one tied to ``. - Confirm the main checkout is a *different* path — you are removing the throwaway workspace, not the primary one. - Only after this confirmation do you proceed to removal. ### 3. Remove the worktree - Remove the worktree at `` using a path-scoped worktree removal. - Scope every command to that path. Never issue a repository-wide reset, clean, or checkout that could touch a sibling's uncommitted work in a shared checkout. ### 4. Delete the local branch - Delete the local branch `` now that its commits live on the base branch. - Because step 1 confirmed the merge, a normal (non-forced) delete is expected to succeed. If it reports the branch as unmerged, stop and re-verify — do not force-delete over unverified work. ### 5. Prune stale worktree metadata - Prune worktree bookkeeping so the repository forgets administrative entries for worktrees whose directories are already gone. - This clears leftover references without touching any live checkout. ### 6. Archive the plan and record status - Move the plan document out of the active area (`~/plans//`) into a "done" / archive location. - Record the final status of the task: what landed, and that the workspace has been cleaned up. ## Guardrails - **Path-scoped only.** Every destructive operation targets `` or `` explicitly — never the whole tree, never a bare reset/clean in shared space. - **Merge before delete.** Never delete a local branch or worktree until the merge is verified on the base branch. - **Leave the main checkout alone.** The primary checkout stays untouched and remains on its normal branch. You are tearing down the disposable workspace, not the home base. - **Confirm before removing.** Identify the exact worktree and branch before deletion; a wrong path or name is unrecoverable. ## Done when - The worktree at `` is gone. - The local branch `` is deleted. - Stale worktree metadata is pruned. - The plan is archived and the final status recorded. - The main checkout is untouched and on its normal branch.