agentleFS
iha2iha2/superlite/skills/merged/SKILL.md

merged

Skill311 starsChanged 18 days agoMITView on GitHub

Use when the user says a pull request was merged, to clean up its session, branch and local main

  • Deletes or force-pushes

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep only PRs whose headRepositoryOwner is this repo's owner (gh repo view --json owner): --head also matches same-named fork branches.

    line 24
  2. Distinctive:

    Look up the branch's checkout in git worktree list --porcelain.

    line 35
  3. Very specific:

    Delete a branch gh has not reported as merged, or one with commits the PR does not hold, unless the user chose "Discard it".

    line 63

“Common” is measured: kept by at least 6 in 10 of the 3 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

Merged

The PR is merged on the remote. Bring the local repo up to date and remove what the PR left behind. Only existing tools, in this order; never push, never touch the remote branch. Nothing here is guessed: each step checks before it changes anything, and any check that fails stops the flow with nothing changed after it.

1. Find the branch

Take the first that works:

  • the argument: a session slug, a branch name, or a PR number (gh pr view <n> --json headRefName). Resolve a slug through bash <skill-dir>/../swarm/scripts/superlite-cli session status --json or <hub>/.superlite/session-store/<slug>/session.json and use its recorded branch; only fall back to superlite/sessions/<slug> when no session metadata exists.
  • the current branch, when it is not the base branch
  • otherwise list live sessions, archived session manifests and local branches, and ask once (one AskUserQuestion) which one was merged

Find the base branch the way superlite:shipping step 2 does. Retain the slug resolved from an argument. For a branch selected by argument, PR, current checkout or the user's answer, find the slug by matching its branch in live session rows or archived <hub>/.superlite/session-store/*/session.json manifests. Only infer the slug from the superlite/sessions/ prefix when no matching metadata exists; otherwise a branch without matching metadata or that prefix has no slug.

2. Confirm the merge

gh pr list --head <branch> --state all --json number,state,url,headRefOid,headRepositoryOwner,mergeCommit,baseRefName

Keep only PRs whose headRepositoryOwner is this repo's owner (gh repo view --json owner): --head also matches same-named fork branches. The PR with the highest number decides.

  • No gh, not signed in, or no PR for the branch: say so and stop. Do not fall back to git branch --merged; a squash merge never shows there.
  • OPEN: say it is still open and stop.
  • CLOSED, not merged: ask once, "Keep the branch" / "Discard it". On keep, stop. On discard, skip the head check below and step 4: run steps 3, 5 and 6.
  • MERGED: use its baseRefName as the base and go on.

Then check the local branch holds nothing the PR did not. If git cat-file -e <headRefOid> fails, run git fetch origin pull/<number>/head first; if it still fails, stop. Then git rev-parse --verify refs/heads/<branch> must equal headRefOid, or git log --oneline <headRefOid>..refs/heads/<branch> must exit 0 and print nothing. If it lists commits or exits non-zero, name them (or the error) and stop: they were never in the PR.

3. Leave the branch

Look up the branch's checkout in git worktree list --porcelain.

  • Its checkout has uncommitted work (git status --short there is not empty), its session row in session status reports stash:yes, or git rev-parse -q --verify refs/superlite/wip/<slug> finds parked work: that work is not in the PR. Name it and ask once, "Stop and keep it" / "Discard it". On stop, stop.
  • The session is still listed in session status: first leave its worktree if you are in one (ExitWorktree with action: "keep" under Claude Code, else cd to the main checkout), then from the main checkout run bash <skill-dir>/../swarm/scripts/superlite-cli session close --slug <slug> --keep-branch. It puts the host back on the base branch and removes a worktree superlite cut. On an ASK line (exit 4, nothing changed), ask exactly what its ask: line says and do what the chosen on ...: line says. A Claude-created worktree is not removed by close: end it with ExitWorktree remove, as superlite:shipping step 7 says.
  • No session, but the branch is checked out: if the user chose to discard its uncommitted work above, first run git reset --hard and git clean -fd in that checkout while it is still on the feature branch. Then switch that checkout to the base branch (git switch <base>), or leave a linked worktree the way step 7 of superlite:shipping does.

4. Update the base branch

git fetch --prune origin, then fast-forward only:

  • The base is checked out in a clean, unoccupied checkout (session status lists no session hosted there, even one whose run is finished): git merge --ff-only origin/<base> there. If another session hosts that checkout, report it and skip this step without changing its files.
  • The base is not checked out anywhere: git fetch origin <base>:<base>.
  • The base is checked out with uncommitted work, or the fast-forward fails (local base has commits origin does not): report it and skip this step. Never merge, rebase or reset the base.

5. Delete the branch

  • With a slug (a listed or archived superlite session): bash <skill-dir>/../swarm/scripts/superlite-cli session discard --slug <slug>. It drops the session's store and parked work ref, and the branch unless superlite adopted it.
  • Then, or without a slug: if git rev-parse -q --verify refs/heads/<branch> still finds it, git branch -D <branch>. -D is safe here only because step 2 proved the branch is in the merged PR, or the user chose "Discard it"; never use it otherwise.

The remote branch is not touched. GitHub's "delete branch on merge" or the user removes it.

6. Report

Run bash <skill-dir>/../swarm/scripts/superlite-cli session status. Print one line per step: PR number and URL, merge commit, the session closed, base <old sha>..<new sha> (or why it was skipped), the branch deleted. Name each session now behind the base (main:+N); each one is offered the update in its own chat, nothing is synced here.

Never

  • Push, delete a remote branch, or open, close or merge a PR.
  • Delete a branch gh has not reported as merged, or one with commits the PR does not hold, unless the user chose "Discard it".
  • Merge, rebase or reset the base branch.
  • Discard uncommitted or parked work without the user's answer.

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.