agentleFS
SantiagoVqzSantiagoVqz/claude-skills/skills/main-flow/cleanup/SKILL.md

cleanup

Skill2 starsChanged 2 months agoMITView on GitHub

Post-merge teardown for a landed spec: confirm the spec branch landed, verify the spec issue and its tickets closed, delete the local and remote branches, and leave the checkout on a refreshed trunk.

  • Commits and pushes

29 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use next, eval and 2 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.
  • VercelSkill

    next

    Next.js adapter for embedding emulators directly in a Next.js app via @emulators/adapter-next. Use when the user needs to embed emulators in Next.js, set up same-origin OAuth for Vercel preview deployments, create an emulate catch-all route handler, configure Auth.js/NextAuth with embedded emulators, add persistence to embedded emulators, or wrap next.config with withEmulate. Triggers include "Next.js emulator", "adapter-next", "embedded emulator", "same-origin OAuth", "Vercel preview", "createEmulateHandler", "withEmulate", or any task requiring emulators inside a Next.js app.

    Also in 4 projects that use this

  • qtzx06Skill

    eval

    Evaluate trained YOLO model accuracy with mAP metrics and per-class error analysis. Identifies failure cases for targeted improvement. Use after training.

    Also in 3 projects that use this

  • BlockSkill

    plan

    Draft a TDD, PRD, or lightweight plan in the conversation without committing it.

    Also in 5 projects that use this

  • genomewalkerSkill

    learn

    Learn from web sources, generate SKILL.md, and store key patterns in soul memory. Trigger keywords: learn, skill-gen, web-learn, documentation, tutorial.

    Also in 3 projects that use this

The file

Files
SKILL.md

cleanup — post-merge spec teardown

One spec = one branch off the trunk, landed by the human. Tickets are commits on that branch, closed by close-ticket as they land. Run this once per spec after the branch lands.

Trunk = the branch this repo merges into (develop on a git-flow repo, main otherwise). Default to the default branch (git symbolic-ref refs/remotes/origin/HEAD); a repo carrying both main and develop is running git-flow, so the trunk is develop. Teardown that hardcodes main on a develop repo leaves the checkout stale and the next branch off the wrong base.

Identify scope

  • Target from $ARGUMENTS: a spec branch, or a spec that maps to one. Else infer from context: the current branch, or the one you were just working on.
  • Spec branch: <type>/<spec-number>-<slug>, the spec's only branch, created by /dispatch or by hand.
  • Trunk: per the rule above; confirm with the user if ambiguous.

Completion: you can name the spec branch and the trunk before touching anything.

Gate: confirm the work landed

Nothing is deleted until the spec branch is on the trunk. A spec lands either through a PR or by a direct merge, so take whichever signal exists:

gh pr list --head <spec-branch> --state merged --json number,url,mergedAt   # if the spec went through a PR
git log <trunk> --oneline --grep '<spec-number>' | head                       # commits from the branch, on the trunk

(GitLab: glab mr list equivalents per the tracker doc.)

  • A merged PR, or the branch's commits present on the trunk: proceed.
  • Neither, or a PR still open: stop and say so. Squash-merges rewrite hashes and defeat both checks, so where the trunk was squashed, the user's confirmation that the branch landed is the gate. Only override on explicit user instruction, and say so in the report.

Verify the spec issue and its tickets closed

close-ticket closes each ticket as it commits, and /ship puts Closes #<spec> in the PR body, so this is normally a verification pass. That keyword fires only when the PR merges into the repository's default branch:

gh pr view <n> --json body --jq '.body | scan("[Cc]loses #[0-9]+")'
gh issue view <n> --json number,state          # for the spec and each ticket

List the spec's tickets from the tracker (sub-issues, or issues whose Parent names the spec; .scratch/<slug>/issues/*.md locally) so a ticket missing from the PR body is not missed.

  • Trunk is the default branch: the issues should already be closed. Verify rather than assume. A ticket the human finished by hand, or a PR body that lost a keyword, leaves that issue open silently.
  • Trunk is develop but the default branch is main: the keywords never fired; closing by hand here is the normal path.

Close anything still open, gh issue close <n> --reason completed, tickets first, then the spec, and name each one in the report. On a local markdown tracker: set every ticket file's Status to done, then mark the spec file done.

Completion: every ticket and the spec issue are closed, and the report says which closed by keyword and which by hand.

Teardown

You cannot delete a branch that a worktree has checked out. A spec branch lives in its own linked worktree (git worktree list), provisioned by scripts/provision.sh where the repo has one. Run this from the primary checkout; standing in the spec worktree, ExitWorktree first.

(cd <worktree> && scripts/provision.sh db drop)   # only if the script exists: drops the fork, if any, and the test database
git worktree remove <worktree>                     # refuses on uncommitted or untracked files: stop and surface it, never --force
git checkout <trunk> && git pull --ff-only
git branch -D <spec-branch>                    # -D: a squash-merge makes -d refuse; the gate above already proved it landed
git ls-remote --exit-code --heads origin <spec-branch> >/dev/null 2>&1 \
  && git push origin --delete <spec-branch> || echo "remote branch already gone"

A spec branch with no worktree skips the first two lines.

--ff-only errors on local divergence instead of forging a merge commit; surface that rather than papering over it. If the merged branch added a schema migration and the local dev DB never applied it, apply it now so the next session doesn't break on a missing column. Report failures, don't force-fix.

Report

Trunk · how the branch landed (merged PR, or commits on trunk) · tickets closed (N by keyword, M by hand, listed) · spec issue closed (by keyword or by hand) · worktree removed (path) or n/a · databases dropped (fork and test, test only, or n/a) · branches deleted (local / remote, or "remote already gone") · trunk refreshed (new HEAD) · migration applied or n/a. Call out anything skipped, PR still open, open tickets, dirty worktree, non-ff trunk, so nothing is silently left behind.

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.