Install in Claude Code
Copygit clone --depth 1 https://github.com/TanStack/ai /tmp/pr-sweep && cp -r /tmp/pr-sweep/.grok/skills/pr-sweep ~/.claude/skills/pr-sweepThen start a new Claude Code session; the skill loads automatically.
Definition
SKILL.md
# PR Sweep
Prep PRs for review. Fan out one subagent per PR (cap 100). Default is **dry-run** (report only). Mutating steps require `--apply` (or the user saying "apply" / "go ahead").
## Args
| Invocation | Behavior |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `/pr-sweep` | All open non-draft PRs (full audit) |
| `/pr-sweep 12 34 56` | Only those PR numbers |
| `/pr-sweep --apply` | Full set, then rebase **and push** (`--force-with-lease`) |
| `/pr-sweep --apply 12 34` | Rebase **and push** listed PRs only |
| `/pr-sweep --outside-only` | Action target = outside authors only (default for mutations) |
| `/pr-sweep --include-in-house` | Also rebase/update **in-house** branches (still never merge) |
| `/pr-sweep --behind` | Only PRs behind base / BEHIND / not up to date |
| `/pr-sweep --conflicts` | Only CONFLICTING / DIRTY / dirty merge state |
| `/pr-sweep --changed` | Only PRs changed since last snapshot (or `updatedAt` within 24h if no snapshot) |
| `/pr-sweep --daily` | Recommended daily recipe: `--changed` ∪ `--behind` ∪ `--conflicts` ∪ new outside PRs; security-scan new outside; lighter pass on the rest |
| `/pr-sweep --apply --daily --include-in-house` | Daily apply: prep outside + rebase ours when behind/conflicting |
Combine freely: `--apply --daily --include-in-house`. Explicit PR numbers always win over filters.
## Modes
- **dry-run (default):** fetch, classify, security-scan, decide relevance / rebase need / CI need / assign recommendation. **No** push, **no** CI approve, **no** comments.
- **apply:** after dry-run logic, **rebase + `git push --force-with-lease` + CI approve** for PRs that pass security and are marked actionable, **in the same turn**. `--apply` on the invocation is consent — do not wait for a second yes. Still **never merge** a PR and **never comment** on a PR. A local rebase with no push is a **failed** apply. Record results in `SWEEP-*.md` only.
## Daily routine (recommended)
### Option A — Grok `/loop` (same machine, session-scoped, expires ~7d)
```text
/loop 1d /pr-sweep --apply --daily --include-in-house
```
Or dry-run every morning and apply only when you say go:
```text
/loop 1d /pr-sweep --daily --include-in-house
```
`/loop` intervals: `Nm` / `Nh` / `Nd` (min 60s). Cancel with `scheduler_list` → `scheduler_delete <id>`.
### Option B — Manual weekday
```text
/pr-sweep --daily --include-in-house # dry-run first
/pr-sweep --apply --daily --include-in-house # after skimming plan
```
### What `--daily` processes
Build the **action set** as the union of:
1. **New outside PRs** — open outside non-draft not present in the previous snapshot (full security scan).
2. **Changed** — `updatedAt` newer than last snapshot `sweptAt`, or head SHA changed vs snapshot.
3. **Behind** — `mergeStateStatus` is `BEHIND` or not up to date with default branch.
4. **Conflicts** — `mergeable == CONFLICTING` or `mergeStateStatus` in `DIRTY`, `BLOCKED` with dirty indicators.
5. **CI waiting approval** — outside PRs with first-time-contributor gate (cheap; no full diff if already in snapshot as `security: clean`).
Skip from action set (still note counts in report):
- Drafts (unless listed explicitly)
- `security: alert` from prior snapshot until human clears
- PRs marked `blocked-conflicts` in the last 24h with **no** `updatedAt` change (avoid thrashing)
- Bot version/release PRs (`changeset-release/*`, pure Renovate) unless `--include-bots`
Cost target: daily should touch **tens**, not all open history. Full `/pr-sweep` remains the weekly deep scan.
### Snapshot (enables `--changed` / `--daily`)
Path: `.agent/pr-sweep/snapshot.json`
```json
{
"repo": "TanStack/ai",
"sweptAt": "2026-08-10T18:00:00Z",
"defaultBranch": "main",
"defaultBranchSha": "abc…",
"prs": {
"1069": {
"author": "mikemikimike",
"outside": true,
"headSha": "def…",
"updatedAt": "2026-08-10T04:01:40Z",
"security": "clean",
"mergeable": "MERGEABLE",
"mergeStateStatus": "UNSTABLE",
"lastAction": "approve-ci",
"lastActionAt": "2026-08-10T17:30:00Z"
}
}
}
```
Write/update after every run (dry-run or apply). Diff against this file for `--changed`. If missing, treat all open PRs as new for one full pass, then write the snapshot.
## Prerequisites
```bash
gh auth status
gh repo view --json nameWithOwner,defaultBranchRef,owner
```
Stop if not authenticated. Confirm you are in the target repo (or pass `owner/repo` if the user named one).
## Safety (hard rules)
1. **Never merge** a PR.
2. **Never** `git push --foMore from this repository
gap-analysisSkill
>
triage-githubSkill
Triage all open GitHub issues, PRs, and discussions in the current repository by fanning out up to 100 parallel subagents (one per item), then produce a single prioritized report ranking which PRs to review first, which issues to address first, and which discussions need maintainer attention. Use when the user asks to "triage open issues/PRs", "triage discussions", "prioritize the backlog", "what should I review first", "sweep the repo", or any request to bulk-evaluate open GitHub work and recommend an order.
ai-code-modeSkill
>
ai-mcpSkill
>
ai-coreSkill
>
ai-core/adapter-configurationSkill
>
ai-core/ag-ui-protocolSkill
>
ai-core/chat-experienceSkill
>