Agent skill

Citus Merge Loop

by citusdata in citusdata/citus

Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red check-style job with make reindent, retry other red checks a bounded…

AGPL-3.0Auto-check passedDevelopment

Install Citus Merge Loop

skills CLI
$ npx skills add citusdata/citus --skill citus-merge-loop -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install citusdata/citus citus-merge-loop --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/citusdata/citus.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/citus-merge-loop .claude/skills/citus-merge-loop && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
citus-merge-loop
GitHub stars
13k
Token cost
~2.5k tokens
SKILL.md length
1,394 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
AGPL-3.0

At a glance

Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red check-style job with make reindent, retry other red checks a bounded…

  • Works in 4 steps: Skip already-merged PRs → Give up if draft or not approved → Sync-and-check loop → …
  • Asked to merge these PRs
  • SKILL.md covers Per-PR algorithm and Final report
  • Calls gh and git

What it does

Citus Merge Loop is an agent skill from citusdata/citus. Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red check-style job with make reindent, retry other red checks a bounded number of times, give up on a PR when a rule says to give up, then squash-merge with the PR description as the commit message. USE WHEN asked to "merge these PRs", "land this batch of PRs", "merge PR 1234 (and others)", or to run an unattended merge loop over several Citus PRs. DO NOT USE for reviewing a PR, for a single…

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Pull requests and Commit messages. It works with PostgreSQL and SQL. The repository describes itself as: Distributed PostgreSQL as an extension. The licence is AGPL-3.0.

When your agent uses it

  • Asked to merge these PRs
  • Land this batch of PRs
  • Merge PR 1234 (and others)
  • Run an unattended merge loop over several Citus PRs

Example prompts

  • “merge these PRs”
  • “land this batch of PRs”
  • “merge PR 1234 (and others)”
  • “/citus-merge-loop”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Skip already-merged PRs
  2. Give up if draft or not approved
  3. Sync-and-check loop
  4. Squash-merge

What it can do on your machine

Read from SKILL.md and the folder at commit d41eec3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • gh
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use gh and git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Citus Merge Loop loads about 2.5k tokens when it runs. Until then it costs about 151 tokens; SKILL.md has 1,394 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~151
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from citusdata/citus at commit d41eec3, republished under its AGPL-3.0 licence (© citusdata). 1,394 words, ~2,507 tokens.

