Cleanup Stale PRs
Use this skill for GitHub pull request hygiene. Start with a dry run, review the candidates, and only use --apply when the user wants the closures to happen.
Prerequisites
ghis installed and authenticated for the target repository.python3is available.- Prefer the bundled script over ad-hoc shell pipelines.
Bundled Resource
scripts/cleanup_stale_prs.pylists stale PRs and optionally closes them.
Default Workflow
Commands below assume the repo root is the current working directory. Invoke the bundled script via its full path under .agents/skills/cleanup-stale-prs/.
python3 ./.agents/skills/cleanup-stale-prs/scripts/cleanup_stale_prs.py --dry-run
python3 ./.agents/skills/cleanup-stale-prs/scripts/cleanup_stale_prs.py \
--dry-run \
--repo owner/repo \
--stale-days 5 \
--exempt-label do-not-close
python3 ./.agents/skills/cleanup-stale-prs/scripts/cleanup_stale_prs.py \
--apply \
--stale-days 3 \
--exempt-label wip
Behavior
- Uses
gh pr list --jsonto inspect open PRs, including titles and PR descriptions. - Treats a PR as stale when
updatedAtis older than the cutoff. The default threshold is 7 days. - Excludes PRs whose labels include the exempt label, case-insensitive.
- In dry-run mode, prints a grouped summary with counts, change-type breakdowns, and detailed candidates grouped by inferred topic.
- Adds a close comment when
--applyis used.
Notes
updatedAtcan be bumped by bots, comments, or status changes. If that is too noisy, switch to a commit-recency variant.- Keep dry-run as the default. Do not close PRs unless the user asked for it.