Skip to main content

Merged Cleanup

@puddleworks/merged-cleanupv2026.11.11.1· MIT· 10d agoBEHAVIORSWORKFLOWSEXTENDSACCEPTED WARNINGS
01README

For merged PRs in the repository of the current directory, report whether each one's worktree and branches are safe to clean up (check), and clean up those that are (clean): remove the worktree, delete the local branch and origin's branch with a lease on the PR's head, and fast-forward main.

02Behaviors1
@puddleworks/merged-cleanupv2026.11.11.1merged_cleanup.ts

Resources

result(infinite)— Per PR: its number, title, verdict (clean, primary, dirty, locked, ahead, absent, open, closed, error), worktree, branch and a one-line reason; for clean, each step (remove worktree, delete local branch, delete origin branch, fast-forward main) as done, already done, skipped with why, or failed with the error; then a one-line summary, or "Nothing to clean up" when there is none.
03Workflows3
@puddleworks/merged-cleanup88a7ffe6-d77c-4df2-ad10-811d6da8b4ca

For merged PRs in the repository of the current directory, report whether each one's worktree and branches are safe to clean up (check), and clean up those that are (clean): remove the worktree, delete the local branch and origin's branch with a lease on the PR's head, and fast-forward main.

mainRun merged-cleanup once with the user's inputs.
1.runmerged-cleanup-model.run— Per PR: its number, title, verdict (clean, primary, dirty, locked, ahead, absent, open, closed, error), worktree, branch and a one-line reason; for clean, each step (remove worktree, delete local branch, delete origin branch, fast-forward main) as done, already done, skipped with why, or failed with the error; then a one-line summary, or "Nothing to clean up" when there is none.
@puddleworks/merged-cleanup-recipe381a1207-bf67-448f-8bbd-f61e714b3a15

Clean up after the merged PR a turn names ("22 is merged", "pr 22 is merged", "#22 merged"): remove its worktree, delete its branch locally and on origin, and fast-forward main, each only when it is safe. The puddlerouterRecipe tag is the recipe @puddleworks/recipes reads: the phrasing it matches (held to the whole turn), the data to show and how. It calls the same method as this workflow's one step, so running this workflow by hand does the same clean-up. clean writes, so the recipe asks once b

main
1.cleanmerged-cleanup-model.clean
@puddleworks/merged-cleanup-latest-recipe4872f7ae-4870-4e56-8f8c-421fc2ff2fb7

Clean up after a bare "merged": the latest 3 merged PRs that still have a worktree at their head, each only when it is safe. The puddlerouterRecipe tag is the recipe @puddleworks/recipes reads: the phrasing it matches (held to the whole turn), the data to show and how. It calls the same method as this workflow's one step, so running this workflow by hand does the same clean-up. clean writes, so the recipe asks once before it runs.

main
1.cleanmerged-cleanup-model.clean
04Extends2
@swamp/gitgit_cleanup.ts
fn cleanup_worktree_list()
List the repo's worktrees (read-only, via git worktree list --porcelain).
fn cleanup_branch_heads()
List each local branch and each branch on origin with its head (read-only: git for-each-ref and git ls-remote --heads origin).
fn cleanup_delete_branch()
Delete a local branch with git branch -d (never -D). Already gone is reported, not an error; git refusing (not merged) is an error.
fn cleanup_delete_remote_branch(expect: string)
Delete a branch on origin only while it is at the expected commit (git push --force-with-lease=<branch>:<expect> --delete). Already gone is reported; a branch that moved is an error.
ArgumentTypeDescription
expectstring

Resources

cleanupWorktrees(ephemeral)— The repo's worktrees: path, HEAD, branch and flags.
cleanupBranchHeads(ephemeral)— Each local branch and each branch on origin, with its head.
cleanupBranchDelete(ephemeral)— A local branch deleted with git branch -d, or already gone.
cleanupRemoteBranchDelete(ephemeral)— A branch deleted on origin with a lease on its expected head, or already gone.
@webframp/githubgithub_cleanup.ts
fn cleanup_merged_prs()
List a repo's merged PRs, newest merge first, with when each was merged (read-only: gh pr list --state merged).
fn cleanup_pull_request(number: number)
One PR's state, head commit and head branch name (read-only: gh pr view).
ArgumentTypeDescription
numbernumber

Resources

cleanupMergedPrs(ephemeral)— A repo's merged PRs, newest merge first, with merge times.
cleanupPullRequest(ephemeral)— One PR's state, head commit and head branch name.
05Stats
B
87 / 100
Downloads
3
Archive size
30.3 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Docs keep secrets in a vault1/1earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License2/2earned
  • Verified public repository0/2missing

07Platforms
08Labels