dart-branch-cleanup
Use this skill in Codex to run the DART dart-branch-cleanup workflow. The editable
workflow source lives in .claude/commands/; this file is its generated adapter
in the shared .agents/skills/ catalog.
Invocation
- Claude Code:
/dart-branch-cleanup <arguments>
- Codex:
$dart-branch-cleanup <arguments>
Treat the text after the skill name as $ARGUMENTS. When the workflow
references $1, $2, etc., map those to the positional values supplied by the
user.
Command Body
Analyze or clean branches: $ARGUMENTS
Required Reading
@AGENTS.md
@docs/onboarding/ci-cd.md
@docs/onboarding/contributing.md
Modes
analyze: inspect only, no deletions
action: prepare follow-up, or delete only after ownership/safety are clear
and the maintainer/user gives explicit approval for each local or remote
branch deletion
Default to analyze if the requested mode is ambiguous.
Workflow
git fetch --all --no-prune
- List stale remote-tracking refs without deleting them:
git remote prune origin --dry-run
If origin uses SSH and port 22 is unavailable, keep the check read-only
and use a temporary HTTPS rewrite instead of changing repository config:git -c url.https://github.com/.insteadOf=git@github.com: \
fetch --all --no-prune
git -c url.https://github.com/.insteadOf=git@github.com: \
remote prune origin --dry-run
To confirm that a remote PR branch was deleted without updating refs, query
GitHub directly over HTTPS:git ls-remote --heads https://github.com/dartsim/dart.git <BRANCH>
- Determine target branch, usually
origin/main.
- For each branch:
git rev-list --left-right --count <TARGET>...<BRANCH>
git log --format='%h %cs %s' <TARGET>..<BRANCH>
git diff --stat <TARGET>..<BRANCH>
git cherry -v <TARGET> <BRANCH>
- Before any explicitly approved local branch deletion, check whether the
branch is checked out by a linked worktree:
git worktree list --porcelain
git -C <WORKTREE> status --short --branch
Dirty linked worktrees must not be removed, detached, or reset during branch
cleanup. Only after explicit maintainer/user approval, switch that worktree
to a preservation branch at the same commit to free the obsolete branch name
before deleting the merged branch.
- The command
git branch --merged may not prove ancestry for PR branches
that landed through a squash or merge commit. Use the merged PR state plus
an empty tree diff or equivalent git cherry -v output as the deletion
signal; if the history relationship is unclear, keep the branch.
- Classify recommendations only; deleting a candidate requires explicit
maintainer/user approval:
ahead=0: safe deletion candidate
- equivalent commits already landed: deletion candidate
- no-PR branch whose fix may already be solved differently on the target:
confirm supersession with a focused A/B or content check before deciding;
superseded is a deletion candidate, otherwise keep or open a follow-up
- small, current, useful diff: keep or rebase into PR
- large or unclear diff: document follow-up before action
- Ask for explicit maintainer/user approval before pruning refs or deleting any
local or remote branch, even when ownership, branch purpose, and remote
impact look clear.
Output
- Branch summary with ahead/behind count and last commit date
- Useful commits or risks
- Recommendation: delete, keep, rebase, or needs follow-up
- Actions taken after explicit maintainer/user approval, if action mode was
explicitly requested
1---2name: dart-branch-cleanup3description: DART Branch Cleanup: analyze or clean stale repository branches4---56<!-- AUTO-GENERATED FILE - DO NOT EDIT MANUALLY -->7<!-- Source: .claude/commands/dart-branch-cleanup.md -->8<!-- Sync script: scripts/sync_ai_commands.py -->9<!-- Run `pixi run sync-ai-commands` to update -->1011# dart-branch-cleanup1213Use this skill in Codex to run the DART `dart-branch-cleanup` workflow. The editable14workflow source lives in `.claude/commands/`; this file is its generated adapter15in the shared `.agents/skills/` catalog.1617## Invocation1819- Claude Code: `/dart-branch-cleanup <arguments>`20- Codex: `$dart-branch-cleanup <arguments>`2122Treat the text after the skill name as `$ARGUMENTS`. When the workflow23references `$1`, `$2`, etc., map those to the positional values supplied by the24user.2526## Command Body2728Analyze or clean branches: $ARGUMENTS2930## Required Reading3132@AGENTS.md33@docs/onboarding/ci-cd.md34@docs/onboarding/contributing.md3536## Modes3738- `analyze`: inspect only, no deletions39- `action`: prepare follow-up, or delete only after ownership/safety are clear40 and the maintainer/user gives explicit approval for each local or remote41 branch deletion4243Default to `analyze` if the requested mode is ambiguous.4445## Workflow46471. `git fetch --all --no-prune`482. List stale remote-tracking refs without deleting them:49 ```bash50 git remote prune origin --dry-run51 ```52 If `origin` uses SSH and port 22 is unavailable, keep the check read-only53 and use a temporary HTTPS rewrite instead of changing repository config:54 ```bash55 git -c url.https://github.com/.insteadOf=git@github.com: \56 fetch --all --no-prune57 git -c url.https://github.com/.insteadOf=git@github.com: \58 remote prune origin --dry-run59 ```60 To confirm that a remote PR branch was deleted without updating refs, query61 GitHub directly over HTTPS:62 ```bash63 git ls-remote --heads https://github.com/dartsim/dart.git <BRANCH>64 ```653. Determine target branch, usually `origin/main`.664. For each branch:67 ```bash68 git rev-list --left-right --count <TARGET>...<BRANCH>69 git log --format='%h %cs %s' <TARGET>..<BRANCH>70 git diff --stat <TARGET>..<BRANCH>71 git cherry -v <TARGET> <BRANCH>72 ```735. Before any explicitly approved local branch deletion, check whether the74 branch is checked out by a linked worktree:75 ```bash76 git worktree list --porcelain77 git -C <WORKTREE> status --short --branch78 ```79 Dirty linked worktrees must not be removed, detached, or reset during branch80 cleanup. Only after explicit maintainer/user approval, switch that worktree81 to a preservation branch at the same commit to free the obsolete branch name82 before deleting the merged branch.836. The command `git branch --merged` may not prove ancestry for PR branches84 that landed through a squash or merge commit. Use the merged PR state plus85 an empty tree diff or equivalent `git cherry -v` output as the deletion86 signal; if the history relationship is unclear, keep the branch.877. Classify recommendations only; deleting a candidate requires explicit88 maintainer/user approval:89 - `ahead=0`: safe deletion candidate90 - equivalent commits already landed: deletion candidate91 - no-PR branch whose fix may already be solved differently on the target:92 confirm supersession with a focused A/B or content check before deciding;93 superseded is a deletion candidate, otherwise keep or open a follow-up94 - small, current, useful diff: keep or rebase into PR95 - large or unclear diff: document follow-up before action968. Ask for explicit maintainer/user approval before pruning refs or deleting any97 local or remote branch, even when ownership, branch purpose, and remote98 impact look clear.99100## Output101102- Branch summary with ahead/behind count and last commit date103- Useful commits or risks104- Recommendation: delete, keep, rebase, or needs follow-up105- Actions taken after explicit maintainer/user approval, if action mode was106 explicitly requested