|
| 1 | +--- |
| 2 | +name: issue-triage |
| 3 | +description: Weekly triage of open issues and PRs - classify, verify, detect staleness, duplicates, and cross-reference |
| 4 | +trigger: schedule |
| 5 | +tool: claude-code |
| 6 | +timeout_minutes: 15 |
| 7 | +max_turns: 30 |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + issues: write |
| 11 | + pull-requests: read |
| 12 | +--- |
| 13 | + |
| 14 | +# Repository Triage |
| 15 | + |
| 16 | +Triage all open issues and pull requests in this repository, then post a |
| 17 | +combined report to the tracking issue. |
| 18 | + |
| 19 | +## Instructions |
| 20 | + |
| 21 | +### 1. Gather data |
| 22 | + |
| 23 | +Collect all open issues, open PRs, and recent merge activity: |
| 24 | + |
| 25 | +```bash |
| 26 | +# All open issues with metadata |
| 27 | +gh issue list --state open --limit 200 \ |
| 28 | + --json number,title,state,createdAt,updatedAt,labels,assignees,author,body |
| 29 | + |
| 30 | +# All open PRs with metadata |
| 31 | +gh pr list --state open --limit 200 \ |
| 32 | + --json number,title,state,createdAt,updatedAt,labels,author,headRefName,body |
| 33 | + |
| 34 | +# Recently merged PRs (last 60 days) to cross-reference |
| 35 | +gh pr list --state merged --limit 100 \ |
| 36 | + --json number,title,headRefName,body,mergedAt |
| 37 | + |
| 38 | +# PR check status for open PRs |
| 39 | +for pr in $(gh pr list --state open --json number --jq '.[].number'); do |
| 40 | + echo "=== PR #${pr} ===" |
| 41 | + gh pr checks "$pr" --json name,state --jq '[.[] | select(.state == "FAILURE" or .state == "ERROR")] | length' |
| 42 | +done |
| 43 | +``` |
| 44 | + |
| 45 | +### 2. Triage issues |
| 46 | + |
| 47 | +For each open issue, determine: |
| 48 | + |
| 49 | +**Classification** (pick one): |
| 50 | +- `bug` - something is broken |
| 51 | +- `feature` - new capability or enhancement |
| 52 | +- `chore` - maintenance, CI, docs, refactoring |
| 53 | +- `discussion` - needs design input or decision before work starts |
| 54 | + |
| 55 | +**Staleness** (based on last update, today's date, and activity): |
| 56 | +- `active` - updated within the last 14 days |
| 57 | +- `aging` - updated 14-30 days ago |
| 58 | +- `stale` - no update for 30+ days |
| 59 | + |
| 60 | +**Verification** - check if the issue has been addressed: |
| 61 | +- Search merged PRs for closing keywords (`Fixes #N`, `Closes #N`, `Resolves #N`) |
| 62 | + referencing this issue |
| 63 | +- Search merged PR titles and branches for keywords matching the issue |
| 64 | +- If a merged PR appears to fix the issue, flag it as `potentially resolved` |
| 65 | +- If there is an open PR linked to the issue, note the PR number |
| 66 | + |
| 67 | +**Labels as signals** - issues with `needs-attention` were flagged by the stale |
| 68 | +PR workflow because their linked PR was auto-closed. Always include these in the |
| 69 | +"Action needed" section. |
| 70 | + |
| 71 | +**Duplicates / related** - flag issues that overlap in scope or description. |
| 72 | + |
| 73 | +### 3. Triage PRs |
| 74 | + |
| 75 | +For each open PR, determine: |
| 76 | + |
| 77 | +**Health flags** (check all that apply): |
| 78 | +- `no-issue` - PR body has no `Fixes/Closes/Resolves #N` reference (external |
| 79 | + contributors only - collaborators are exempt) |
| 80 | +- `issue-closed` - PR links to an issue that is already closed (by another PR |
| 81 | + or manually) |
| 82 | +- `checks-failing` - PR has failing CI checks |
| 83 | +- `stale` - no author activity (push or comment) for 14+ days with failing |
| 84 | + checks |
| 85 | +- `duplicate-fix` - another open PR references the same issue |
| 86 | + |
| 87 | +**Cross-reference** - for each PR that references an issue: |
| 88 | +- Verify the linked issue exists and is open |
| 89 | +- Check if another open or merged PR also references the same issue |
| 90 | +- If two open PRs fix the same issue, flag both as `duplicate-fix` |
| 91 | + |
| 92 | +### 4. Build the report |
| 93 | + |
| 94 | +Write the combined report to `/tmp/issue-triage-report.md` using this format: |
| 95 | + |
| 96 | +```markdown |
| 97 | +<!-- agentic-ci-issue-triage --> |
| 98 | +## Repository Triage Report |
| 99 | + |
| 100 | +**Run date:** YYYY-MM-DD |
| 101 | +**Open issues:** N | **Open PRs:** N |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +### Issues: action needed |
| 106 | + |
| 107 | +Issues that need maintainer attention (potentially resolved, stale with no |
| 108 | +assignee, possible duplicates, needs-attention label). |
| 109 | + |
| 110 | +| # | Title | Category | Staleness | Flag | Notes | |
| 111 | +|---|-------|----------|-----------|------|-------| |
| 112 | + |
| 113 | +### Issues: active work |
| 114 | + |
| 115 | +Issues with assignees or linked open PRs. |
| 116 | + |
| 117 | +| # | Title | Category | Assignee | PR | Last updated | |
| 118 | +|---|-------|----------|----------|-----|-------------| |
| 119 | + |
| 120 | +### Issues: backlog |
| 121 | + |
| 122 | +Remaining open issues, ordered by staleness (most stale first). |
| 123 | + |
| 124 | +| # | Title | Category | Staleness | Last updated | |
| 125 | +|---|-------|----------|-----------|-------------| |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +### PRs: action needed |
| 130 | + |
| 131 | +PRs with health flags that need maintainer attention. |
| 132 | + |
| 133 | +| # | Title | Author | Flags | Notes | |
| 134 | +|---|-------|--------|-------|-------| |
| 135 | + |
| 136 | +### PRs: healthy |
| 137 | + |
| 138 | +Open PRs with no flags. |
| 139 | + |
| 140 | +| # | Title | Author | Linked issue | Last updated | |
| 141 | +|---|-------|--------|-------------|-------------| |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +### Summary |
| 146 | + |
| 147 | +**Issues:** |
| 148 | +- N triaged, N flagged for action, N active, N backlog |
| 149 | +- Flags: X potentially resolved, Y stale, Z duplicates |
| 150 | + |
| 151 | +**PRs:** |
| 152 | +- N triaged, N flagged |
| 153 | +- Flags: X no linked issue, Y checks failing, Z stale, W duplicate fixes |
| 154 | +``` |
| 155 | + |
| 156 | +### 5. Post the report |
| 157 | + |
| 158 | +Find the tracking issue number from the `ISSUE_TRIAGE_TRACKING_ISSUE` |
| 159 | +environment variable. Find the last comment by `github-actions[bot]` that |
| 160 | +contains `<!-- agentic-ci-issue-triage -->` and note its ID. |
| 161 | + |
| 162 | +- If a previous comment exists, **edit it in place** using |
| 163 | + `gh api -X PATCH repos/{owner}/{repo}/issues/comments/{id}`. |
| 164 | +- If no previous comment exists, post a new comment using `gh issue comment`. |
| 165 | + |
| 166 | +```bash |
| 167 | +# Edit existing comment |
| 168 | +gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" \ |
| 169 | + -f body="$(cat /tmp/issue-triage-report.md)" |
| 170 | + |
| 171 | +# Or post new comment |
| 172 | +gh issue comment "$TRACKING_ISSUE" --body-file /tmp/issue-triage-report.md |
| 173 | +``` |
| 174 | + |
| 175 | +## Constraints |
| 176 | + |
| 177 | +- **Read-only triage.** Do not close, label, or modify any issues or PRs. The |
| 178 | + report is for maintainers to act on. |
| 179 | +- **Do not post the report yourself if you cannot find the tracking issue.** |
| 180 | + Write the report to `/tmp/issue-triage-report.md` and stop. The workflow |
| 181 | + will handle fallback posting. |
| 182 | +- **Stay concise.** Notes columns should be one sentence max. Link to the |
| 183 | + relevant PR, issue, or duplicate - don't explain the fix. |
| 184 | +- **Cost awareness.** Do not read full issue/PR bodies unless needed to |
| 185 | + determine duplicates or verify cross-references. The metadata from |
| 186 | + `gh issue list` and `gh pr list` is enough for most checks. |
0 commit comments