Land batch

From indigoai-us/hq-core · View interactive version

Land batch is an AI agent skill from the GitHub repository indigoai-us/hq-core. Triage, review, and merge several open PRs in order, with CI and deploy checks. Triggers: \"land all PRs\", \"merge open PRs\".

How to use this skill

Skill file

Land Batch

Triage open PRs -> prioritize -> review each -> batch train or auto-merge on green -> verify deploys.

This skill takes a set of open PRs from "open" to "merged and verified." It handles

triage/prioritization, per-PR review, conflict resolution, batch-train or GitHub

auto-merge landing pinned to reviewed heads, and post-merge deploy tracking.

Input

Accepts one of:

Step 0: Discover + Triage

0a: List open PRs and repo merge capabilities

gh pr list -R {repo} --state open --json number,title,headRefName,headRefOid,isDraft,mergeable,createdAt,labels,statusCheckRollup,additions,deletions,files
gh api repos/{repo} --jq '{allow_auto_merge, delete_branch_on_merge}'

0b: Classify each PR

For each PR, determine:

0c: Build merge order and check confirmation gate

Prioritize by:

  1. Blockers first — PRs that other PRs depend on
  2. Low risk first — config, docs, cleanup PRs land fast
  3. Infrastructure before features — DB/infra PRs before feature PRs that use them
  4. Smallest first within same tier — reduces conflict surface

Present triage table:

PR Triage
─────────
| # | Title | Head | Risk | CI | Order |
|---|-------|------|------|----|-------|
| ... | ... | ... | ... | ... | ... |

Proposed merge order: #X -> #Y -> #Z

Confirmation gate:

Step 1: Review + Land

1a: Resolve conflicts and review each PR on its exact `head_sha`

For each PR in merge order:

1b: Land via Batch Train, Auto-Merge, or Direct Squash

Choose the highest-throughput safe path supported by {repo}:

  1. Batch train (preferred for 2+ ready PRs in the same repo when scripts/ci/batch-train.py or a merge queue is available):

Pass every reviewed PR pinned as {number}@{head_sha} so the train validates the combined batch once, bisects on red, and squash-merges with --match-head-commit:

```bash

python3 scripts/ci/batch-train.py --repo {repo} --prs {n1}@{sha1},{n2}@{sha2}

```

For production-on-merge repos that require serialized deploys, add --one-at-a-time --deploy-check '<cmd>' --deploy-wait '<cmd>'.

  1. GitHub auto-merge (preferred when no batch-train executor is present and allow_auto_merge is true):

For each independent reviewed PR whose ruleset approval requirement is met (and respecting deploy spacing / contract order — never arm parallel merges into a known broken prod deploy):

```bash

gh pr merge {number} -R {repo} --auto --squash --delete-branch --match-head-commit {head_sha}

```

Monitor completion in the background (gh pr checks {number} -R {repo} --watch).

  1. Direct squash fallback (only when neither batch-train nor --auto can fire):

Wait for required checks to finish green on {head_sha} (background watch, no foreground sleep loop), then merge pinned to the reviewed head:

```bash

gh pr merge {number} -R {repo} --squash --delete-branch --match-head-commit {head_sha}

```

Use --admin only when authorized and only for a review-only gate — never to bypass failing required checks or unverified flakes.

1c: Post-merge conflict check (non-train merges only)

After direct merges, check remaining PRs' mergeable status (gh pr view {next_number} -R {repo} --json mergeable); only update a branch from main when GitHub reports CONFLICTING.

1d: Track what needs deploy

After each merge, note:

Step 2: Deploy Verification

After all PRs merged:

2a: Trigger deploys

# If Lambda changes were merged:
gh workflow run cd.yml -f env=development -f apps={affected-apps}

# Monitor deploy:
gh run list --workflow cd.yml -L 1 --json status,conclusion,databaseId

2b: SST deploy (if needed)

SST infra changes require manual deploy:

sst deploy --stage development

If SST lock exists: sst unlock --stage=development first (requires admin AWS creds).

2c: Post-deploy checks

Step 3: Report

Batch Landing Complete
──────────────────────
Merged: {N} PRs
  - #{number}: {title} ({risk})
  ...

Deploy status:
  - Lambda: {deployed/pending/not-needed}
  - SST infra: {deployed/pending/not-needed}
  - Frontend: {auto-deployed/pending}
  - DB migrations: {applied/pending/none}

Follow-ups:
  - {any PASS WITH NOTES items}
  - {any post-deploy scripts needed}
  - {any remaining open PRs not in this batch}

Error Handling

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.