mma
Merge main into open PR branches.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- mma
- description
- Merge main into open PR branches.
- allowed-tools
- [ "Bash", "Read", "Edit", "Write", "Agent" ]
- user-invocable
- true
03 SKILL.md 正文
mma
Repo-wide fan-out of sync-pr-branch: instead
of resyncing one branch, resync every currently-open PR in the repo that passes memories/reviewing-prs.md's scope test
against main (and each PR's own remote), so a burst of merges into main
doesn't leave the rest of the queue stale and conflict-prone.
This is not a duplicate of sync-pr-branch — it's an orchestration layer on
top of it. The per-branch mechanics (fetch, merge origin/main, merge
origin/<branch>, resolve conflicts, run checks, push) are unchanged; only
sync-pr-branch owns that logic. Keep it that way — if the per-branch steps
ever need to change, fix them in sync-pr-branch and this skill inherits the
fix for free.
When this fires
- "merge main into all pr branches", "sync every open PR with main", "mma", "resync the whole queue with main".
- After a run of merges to
main(e.g. finishing anardia/giasweep) — proactively, even without being asked, since every remaining open PR just fell further behind.
The procedure
-
List every open PR in the repo (
mcp__github__list_pull_requests/gh pr list --json number,headRefName,author,assignees). Note each PR's number,headRefName,author, andassignees. Filter the list bymemories/reviewing-prs.md's scope test first, asardiastep 1 does (opened by or assigned to the invoking user, explicitly requested by name, or authored by the GitHub Actions app (github-actions)), and report the PRs dropped: a resync pushes a merge commit, which that memory forbids on any other PR. -
Check whether main is actually ahead before touching anything:
git fetch origin mainFor a PR whose
origin/mainis already an ancestor of the branch tip (git merge-base --is-ancestor origin/main <branch-tip>returns true), skip it — main is already incorporated; nothing to merge. -
Resync each PR branch, one at a time — do not parallelize the push step. This is the shared-runner exception in practice: several PRs is decomposable, but each push triggers that PR's own CI and
@claudereview bot on a runner the whole repo shares, and parallel pushes make per-PR status illegible and can race concurrency groups against each other (seegha's ownclaude-review-<PR>/cancel-in-progressnote for what that race looks like in practice). Work the queue serially, or cap concurrency low enough that no two pushes land in the same few seconds.For each PR branch, in its own worktree (never the shared main checkout — see the per-repo memory file for this repo's worktree conventions if it has one). Pass
-b <branch>so the worktree gets a real local branch instead of detached HEAD —sync-pr-branch's own step 1 checksgit branch --show-currentand halts if that's empty:git worktree add -b <branch> .claude/worktrees/pr-<N> origin/<branch>cddoesn't persist across separate tool calls — run subsequent commands with that path ((cd .claude/worktrees/pr-<N> && git ...), or an absolute path) rather than assuming a priorcdcarried over.Then run exactly the
sync-pr-branchprocedure against that branch: fetch, mergeorigin/main, mergeorigin/<branch>, resolve any conflicts (seeresolve-conflicts/rc), run the repo's pre-commit checks, push.Only merge
origin/mainand the PR's ownorigin/<branch>— never another open PR's branch. Cross-PR changes stay out of scope here, same assync-pr-branch's own note.Remove the worktree once that branch is done —
git worktree remove .claude/worktrees/pr-<N>— so they don't pile up across runs. Leave it in place only when step 4 left a real conflict unresolved and the PR needs a later resume. -
A real conflict blocks that one PR, not the sweep. If a merge needs real conflict resolution beyond a mechanical pick, resolve it inline when confident and small; when the resolution is ambiguous or architecturally significant, leave that PR's worktree in place (mid-merge is fine to pause on — don't force through it) and move to the next PR, then come back to it. Report which PRs needed real resolution versus which were a clean fast-forward-style merge with nothing to resolve.
-
A push can 403 in a session scoped to only its own harness-assigned branch (see
ai-config's own "Use the existing PR branch, not the harness-specified branch" note). When that happens, don't retry the plain push — it's a policy denial, not a transient failure. That same note's default fallback is to stack the merge as its own PR against the original branch, or ask the user directly — not to reach forgit push --force-with-leaseas a routine step. A force-push is destructive and needs the user's own live, per-instance authorization (see the top-level git-safety rules); don't bake it into this skill's default path even when a past session found the proxy permitted it — that was an environment-specific exception, not a standing grant. Surface the blocked PRs to the user rather than guessing at a workaround. -
Report a per-PR summary at the end: which PRs were already up to date, which merged clean and pushed, which needed conflict resolution (and whether that's done or still open), and which are blocked on something outside this skill's scope (a push restriction, an ambiguous conflict needing the user's call).
Notes
- You can parallelize the local fetch-and-merge groundwork (step 3's setup, before any push) within a single agent loop when the queue is large — but keep the pushes themselves sequential per step 3's shared-runner reasoning. This skill doesn't define a cross-agent coordination mechanism, so don't dispatch one background agent per PR and assume they'll serialize their pushes on their own; either push from a single loop, or add an explicit handoff (a queue, a lock file) before fanning the push step out across agents.
- This skill only touches branches with an open PR. A stale local
worktree left over from a merged PR isn't in scope — that's the
post-mergeskill's job. - If every open PR is already current with
main, say so and stop; nothing to do is a valid, common outcome right after this same skill last ran.
04 同仓库更多 Skills
wrap-up
End-of-session verification and UMS.
workaround-watcher
Watch upstream issue for fix.
wn
→ whats-next.
whats-next
Recommend concrete next step or action.
wait-for-results
Wait for pipeline/CI results.
wai
→ send-notes.