--- name: haci-issue-triage description: >- Work through a backlog of GitHub issues on this repository — categorize, then walk bugs and feature requests one at a time, fixing approved ones on a branch through a pull request instead of committing straight to main. Use when asked to "triage my issues", "go through the issue backlog", "work through the issues", "let's triage", or invoked via the `haci-issues` skill. This is opt-in tooling for backlog work, not a replacement for the normal ad-hoc flow in AGENTS.md — a single "fix this bug" request in conversation still goes through that flow, not this one. SYMPTOMS — load this if you are about to: fix several issues in a row by committing each straight to main with nobody reviewing between commits; dump the whole backlog in one message instead of walking it one issue at a time; merge a pull request this flow opened without either explicit confirmation or an explicit full-autonomy invocation; bump a version by hand; or skip the breaking-changes warn-first check on an issue fix that needs it. --- # Issue triage and branch/PR-based fixing A backlog-scale companion to the project's ad-hoc flow in `AGENTS.md` — typically: commit on explicit request, no push. That flow is still correct for a single request handled live with the developer watching. This skill is for the different situation: working through several issues in a row, where a branch + pull request + green CI is the review surface, because nobody is watching each individual commit in real time. Both are legitimate; pick based on whether you're handling one request or a backlog, not out of habit. ## Merge autonomy — read this before the fix flow below By default, **ask for explicit confirmation before merging** any pull request this flow opens — merging is a shared-state, hard-to-reverse action, and a backlog run touches several of them in a row. Skip that per-PR confirmation, and merge automatically on green CI, only when this session was entered through a dedicated entry point built for full autonomy — a command that exists specifically to invoke this flow (such as `haci-issues`, which only the developer invokes), or an explicit instruction scoped to the session ("auto-merge these", "don't ask me each time today"). Ad-hoc conversational use of this skill — "hey, can you triage my issues" — always asks. State which mode you're in once, at the start of a run, rather than leaving it implicit. ## Concurrency: running more than one instance on the same repo If nothing else is touching this backlog concurrently, skip this section — claim/release below are harmless no-ops. It exists for when you might be one of several agent sessions working the same repo at once. **Instance ID:** generate one ID of the form `-` (`` `date +%s` `` seconds, plus a random suffix) at the start of a run, show it, and reuse the literal value in every later command — shell variables do not survive between separate tool calls. The lock label is `wip:`; the epoch doubles as its creation timestamp for the TTL below. **Locked** means an issue carries a _foreign_ `wip:-*` label whose epoch is younger than 6 hours. Don't touch those — list them, move on. A foreign lock older than 6 hours is orphaned and does not lock (see "Expired locks"). **Claim** (before any write to an issue — categorize, fix, comment, snooze; plain viewing needs no lock): 1. `gh issue view N --json labels` — a foreign non-expired `wip:*` already there? It's taken; say so, move on. 2. Ensure both labels exist with `gh label create "in progress" --color fbca04 --force` and `gh label create "wip:" --color 5319e7 --force`, then `gh issue edit N --add-label "wip:" --add-label "in progress"`. 3. **Race check:** view the labels again. Several `wip:*` present → the lexicographically smallest ID wins. Not the smallest → remove your label, tell the developer, move on. Otherwise you hold the lock. **Release** immediately after a quick write (categorize/comment/snooze); hold it through a fix until merge. Release with `gh issue edit N --remove-label "wip:" --remove-label "in progress"` (a merged fix closes the issue anyway). **Expired locks (TTL 6h):** `now − epoch > 21600` → orphaned. Remove the foreign label, then claim normally with your own ID. **Label cleanup:** whenever a `wip:` label is removed (release, race back-off, `unlock`, expired takeover) and no open issue still carries it, delete the label definition too (`gh label delete "wip:" --yes`) so `wip:*` doesn't pile up. ## Dispatch - `locks` — list open issues carrying a `wip:*` label (number, title, holding ID); mark ones older than 6h "(expired, treated as free)". Nothing else. - `unlock ` — show the issue's `wip:*`/`in progress` labels, confirm, remove them. - a bare issue number — skip triage, show the issue and its comments, get the developer's read on it before writing any code (plan mode / a quick back-and-forth, not straight into the fix flow). - `stop` / `drain` (as an argument, or said mid-run) — see "Graceful stop" below. - no argument — the full flow below (generate the instance ID first if concurrency applies). ## Phase 0 — prerequisites and scope (counts only) List the repository labels first. Create the workflow label once with `gh label create "in progress" --color fbca04 --force`; claims depend on it and must not fail halfway through. Resolve the two category labels from what is actually present: prefer `bug` for defects and `enhancement` for feature work, fall back to `Feature request` if that is the repository's convention, and ask when several plausible labels remain. Reuse those exact names for the whole run. Then run `gh issue list --state open --limit 1000 --json number,title,labels,assignees,author`. Run the snooze wake pass (see below) and set aside issues with a foreign, non-expired `wip:*`. Report only counts — how many need categorizing, how many bugs, how many feature requests, one line each for anything that woke up or is locked elsewhere. Do not enumerate the backlog; go straight into the per-issue walk. If the repository has more than 1,000 open issues, say that this is the first batch rather than presenting the counts as complete. ## Phase 1 — categorize Use the defect and feature labels resolved in Phase 0. Walk the uncategorized issues one at a time: 1. A short summary (2–3 sentences) of what the issue wants. 2. A weak title? Suggest a better one. 3. Ask about **only this issue**, with a reasoned recommendation (bug vs. feature request; `question`/`duplicate`/ `wontfix` when in doubt), fold an optional title change into the same question. Wait for the answer. 4. After the decision: claim, `gh issue edit N --add-label "