π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π docs(skill): record the approved worktree deletion policy and the squash-merge rule (#20277)
Arvin Xud622db5e4fcf
diff --git a/.agents/skills/cleanup-git-worktrees/SKILL.md b/.agents/skills/cleanup-git-worktrees/SKILL.mdindex 480e1f44af5..ae7067122f0 100644--- a/.agents/skills/cleanup-git-worktrees/SKILL.md+++ b/.agents/skills/cleanup-git-worktrees/SKILL.md@@ -5,7 +5,7 @@ description: 'Use for stale-worktree, Git registration and branch audits. Manage# Cleanup Git Worktrees-Use the bundled script to make classification deterministic. Treat cleanup as a destructive action: audit first, show the exact candidates grouped by why they are deletable, and obtain one explicit approval before applying deletion unless the user's current request already names the exact targets. Aim for a single approval round-trip, not a per-item Q&A.+Use the bundled script to make classification deterministic. Treat cleanup as a destructive action: audit first, show the exact candidates grouped by why they are deletable, and obtain one explicit approval before applying deletion unless the user's current request already names the exact targets. Aim for a single approval round-trip, not a per-item Q\&A.## Workflow@@ -22,22 +22,22 @@ Use the bundled script to make classification deterministic. Treat cleanup as a2. Interpret classifications:- | Classification | Meaning | Action |- | --- | --- | --- |- | `protected-branch` | `main`, `canary`, or the base ref | never |- | `protect-current` | the worktree running the command | never |- | `protect-dirty` | tracked modifications, or untracked files outside the noise regex | keep; list the files |- | `candidate-merged` | tip is an ancestor of the base | delete |- | `candidate-pr-merged` | PR state MERGED and local tip == PR head SHA | delete |- | `candidate-pr-closed` | PR CLOSED and tip == PR head or nothing unpushed | delete |- | `candidate-gone` | upstream pruned and nothing unpushed | delete after confirming PR state |- | `candidate-stale` | older than `--stale-days`, clean, nothing unpushed | delete |- | `review-pr-merged-ahead` | PR merged but local tip has extra commits | check the extra commits by subject (below) |- | `review-gone-unpushed` | upstream pruned but local-only commits exist | keep; deleting loses work |- | `review-no-upstream` | no upstream, not merged | keep unless the user names it |- | `review-detached` | detached HEAD worktree | keep; show its dirty files |- | `broken-registration(...)` | registration whose gitdir is gone | see below |- | `active` | everything else | keep |+ | Classification | Meaning | Action |+ | -------------------------- | ----------------------------------------------------------------- | ------------------------------------------ |+ | `protected-branch` | `main`, `canary`, or the base ref | never |+ | `protect-current` | the worktree running the command | never |+ | `protect-dirty` | tracked modifications, or untracked files outside the noise regex | keep; list the files |+ | `candidate-merged` | tip is an ancestor of the base | delete |+ | `candidate-pr-merged` | PR state MERGED and local tip == PR head SHA | delete |+ | `candidate-pr-closed` | PR CLOSED and tip == PR head or nothing unpushed | delete |+ | `candidate-gone` | upstream pruned and nothing unpushed | delete after confirming PR state |+ | `candidate-stale` | older than `--stale-days`, clean, nothing unpushed | delete |+ | `review-pr-merged-ahead` | PR merged but local tip has extra commits | check the extra commits by subject (below) |+ | `review-gone-unpushed` | upstream pruned but local-only commits exist | keep; deleting loses work |+ | `review-no-upstream` | no upstream, not merged | keep unless the user names it |+ | `review-detached` | detached HEAD worktree | keep; show its dirty files |+ | `broken-registration(...)` | registration whose gitdir is gone | see below |+ | `active` | everything else | keep |Columns worth reading: `dirty` (real dirt), `noise` (ignorable untracked), `age_days`, `unpushed` (commits no remote ref reaches), `pr` / `pr_state` / `tip_eq_pr`.@@ -75,6 +75,19 @@ Squash and rebase merges leave no ancestry, so `git merge-base --is-ancestor` anZero `unpushed` means every local commit is reachable from some remote ref, so deleting the local branch loses nothing even when the PR is still OPEN; the user has approved deleting such branches once they pass the stale threshold.+## Repo-approved deletion policy++The repository owner has approved the following for this repo, so a cleanup run does not need to re-ask per item. It is the sanctioned exception to the safety rules below; state it in the report and say plainly whenever uncommitted work is being discarded.++- **Dirt equal to the base is not dirt.** A tracked file listed as modified whose content is byte-identical to the base (`git diff --quiet <base> -- <file>`) is stale residue of a branch that is simply behind. When presenting, do not count it as a real change: list such files in their own group so the genuine modifications stay visible.+- **Merged / closed PR branches are disposable together with their local commits.** When a branch's PR is `MERGED` or `CLOSED`, its worktree and local branch may be removed even when `unpushed > 0` or the tree is dirty. Record every branch SHA before deleting (reflog keeps them \~90 days) and state in the report that uncommitted edits are not recoverable.+- **Local scratch does not block removal.** Untracked `*.probe.test.ts`, spike scripts under `scripts/`, and untracked screenshots (`*.png`) are disposable; do not raise them as blockers.+- Still never delete: `main`, `canary`, the base ref, and the worktree running the command. A branch whose PR is **OPEN** is kept while it still holds local-only work (dirty files or `unpushed > 0`); a clean, fully-pushed branch with an open PR is the redundant local copy the stale rule already covers.++**Proving a merge when the repo squash-merges.** This repo squash-merges, so a landed PR leaves the squash commit on the base but none of the branch's own commits. Searching the base for an individual commit subject therefore fails for every squashed branch β do not read that as "unmerged". Decide `review-pr-merged-ahead` by the PR's state plus commit dates instead: if the branch tip is not newer than `mergedAt`, the branch is pure pre-merge history whose content is already on the base (verify the PR's `mergeCommit` with `git merge-base --is-ancestor <mergeCommit> origin/canary`). Only commits dated after `mergedAt` are candidate unmerged work β keep the branch and list them.++The bundled script still refuses anything outside `candidate-*`, so these removals are done manually: `wt_path=$(git worktree list --porcelain β¦)` β record `git rev-parse <branch>` β `git worktree remove --force` β `git branch -D`. Keep the run in the background; removals that hold `node_modules` take minutes each.+## Broken registrations`git worktree list --porcelain` marks an entry `prunable` when its gitdir file points nowhere (typically after a partial removal). The audit reports these as `broken-registration(directory-present|missing; reason)` instead of crashing on them.@@ -84,8 +97,8 @@ Zero `unpushed` means every local commit is reachable from some remote ref, so d## Safety rules-- Never discard dirty worktrees merely because their branch is merged, `[gone]`, or old. Noise-only dirt (the `--noise` regex) does not count.-- Never delete a branch with `unpushed > 0` through this script; list it and let the user decide.+- Never discard dirty worktrees merely because their branch is merged, `[gone]`, or old; noise-only dirt (the `--noise` regex) does not count. The one exception is a worktree whose branch's PR is `MERGED` or `CLOSED`, per the repo-approved deletion policy above.+- Never delete a branch with `unpushed > 0` through this script; list it and let the user decide. Same exception: a `MERGED`/`CLOSED` PR branch may be removed under the owner's standing approval, with its SHA recorded first.- Never use recursive deletion on a registered worktree. If Git partially removes a directory, stop and inspect the exact path before deciding how to recover.- Never delete `main`, `canary`, or the base branch.- Preserve unrelated user changes and concurrent worktrees. The user's other sessions may be working in them.