cleanup
Installation
SKILL.md
Cleanup
Make the branch's diff as small as it can be while every observable behaviour stays identical. The bar is not "tidier" — it is "could this be written in half the lines with what the project already has?" The only behaviour change allowed is a real bug found on the way, reported as one.
1. Setup
- Read the project's agent instructions (
CLAUDE.md,AGENTS.md, …) and every rule file they index that the diff touches. They outrank this skill. - Compatibility code (shims, aliases, fallbacks, migrations) is owed only to consumers outside the repo — a published package, a public API, persisted data, a released app. Find out which exist.
- Pick
BASE, first match wins.git diff $BASEincludes uncommitted work. An argument overrides it (a ref becomesBASE) or narrows it (a path).- The branch has an open PR:
BASE=$(git merge-base HEAD origin/$(gh pr view --json baseRefName -q .baseRefName)). - The branch has commits ahead of the default branch:
BASE=$(git merge-base HEAD $(git rev-parse --abbrev-ref origin/HEAD)). - Only uncommitted changes:
BASE=HEAD. - None: say so and stop.
- The branch has an open PR:
git fetch -q origin
git diff --shortstat $BASE # the number to beat
git status --short # untracked files are part of the target