merging-pull-requests
Skill21 starsChanged 3 months agoApache-2.0View on GitHub
Merge a Kivgraph PR only after current-head CI and a clean CodeRabbit review; then delete its exact head branch. Use for explicit merge requests only.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- benchmarks/AGENTS.mdAGENTS.md
- internal/AGENTS.mdAGENTS.md
- landing/AGENTS.mdAGENTS.md
- ts-worker/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- benchmarks/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- internal/CLAUDE.mdCLAUDE.md
- landing/CLAUDE.mdCLAUDE.md
- ts-worker/CLAUDE.mdCLAUDE.md
- web/CLAUDE.mdCLAUDE.md
- adding-a-languageSkill
- autofixSkill
- code-reviewSkill
- opening-pull-requestsSkill
- publishing-releasesSkill
- running-testsSkill
- writing-blog-postsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 12
Do not use this skill for requests to prepare a PR, check whether it is ready, or enable auto-merge.
- Distinctive: line 18
Treat the PR as review-ready only when the intended changes are committed and pushed, relevant local gates have passed, required GitHub …
- Distinctive: line 26
Stop if the target is ambiguous.
- Distinctive: line 31
Check required status checks and review state.
- Distinctive: line 40
Before waiting, record the current head SHA and a snapshot of all existing CodeRabbit reviews, inline comments, issue comments, and thread …
- Distinctive: line 47
Wait until the CodeRabbit check or review for that exact SHA has completed.
- Distinctive: line 57
Check existing findings as well.
- Distinctive: line 71
When using the GitHub CLI, the relevant read-only API surfaces are equivalent to:
- Very specific: line 80
Use structured fields such as commit_id, user.login, state, created_at, submitted_at, and thread resolution state.
- Distinctive: line 98
Never use the base repository or a same-named branch as a fallback.
- Very specific: line 100
Before requiring --delete-branch, determine whether the base branch requires a merge queue using live GitHub branch-protection or …
- Very specific: line 103
When a queue is required, report a blocker and do not drop --delete-branch, delete the branch before merging, or use --auto.
- Distinctive: line 129
If another actor merged the PR during the final refresh, do not merge again.
- Distinctive: line 130
Verify the same post-merge and branch-deletion conditions, then report the race.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Merging a Kivgraph pull request
This skill performs the final, destructive PR operation. A request to merge a
specific PR authorizes both the merge and deletion of that PR's head branch.
Do not use this skill for requests to prepare a PR, check whether it is ready,
or enable auto-merge. The workflow below is self-contained and must not load
another skill's SKILL.md at runtime.
Preconditions
- Treat the PR as review-ready only when the intended changes are committed and pushed, relevant local gates have passed, required GitHub checks have completed successfully, CodeRabbit has reviewed the latest head, every actionable finding is addressed or explained, and GitHub reports no merge conflict or other known blocker. Stop if any condition is missing; do not merge around an unresolved finding.
- Resolve exactly one PR. Use the PR number or URL supplied by the user; if it is absent, use the current branch's PR only when there is exactly one. Stop if the target is ambiguous.
- Fetch live PR metadata from GitHub. Confirm that the PR is open, not a draft,
mergeable, and has a concrete
headRefOid,headRefName,headRepository.nameWithOwner, base branch, and repository. Never infer these values from a stale local checkout. - Check required status checks and review state. Wait for pending checks and CodeRabbit; stop on a failure, conflict, missing required check, or a review decision that still requests changes.
CodeRabbit final gate
The final gate is about the current head SHA, not merely whether CodeRabbit has reviewed the PR at some point.
- Before waiting, record the current head SHA and a snapshot of all existing
CodeRabbit reviews, inline comments, issue comments, and thread states. Keep
each artifact's ID, commit or timestamp fields, body digest, and resolution
state where available. Set
reviewCycleStartedAtimmediately after this snapshot. Identify the bot by its GitHub account/login returned by the API, not by a string in the comment body. The usual login iscoderabbitai[bot], but do not assume it. - Wait until the CodeRabbit check or review for that exact SHA has completed. A queued, in-progress, absent, or API-inaccessible review is a blocker.
- Fetch all three surfaces again:
- pull-request reviews;
- pull-request review comments, including replies and threads;
- issue comments on the PR, which cover comments outside the diff.
- Compare the second snapshot with the first and save the second as the
postReviewSnapshot. Any new CodeRabbit finding that requests a change blocks the merge, even if CI is green. A new clean summary is not a finding, but it must be reported. - Check existing findings as well. Every CodeRabbit comment concerning the
current head must be resolved, obsolete with an evidence-based explanation,
or already fixed. Do not treat an old comment as harmless just because it
was posted on an earlier SHA. Unresolved review threads or a
CHANGES_REQUESTEDreview block the merge. - Issue comments do not expose
commit_id. Treat an issue comment as part of the current review cycle when its ID is new afterreviewCycleStartedAt, or its body orupdated_atchanged after that checkpoint. Evaluate its body and ID even without a commit field. Pre-existing unchanged issue comments remain historical, but their unresolved actionable content still blocks the merge; missingcommit_idalone is not uncertainty. If identity, timing, or status cannot otherwise be established, stop and report the uncertainty instead of guessing. After any fix and push, restart this gate from the new head SHA.
When using the GitHub CLI, the relevant read-only API surfaces are equivalent to:
gh api --paginate repos/{owner}/{repo}/pulls/{number}/reviews
gh api --paginate repos/{owner}/{repo}/pulls/{number}/comments
gh api --paginate repos/{owner}/{repo}/issues/{number}/commentsUse structured fields such as commit_id, user.login, state, created_at,
submitted_at, and thread resolution state. Do not rely on the abbreviated
output of gh pr view alone. Use the GraphQL reviewThreads connection when
the REST response does not expose whether an inline thread is resolved.
Merge and branch deletion
Immediately before mutating anything, refresh the PR and take a fresh snapshot
of all three CodeRabbit surfaces: reviews, review comments, and issue comments,
including body digests, timestamps, commit IDs, states, and thread resolution
states where available. In the same live refresh, revalidate state=OPEN,
isDraft=false, mergeable=MERGEABLE, all required checks as complete and
passing, the review state, and the absence of a merge conflict or other known
blocker. Compare the CodeRabbit data with postReviewSnapshot. If any
CodeRabbit surface changed, any prerequisite is no longer merge-ready, or the
head SHA differs from the SHA that passed the final CodeRabbit gate, repeat the
entire gate. Otherwise capture the verified SHA as gatedHeadSha and retain
the PR's headRepository.nameWithOwner and headRefName as the cleanup target.
Never use the base repository or a same-named branch as a fallback.
Before requiring --delete-branch, determine whether the base branch requires
a merge queue using live GitHub branch-protection or repository metadata. The
GitHub CLI does not support combining a merge queue with --delete-branch.
When a queue is required, report a blocker and do not drop --delete-branch,
delete the branch before merging, or use --auto. Proceed only if GitHub
confirms a supported direct-merge path, the user explicitly authorizes any
required bypass (such as administrator privileges), and that path still
supports deletion after the merge.
For a supported direct merge, use the repository's configured or user-selected
method and include both --delete-branch and
--match-head-commit "$gatedHeadSha" in the gh pr merge command. Do not use
--auto: it can merge later after the verified review state is stale. Do not
close the PR separately; a successful merge closes it.
After the command:
- Refetch the PR and verify
state=MERGED, a merge timestamp, and a merge commit or equivalent merge result. - Resolve the remote repository from the saved
headRepository.nameWithOwner, then check whetherrefs/heads/<headRefName>exists there. The preferred path is the CLI's--delete-branchbehavior. If that exact ref still exists after a successful merge, including for a cross-repository PR, delete only that ref through GitHub and verify it is absent afterward. URL-encode branch names as needed; never check or delete a same-named ref in the base repository. - A protected branch or a deletion failure is not success. Report the PR as merged but the cleanup as failed, including the exact branch name; never force-delete another ref.
- If another actor merged the PR during the final refresh, do not merge again. Verify the same post-merge and branch-deletion conditions, then report the race.
Handoff
Report the PR URL and number, final head SHA, checks, CodeRabbit result (including whether any new comments appeared), merge method and merge commit, exact branch deletion result, and any skipped or blocked condition. Say explicitly if the PR was already merged or if the branch cleanup still needs intervention.
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
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.