Download SKILL.mdSave it as .claude/skills/citus-merge-loop/SKILL.md (or your agent's skills folder).
name
citus-merge-loop
description
Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red `check-style` job with `make reindent`, retry other red checks a bounded number of times, give up on a PR when a rule says to give up, then squash-merge with the PR description as the commit message. USE WHEN asked to "merge these PRs", "land this batch of PRs", "merge PR #1234 (and others)", or to run an unattended merge loop over several Citus PRs. DO NOT USE for reviewing a PR, for a single manual merge with no retry/give-up rules, or for non-Citus repos.
license
See the repository LICENSE file.

Merge a batch of Citus PRs, one at a time

Input: one or more PR links or numbers. Process them one at a time, independently — finish (merge or give up on) one PR completely before starting the next. Do not chain PRs onto each other (do not base one PR's fix on another PR's branch).

Use the gh CLI for all GitHub calls. Every gh pr ... command accepts a PR number or a full PR URL directly, so you never need to parse the input yourself: gh pr view <input>, gh pr checks <input>, gh pr merge <input> all work either way.

Keep a running list of {pr, outcome, reason} as you go (a scratch note or a session SQL table both work) so you can print the final report without having to re-look-up anything.

Per-PR algorithm

For each PR, in order:

1. Skip already-merged PRs

gh pr view <pr> --json state,isDraft,reviewDecision,latestReviews,mergeStateStatus,baseRefName,headRefOid,title,body

  • state == "MERGED" → record outcome skipped (already merged), move to the next PR.
2. Give up if draft or not approved
  • isDraft == true → record outcome given up (draft), move to the next PR.

  • Then decide by reviewDecision. It is one of APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, or empty. Handle each value as follows:

    • APPROVED → approved, continue to step 3.
    • CHANGES_REQUESTED → record outcome given up (changes requested), move to the next PR.
    • REVIEW_REQUIRED → record outcome given up (not approved), move to the next PR.
    • Empty → the base branch does not require reviews (this is the case for the release-* branches here). GitHub then reports empty no matter what reviewers did, even if someone requested changes. So look at latestReviews (the latest review from each reviewer) yourself:
      • If any entry has state == "CHANGES_REQUESTED" → record outcome given up (changes requested), move to the next PR.
      • Otherwise → acceptable, continue to step 3. This includes a PR that has no reviews at all.

    You only need to test this once, here. Pushing to a PR does not dismiss an existing approval in this repo, so an approval you saw in this step is still valid later in the loop.

3. Sync-and-check loop

Repeat the steps below until both are true: the PR's mergeStateStatus is CLEAN (fully merged up to date with its base, no conflicts) and every non-Codecov check is passing. Re-fetch PR state at the top of every iteration — do not act on stale data.

a. Bring the branch up to date with its target. If mergeStateStatus is BEHIND, run gh pr update-branch <pr> (this merges the base branch into the PR branch on GitHub's side — no local checkout needed) and loop back to re-fetch state.

If mergeStateStatus is DIRTY (real merge conflict) or BLOCKED for a reason you cannot resolve with the rules below, give up: record outcome given up (merge conflict / blocked), move to the next PR.

b. Read every check. gh pr checks <pr> --json name,bucket,link (bucket is one of pass, fail, pending, skipping, cancel.)

Do not pass --required. Branch protection here requires a single aggregate job named CI that only mirrors the result of the jobs it depends on. check-style and the flakyness jobs never appear in --required output, so the special-case rules below would be unreachable. Read every check instead, so you can see and act on the individual job that actually failed.

  • Ignore checks whose name contains codecov (case-insensitive), regardless of whether their bucket is pass, fail, pending, skipping, or cancel. Codecov checks do not block merging in this repository.

  • All non-Codecov checks are pass (or skipping, which does not block merge) and none are pending → sync-and-check loop is done, go to step 4.

  • Any pending and nothing actionable to do → wait for up to 15mins (e.g. gh pr checks <pr> --watch), then loop back to re-fetch state. Do not wait on pending Codecov checks.

  • Any non-Codecov fail or cancel → handle the failing ones as follows, most specific rule first:

    1. A check named check-style failed — this loop is responsible for setting up the environment; the reindent skill only works on whatever is already checked out. Concretely:

      • Check out the PR's own head branch, e.g. gh pr checkout <pr>.
      • Record the PR's own changed files, taken from the PR itself rather than from a local diff:
        bash
        gh pr diff <pr> --name-only > /tmp/pr-<pr>-files.txt
        Do not derive this list with git diff ... origin/<base-branch>. gh pr checkout does not refresh your local copy of the base branch, so a stale origin/<base-branch> would fold base-branch changes into the list and let an unrelated reindent slip through as "allowed".
      • Load and follow the standalone citus-check-style-reindent skill as-is. It reads the formatter versions pinned by the checked-out branch itself and, if it finds a legitimate fix, stops after a local commit — it never pushes.
      • After the skill produces a commit, compare the reindent commit's changed files against the PR's own changed-files list from above. If the reindent commit touched any file the PR itself did not already touch, discard the commit (git reset --hard HEAD^) and give up: record outcome given up (check-style: reindent touched unrelated files), move to the next PR.
      • Otherwise, push the local commit to the PR's head branch (git push) — pushing is this loop's decision, not the reindent skill's.

      Track how many times you have run this recipe for this PR. If check-style is still red after your 5th attempt (whether the skill made no fix, or the fix still fails CI), give up: record outcome given up (check-style), move to the next PR. Otherwise loop back to re-fetch state (the head commit has changed).

    2. A check whose name contains "flaky" (e.g. a flakyness/flaky job) failed — give up immediately, no retries: record outcome given up (flaky job), move to the next PR.

    3. Any other check failed or was canceled — rerun the individual failed jobs, one at a time, each with its own counter.

      Do not run gh run rerun <run-id> --failed. That reruns every failed job in the whole workflow run at once, so unrelated failures get retriggered while only the one check you were looking at gets its counter incremented.

      Instead, for each failing check, resolve its run, look up that single job's databaseId, and rerun only that job:

      bash
      LINK=$(gh pr checks <pr> --json name,link -q '.[] | select(.name=="<check-name>") | .link')
      RUN_ID=$(echo "$LINK" | grep -oE 'runs/[0-9]+' | grep -oE '[0-9]+')
      JOB_ID=$(gh run view "$RUN_ID" --json jobs \
        -q '.jobs[] | select(.name=="<check-name>") | .databaseId')
      gh run rerun "$RUN_ID" --job "$JOB_ID"

      --job needs the job's databaseId from the API. The number in the job's browser URL is a different id and returns 404.

      Repeat that block once per failing check, so several failing checks in the same run each get rerun separately.

      Keep one independent counter per (head commit SHA, check name) pair — never a single shared counter. If one check has already failed 5 times on this exact head commit, stop rerunning that check: record outcome given up (check <name> failed 5+ times), move to the next PR. A new head commit (from step 3a or 3b.1) resets every counter for this PR.

      After triggering the reruns, loop back to re-fetch state and wait for them to finish.

Show full SKILL.md (220 more words)Show less
4. Squash-merge

The PR is in sync with its base and every non-Codecov check is green. Merge it with the PR description as the commit message, pinned to the exact commit you just validated:

bash
BODY=$(gh pr view <pr> --json body -q .body)
SHA=$(gh pr view <pr> --json headRefOid -q .headRefOid)
gh pr merge <pr> --squash --body "$BODY" --match-head-commit "$SHA"

If --match-head-commit rejects the merge (head moved again in the small window between the check and the merge), just loop back to step 3 and re-validate — do not force it.

Never record merged just because you issued the command. Check that gh pr merge exited successfully, then confirm the PR really reached the merged state:

bash
gh pr view <pr> --json state,mergedAt
  • gh pr merge succeeded and state == "MERGED" → record outcome merged, move to the next PR.
  • gh pr merge failed on a --match-head-commit mismatch → loop back to step 3 as described above.
  • gh pr merge failed for any other reason (you lack merge permission on the repo, a branch protection rule rejected it, an API or network error), or it reported success but state is still not MERGED → record outcome given up (merge failed: <error text>), move to the next PR. Do not retry blindly, and never report such a PR as merged.

Final report

After every PR has been processed, print one line per PR: its number/link and its outcome (merged, skipped (already merged), or given up (<reason>)). List the given-up PRs together at the end so they're easy to scan.

© citusdata, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/citus-merge-loop of citusdata/citus.

Open the folder on GitHubat commit d41eec3

Compare with similar skills

Citus Merge Loop next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Citus Merge Loop compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Citus Merge Loop this skillcitusdata/citus13k—~2.5kAutomated safety check: PassAGPL-3.0
PR Bot Reviewspgplex/pgconsole155—~2.1kAutomated safety check: PassApache-2.0
Git PR Flowwgzhao/Addax1.4k—~216Automated safety check: PassApache-2.0
Commit And PR Guidelinesrelytcloud/pg_ducklake143—~1.4kAutomated safety check: NotesMIT
Mz PR ReviewMaterializeInc/materialize6.4k—~1.6kAutomated safety check: NotesCustom licence
Postgres Commit History Articledigoal/blog8.6k—~2.3kAutomated safety check: PassGPL-2.0

Similar skills

  • PR Bot Reviews

    pgplex/pgconsole

    Triage, verdict, and reply to automated PR review comments from GitHub Copilot and Greptile, then iterate until the bots have nothing left to say.

    155 GitHub stars~2.1k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Git PR Flow

    wgzhao/Addax

    Standard branch, commit, and pull-request workflow for this repo.

    1.4k GitHub stars~216 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Commit And PR Guidelines

    relytcloud/pg_ducklake

    Commit message conventions and pull request description guidelines.

    143 GitHub stars~1.4k tokensUpdated yesterday
    DevelopmentAuto-check: notes
  • Mz PR Review

    MaterializeInc/materialize

    Local code review of current branch vs Materialize standards.

    6.4k GitHub stars~1.6k tokensUpdated today
    DevelopmentAuto-check: notes
  • Analyze PostgreSQL git commit history between two commit ids and, when valuable DBA/application-developer changes exist, write a Chinese Markdown article for WeChat/公众号 readers with examples checked…

    8.6k GitHub stars~2.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • SeekDB Code Review

    oceanbase/seekdb

    Reviews seekdb pull requests and diffs for real defects in correctness, resources, concurrency, security and tests, reporting only Blocker or Major findings.

    3.1k GitHub stars~2.1k tokensUpdated today
    DevelopmentAuto-check passed

More from citusdata/citus

  • Fix a failing citusdata/citus check-style job by running make reindent with the exact uncrustify/citusindent versions the currently checked-out branch pins (read from its own STYLEGUIDE.md and its…

    13k GitHub stars~1.5k tokensUpdated yesterday
    Auto-check: notes
  • Citus Backport

    citusdata/citus

    Backport one or more merged citusdata/citus main commits/PRs onto the active release branches.

    13k GitHub stars~3.2k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Citus Merge Loop

What does Citus Merge Loop do?

Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red check-style job with make reindent, retry other red checks a bounded…. Citus Merge Loop is an agent skill from citusdata/citus. Take a list of citusdata/citus PR links or numbers and merge each one independently: sync it with its base branch, fix a red check-style job with make reindent, retry other red checks a bounded number of times, give up on a PR when a rule says to give up, then squash-merge with the PR description as the commit message.

When should I use Citus Merge Loop?

Citus Merge Loop fits situations like: asked to merge these PRs; land this batch of PRs; merge PR 1234 (and others); run an unattended merge loop over several Citus PRs.

How do I install Citus Merge Loop in Claude Code?

Run `npx skills add citusdata/citus --skill citus-merge-loop -a claude-code`. Or copy the skill folder (.github/skills/citus-merge-loop in citusdata/citus) into .claude/skills/citus-merge-loop in your project. Claude Code loads it when a task matches its description.

How do I install Citus Merge Loop in Codex?

Run `npx skills add citusdata/citus --skill citus-merge-loop -a codex`. Or copy the skill folder (.github/skills/citus-merge-loop in citusdata/citus) into .agents/skills/citus-merge-loop in your project. Codex loads it when a task matches its description.

Can I use Citus Merge Loop in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add citusdata/citus --skill citus-merge-loop -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/citus-merge-loop, .gemini/skills/citus-merge-loop, .github/skills/citus-merge-loop and .opencode/skills/citus-merge-loop in your project.

What does Citus Merge Loop need to run?

Going by SKILL.md and its folder, Citus Merge Loop needs the command-line tools its instructions call (gh and git).

Does Citus Merge Loop access the network?

SKILL.md contains no URLs. Its commands use gh and git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Citus Merge Loop safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Citus Merge Loop use?

Citus Merge Loop is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Citus Merge Loop use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Citus Merge Loop?

Skills that share tags, products or a category with Citus Merge Loop: PR Bot Reviews (pgplex/pgconsole, 155 stars), Git PR Flow (wgzhao/Addax, 1.4k stars), Commit And PR Guidelines (relytcloud/pg_ducklake, 143 stars) and Mz PR Review (MaterializeInc/materialize, 6.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Citus Merge Loop?

citusdata (a GitHub organization) maintains it in citusdata/citus, which has 12,803 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 8, 2026.

Source: citusdata/citus on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.