Skip to content

Add automated cleanup policy for stale draft PRs#12174

Merged
pelikhan merged 2 commits intomainfrom
copilot/add-draft-pr-cleanup-policy
Jan 28, 2026
Merged

Add automated cleanup policy for stale draft PRs#12174
pelikhan merged 2 commits intomainfrom
copilot/add-draft-pr-cleanup-policy

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Draft PRs account for 9.6% of open PRs (25/260), creating noise in triage. Implements automated cleanup with warning phase before closure.

Implementation

Workflow: .github/workflows/draft-pr-cleanup.md

  • Daily execution with fuzzy timing to distribute load
  • Queries draft PRs via GitHub MCP tools
  • Calculates inactivity from last commit, comment, or label change

Two-phase cleanup:

  • Days 10-13: Add stale-draft label + warning comment
  • Day 14+: Auto-close with reopening instructions

Exemptions: Skip PRs labeled keep-draft, blocked, or awaiting-review

Safe-output limits: 20 comments, 10 closures per run

Inactivity criteria

A draft is stale when it has no:

  • Commits to branch
  • PR comments
  • Label changes
  • Title/description updates

Target: Reduce draft rate from 9.6% to <5%

Original prompt

This section details on the original issue you should resolve

<issue_title>Add draft PR cleanup automation policy</issue_title>
<issue_description>### Problem

Analysis of recent PR activity (Jan 24-28) shows 25 draft PRs (9.6% of total 260 PRs) remain open, with some potentially abandoned work-in-progress items. This creates clutter in the PR list and makes triage more difficult.

Proposed Solution

Implement automated cleanup policy for stale draft PRs:

  1. Warning phase (10 days of inactivity):

    • Post comment: "This draft PR has been inactive for 10 days and will be auto-closed in 4 days unless updated"
    • Label: stale-draft
  2. Cleanup phase (14 days of inactivity):

    • Auto-close with comment: "Closing inactive draft PR. Feel free to reopen if work continues."
    • Keep stale-draft label for tracking
  3. Exemptions:

    • PRs with keep-draft label
    • PRs marked as blocked or awaiting-review
    • PRs with activity in last 10 days

Implementation

Create workflow: .github/workflows/draft-pr-cleanup.md

---
engine: copilot
on:
  schedule:
    - cron: '0 2 * * *'  # Daily at 2 AM UTC
safe-outputs:
  max:
    issues: 0
    pull_requests: 0
    comments: 20  # Up to 20 stale draft warnings/closes per run
---

Review all open draft PRs and:
1. Identify drafts with >10 days of inactivity (no commits, comments, or label changes)
2. For drafts inactive 10-13 days: Add warning comment and `stale-draft` label
3. For drafts inactive >14 days: Close with cleanup comment (unless exempted)
4. Exempt PRs with `keep-draft`, `blocked`, or `awaiting-review` labels

Use GitHub MCP tools to query drafts, check activity, and post comments.

Success Metrics

  • Draft PR rate drops from 9.6% to <5%
  • Faster PR triage (less clutter)
  • Clear communication to PR authors
  • Exemption system prevents premature closure

Context

  • Current draft PRs: 25 (out of 260 recent PRs)
  • Estimated abandoned drafts: 10-15
  • Impact on ecosystem: Minor but improves maintainability
  • Priority: P2 (this week)

Related

Agent Performance Report - Week of January 24-28, 2026

AI generated by Agent Performance Analyzer - Meta-Orchestrator

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Created .github/workflows/draft-pr-cleanup.md with automated cleanup policy
- Warning phase: Add stale-draft label and comment after 10 days inactivity
- Cleanup phase: Close PRs after 14 days inactivity
- Exemptions for keep-draft, blocked, and awaiting-review labels
- Configured safe-outputs with 20 comments and 10 closures max per run
- Uses fuzzy daily schedule to distribute load
- Workflow compiled successfully

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add draft PR cleanup automation policy Add automated cleanup policy for stale draft PRs Jan 28, 2026
Copilot AI requested a review from pelikhan January 28, 2026 05:31
@pelikhan pelikhan marked this pull request as ready for review January 28, 2026 05:36
@pelikhan pelikhan merged commit a96483b into main Jan 28, 2026
@pelikhan pelikhan deleted the copilot/add-draft-pr-cleanup-policy branch January 28, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add draft PR cleanup automation policy

2 participants