agentleFS
SantiagoVqzSantiagoVqz/claude-skills/skills/4-ship/cleanup/SKILL.md

cleanup

Skill2 starsChanged 12 days agoMITView on GitHub

Tear down a merged branch: check the merged PR, close the issues, remove the worktree and branches, and refresh the trunk.

  • Commits and pushes

74 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use chips, react-query-best-practices and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • udecodeSkill

    chips

    Run the project's suggested-task ledger, the chips. /chips alone brings this session's open tasks up to date: it applies what the ledger helper says, settles stale and split tasks, cards what can start and reports the board, and /chips all also takes the ship-list tasks and the ones no live session owns, and merges duplicate tasks across the board. Use for /chips, /chips offer, start or drop, \"what chips are open\", \"suggest a task for X\", \"update the chips\", \"clean up the chips\", \"which chips are stale\", \"is this chip still worth doing\", \"merge duplicate chips\", at the last hand-back of a run that offered a task, and whenever pstack would file a tracked issue, a follow-up, a reflect Backlog item or an out-of-band PR.

    Also in 3 projects that use this

  • bibektimilsina00Skill

    react-query-best-practices

    Audit and fix React Query usage in apps/web — enforce query key factories, signal forwarding, staleTime, and proper mutation patterns. Use when reviewing or fixing server-state code.

    Also in 3 projects that use this

  • bibektimilsina00Skill

    you-might-not-need-a-callback

    Analyze and fix useCallback anti-patterns in your code

    Also in 3 projects that use this

  • Scylla23Skill

    redo

    Re-run the last routed task one model tier up (haiku → sonnet → opus → fable). User-invoked escalation when the previous result missed. Pass --dry-run to preview without running.

    Also in 3 projects that use this

  • Aetheria-Labs1Skill

    plan-page

    Plan one storefront page from strategy through final copy, section order, proof, offers, template direction, responsive layout, and production asset requirements. Stops at an approved execution-ready specification.

    Also in 3 projects that use this

  • SocialKit-APISkill

    video-transcripts

    Extract transcripts from social videos through SocialKit across YouTube, TikTok, Instagram, Facebook, X/Twitter, LinkedIn, and direct video file URLs. Use when the user asks to transcribe, get captions or subtitles, pull the spoken text, or read what a video says, including one video or many at once. Returns full text plus timestamped segments. Not for posting, private accounts, or unrelated website scraping.

    Also in 3 projects that use this

  • +3 more from bibektimilsina00

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 62 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    An open PR: stop, and give its URL.

    line 25
  2. Very specific:

    No PR: stop. The next step is /ship.

    line 26
  3. Very specific:

    Read the closing line of the PR body.

    line 32
  4. Very specific:

    Call the Skill tool with worktree to remove the worktree of the branch, also when you know its steps.

    line 53
  5. Very specific:

    Run git ls-remote --exit-code --heads origin <branch>.

    line 59
  6. Very specific:

    When it does not fast-forward, list the local-only commits with git log --oneline origin/<trunk>..<trunk>.

    line 67
  7. Distinctive:

    Stop: keep everything as it is.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 62 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Cleanup

/cleanup runs after the user merges a PR from /ship. It ends with the issues in the right state, the worktree and branches gone, and the primary checkout on the latest trunk. It deletes nothing before the gate passes.

Run it from the primary checkout. When the session is in a worktree, call ExitWorktree with keep first. When ExitWorktree says that no session is active, the session went into the worktree with cd: run cd to the first path of git worktree list, which is the primary checkout. When the session is still not in the primary checkout, stop, and tell the user to run /cleanup in a session there.

1. Find

The target is the argument, or the branch you just shipped. Find the trunk as the worktree skill does.

Completion: you have the branch, its issue and the trunk.

2. Gate

Run gh pr list --head <branch> --state all --json number,url,state,body.

  • A merged PR: go on. Read its merge commit with gh pr view <pr> --json mergeCommit. When that commit has two parents (git cat-file -p <commit> after a fetch), the PR merged with a merge commit. When the merge line of the PR body names another method, name the difference in the report, and name the repo setting that blocks it, gh repo edit --enable-merge-commit=false.
  • An open PR: stop, and give its URL.
  • No PR: stop. The next step is /ship.

Completion: the branch has a merged PR.

3. Issues

Read the closing line of the PR body. Use docs/agents/tracker.md, or NO-SETUP.md in the folder of the setup-skills skill. A PR with no closing line has no issue to change.

  • Closes #<n>: when the issue is still open, close it as tracker.md says. When it is a ticket and every ticket of its spec is closed now, close the spec too. The keyword fires only on a merge into the default branch, so when the trunk is not the default branch, a close by hand is the normal path.
  • Refs #<n>: the fix added instrumentation, and the cause is not confirmed. The issue stays open. Name in the report what confirms the cause.

Completion: each issue is in the state that the closing line gives, and you know which closed by keyword and which by hand.

4. Servers

Stop each dev server and background task that runs from the worktree. Check the background tasks of this session, and each process whose working directory is in the worktree: lsof -d cwd lists them. A task can survive a /clear, so look also when you think this session started none.

In a repo with a .xcodeproj or a .xcworkspace, also shut down the simulators, because their working directory is not in the worktree. When pgrep xcodebuild finds no other build, run xcrun simctl shutdown all, then xcrun simctl --set testing shutdown all. The second one fails harmlessly when no test clone exists.

Then delete the test clones, which are disposable: Xcode leaves them on disk, and one session found 5 clone folders with one booted. Record the size with du -sh ~/Library/Developer/XCTestDevices, then run xcrun simctl --set testing delete all.

Leave Claude Code's own processes, which are the session shell, caffeinate and the MCP servers. Then clear what this session left: close each browser page that it opened, and delete each partial install and temp file that it made. Name each one in the report.

Completion: no process other than Claude Code's has its working directory in the worktree, and no simulator is booted unless another build uses it.

5. Worktree

Call the Skill tool with worktree to remove the worktree of the branch, also when you know its steps. When the primary checkout has the branch and no worktree has it, run git switch <trunk>, then git branch -D <branch>, and skip worktree.

Completion: git worktree list does not show the branch, and the local branch is gone.

6. Remote branch

Run git ls-remote --exit-code --heads origin <branch>. When the branch is there, run git push origin --delete <branch>. GitHub can delete it on merge, so a missing branch is normal.

Completion: origin does not have the branch.

7. Trunk

Record the trunk head with git rev-parse HEAD. Run git pull --ff-only.

When it does not fast-forward, list the local-only commits with git log --oneline origin/<trunk>..<trunk>. Ask with the question tool:

  • Move to a branch (recommended): git branch local/<trunk>-<date> <trunk>, then git reset --keep origin/<trunk>. The commits stay on the branch, and the user ships them with a PR.
  • Rebase and push: git rebase origin/<trunk>, then git push origin <trunk>. Only for a repo where the user pushes to the trunk.
  • Stop: keep everything as it is.

Completion: the primary checkout is on the latest trunk, or the user picked Stop.

8. Migrations

Find the migration folder in AGENTS.md, or in the config of the migration tool, such as script_location in alembic.ini. Run git diff --name-only <old head> HEAD -- <folder>. When it shows new migrations, run the migrate command from AGENTS.md or package.json on the trunk dev database. When the repo has no such command, name the migrations in the report.

Completion: the trunk dev database has each new migration, or the report names them.

Report

PR · merge method, when it differs from the merge line of the PR · issues closed by keyword, by hand, or left open · servers stopped · session leftovers cleared · size of the test clones deleted · worktree removed · branches deleted · trunk head · migrations applied.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.