agentleFS
alex-macraalex-macra/claude-codex-skills-assembly/skills/post-merge-cleanup/SKILL.md

post-merge-cleanup

Skill1 starsChanged 3 months agoMITView on GitHub

Verify a merged PR and remove its clean, idle task worktree. Use for post-merge cleanup.

5 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

2 rules. 0 are common, 1 is distinctive, and 1 is 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.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read repository rules. Identify the exact repository, PR, base branch, PR head branch and task worktree from the user's request or …

    line 16
  2. Very specific:

    Run git worktree remove <exact path> from another checkout, without --force.

    line 20

“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

Post merge cleanup

An explicit cleanup request or a standing user or repository rule to run the cleaner when a known PR is reported merged authorizes removing only its identified task worktree after proving the merge. A generic PR handoff or request to merge alone does not authorize removal. On Claude Code, dispatch the cleaner agent; on Codex, dispatch a cleaner subagent and tell it to read this SKILL.md completely. If no subagent is available, take this role in the current session. The cleaner never merges a PR.

  1. Read repository rules. Identify the exact repository, PR, base branch, PR head branch and task worktree from the user's request or established handoff. If more than one candidate fits, stop and report ambiguity. Inspect git status --short --branch, git worktree list --porcelain, and the worktree path before mutation.
  2. Resolve the selected local Git remote's canonical repository identity. Query the PR with explicit repository selection independent of GH_REPO or other ambient defaults, and require its returned repository identity to match that remote. Require the PR's actual MERGED state, base branch, head branch, full head commit ID, and full merge commit ID. Fetch only that base ref from the verified remote and require the merge commit reachable from it. Never infer a merge from a closed PR, branch deletion, or the user's statement. If identity, merge metadata, or the matching ref cannot be verified, stop.
  3. Match one non-primary linked worktree's exact canonical path and branch from git worktree list --porcelain to that PR head. Require its HEAD to equal the PR's full head commit ID; detached, moved, duplicate, and branchless cases stop. Never select by directory-name resemblance or clean up the primary checkout.
  4. In that exact worktree, require empty git status --porcelain=v1 --untracked-files=all and empty git status --porcelain=v1 --ignored=matching --untracked-files=all. Inspect its worktree lock and live processes' current directories, open files, command lines, executables, and mapped files (lsof, ps, or /proc as available). Resolve paths before comparing. If any process view is unavailable, fails, or leaves worktree use uncertain, skip removal. Recheck identity, status, lock, and use immediately before removal.
  5. Run git worktree remove <exact path> from another checkout, without --force. Do not prune broadly or delete branches. Stop on any failure; never retry with a stronger command. Preserve dirty, ignored, locked, active, primary, and unrelated worktrees.
  6. Report the PR URL, merge commit, fetched base ref and tip, removed path or precise skip reason, and primary checkout status. For a tracked task, use its tracker adapter under repository instructions and copy every reconciliation line; never hand-edit its ledger. Do not pull, merge, rebase, reset, stash, push, delete branches, or update protected branches as part of cleanup.

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.