-
Agentic setup — follow references/agentic-setup.md. This skill uses: BASE_BRANCH, LABELS_ENABLED (--apply needs true, because the outcome is a label; a dry run works without it), AUTOMERGE_LABEL, the automerge.eligibility slots (TIERS, SMALL_PR_FILE_LIMIT, STALE_AFTER_DAYS, SECURITY_LABELS, TRUSTED_AUTHORS, EXCLUDE_ASSOCIATIONS, EXCLUDE_LABELS, LOOKBACK_DAYS, ANALYZE_LIMIT, LIMIT), the labels.priority and labels.risk lists, and the tracker operations current-user, default-branch, list-prs, get-pr, get-pr-author-association, get-pr-diff, get-issue, list-review-comments, get-pr-checks, list-issue-comments, comment-pr, update-comment, create-label, and the label_exists / apply_label guards.
-
List candidates in the window. Fetch the open PRs with list-prs (limit 1000, raising the descriptor's default cap; when the result reaches the limit, the proposal discloses it), requesting number,title,url,author,labels,isDraft,baseRefName,createdAt,changedFiles,closingIssuesReferences,reviewDecision,latestReviews. Call get-pr for any field the tracker's list leaves out. Establish the review state before deciding whether requested-changes judgment is required; unreadable review state rejects the PR with review state unknown rather than being assumed clear. Then apply the window and the analyze limit (references/eligibility.md → Window and analyze limit): keep PRs whose createdAt falls inside the window, order them newest first (oldest first with --from-oldest), and keep the first ANALYZE_LIMIT. Count the PRs left outside the window or past the limit for the report. With --pr, fetch that PR only and skip the window.
-
Sort out PRs that are already handled. A PR already carrying AUTOMERGE_LABEL goes to the already queued list. Re-check the hard gates for it and flag any it now fails, but never remove the label. A PR carrying automerge-blocked is skipped: it is waiting for a human to clear that label. Neither kind is proposed.
-
Apply the hard gates (references/eligibility.md → Hard gates): open and not a draft, targets BASE_BRANCH, no label in EXCLUDE_LABELS, and an author association outside EXCLUDE_ASSOCIATIONS (read with get-pr-author-association) unless the author is in TRUSTED_AUTHORS. Run the cheap list-field gates first, so the association lookup runs only for PRs that are still candidates. Record the first gate each rejected PR failed.
-
Label-based tier and shortlist. Evaluate the label-based criteria — every criterion except ai-judgment (references/eligibility.md → Criteria) — and place each surviving PR in the first tier of TIERS it matches. A PR matching no label-based tier becomes a judgment-only candidate, ranked after every tiered PR, when TIERS includes ai-judgment; otherwise it is recorded as no tier matched. Rank (references/eligibility.md → Ranking) and keep the first LIMIT as the shortlist. PRs past the shortlist are counted for the report and get no AI judgment.
-
AI judgment on the shortlist only. When TIERS includes ai-judgment, or a shortlisted PR has requested changes, follow references/ai-judgment.md for each shortlisted PR — never for PRs outside it. match moves the PR to the ai-judgment tier when that tier comes earlier than its label-based one. A PR with requested changes, or a judgment-only candidate, is dropped unless the judgment is match, with the decisive reason recorded. Re-rank the remaining PRs; they are the proposal (at most LIMIT, never backfilled).
-
Report the proposal using references/report-templates.md → Proposal. It contains the ranked table (tier, matched criteria, priority, risk, files changed, author association), the already-queued list with any flags, and a collapsed list of rejected PRs, each with its decisive gate or judgment. Include the evidence-linked judgment record from references/ai-judgment.md for every assessed PR.
-
Stop for confirmation, unless --apply was given. End with ⚠ NEEDS HUMAN CONFIRMATION and three exact commands, each carrying this run's window flags (--window, --from-oldest, --lookback-days, --analyze-limit, --limit) so it reproduces the same shortlist: label all proposed PRs (--apply all), label selected ones (--apply <n>,<n>), or scroll to the next window (--window <n+1>, no --apply). A scheduled run stops here. With --apply (or a reply choosing all or some PRs), continue to step 8; a reply asking for the next window starts a new dry run with --window <n+1>.
-
Apply the label to confirmed PRs only. For each confirmed number, re-read the PR with get-pr and repeat steps 2–5 on its current state, refreshing the judgment and evidence against its current head. Skip any PR that is no longer eligible or is not in the proposal, and say why. Set PR_NUMBER to that confirmed number. For an eligible PR, apply_label "$AUTOMERGE_LABEL" "$PR_NUMBER" (create it with create-label first when label_exists says it is missing). Re-read its labels with get-pr; only count it as labeled and create or update this skill's label-rationale comment when AUTOMERGE_LABEL is present (references/report-templates.md → Label rationale). A failed write, unreadable read-back or absent label is skipped with its reason. Never touch assignees, claims, or other labels.
-
Report. Give the outcome per PR (labeled, skipped with reason), then a PR: chaining line for each PR labeled (references/report-templates.md → Apply report).