Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .claude/skills/post-merge-cleanup/skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Post-Merge Cleanup

Run this after squash-merging a PR to clean up the local repo.

## Steps
Comment on lines +1 to +5

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This skill file doesn’t include the YAML frontmatter metadata (e.g., description, argument-hint, allowed-tools) that the other skill in .claude/skills/ uses. Without it, tooling that indexes/validates skills may not pick up the skill consistently; consider adding a frontmatter block consistent with .claude/skills/aurelio-review-pr/skill.md.

Copilot uses AI. Check for mistakes.

1. Switch to main and pull latest:
```bash
git checkout main && git pull
```

2. Prune remote tracking branches that no longer exist on the remote:
```bash
git fetch --prune
```

3. Delete local branches whose remote tracking branch is gone:
```bash
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of xargs -r is not portable as it's a GNU extension and is not available on systems like macOS. This can cause the script to fail when there are no branches to delete. A more portable way to prevent xargs from running the command on empty input is to use the -I flag. This change will make the skill more robust and usable across different developer environments.

Suggested change
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -I {} git branch -D {}

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch-deletion pipeline can break when the currently checked-out branch is one of the “gone” branches: git branch -vv prefixes the current branch with *, so awk '{print $1}' yields * instead of the branch name. This can cause the deletion step to fail or skip the intended branch; adjust the parsing to extract the actual branch name even for the current branch (or use a porcelain/format-based command like for-each-ref/git branch --format).

Suggested change
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D
git for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D

Copilot uses AI. Check for mistakes.

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xargs -r is a GNU extension and will fail on macOS/BSD xargs. Since this is a cross-platform repo workflow, consider rewriting the command to avoid -r (e.g., a shell loop that only runs git branch -d/-D when there are matches) so the step works consistently.

Suggested change
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | while read -r branch; do git branch -D "$branch"; done

Copilot uses AI. Check for mistakes.
```
If no gone branches exist, skip this step.
Comment on lines +19 to +21

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step force-deletes branches with git branch -D, which can discard local-only commits even if the remote tracking branch is gone (e.g., someone deleted the remote branch before you pushed). To reduce the chance of accidental data loss, consider using a safe delete first (-d) and only instructing -D after confirming the branch can be dropped.

Suggested change
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -D
```
If no gone branches exist, skip this step.
git branch -vv | grep '\[.*: gone\]' | awk '{print $1}' | xargs -r git branch -d

If git branch -d refuses to delete a branch, inspect it first; only use git branch -D <branch> if you're sure its commits can be discarded. If no gone branches exist, skip this step.

Copilot uses AI. Check for mistakes.

4. Check for any remaining non-main local branches and report them. Do NOT delete branches that still have a remote — only report them.

5. Confirm the workspace is clean with `git status`.