gh-issues · git:20260925.1b994cf · 2026-09-25 · sha256 1e760ccaa469c796

gh-issues git:20260925.1b994cfA

Immutable. This exact content never changes and is served at /api/v1/blob/1e760ccaa469c796.

No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_qqm7c2y4bi2pkk72/1e760ccaa469c79663e84609d89ed4795db8371fde2f65ea74ab1b28a9a23a03.json

Then /plugin install gh-issues@markdownregistry-qqm7c2y4bi2pkk72 in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.

---
name: gh-issues
description: Walk over all open GitHub issues that are unassigned or assigned to the current user, and process each one via the gh-issue skill, sequentially.
argument-hint: "[--limit N] [--label foo] [--dry-run]"
disable-model-invocation: false
x-claude:
  allowed-tools: "Read, Bash(gh *), Bash(git *), Bash(go *), Bash(make *), Bash(./agnostic-ai *), Skill(gh-issue)"
---

# GitHub Issues Watcher

## Purpose

Process every open GitHub issue that is **unassigned** or **assigned to the current user (`@me`)**, one after another, by delegating each to the `gh-issue` skill. Stop on first hard failure so it can be inspected.

## Args

- `--limit N` — process at most N issues this run (default: all).
- `--label foo` — only issues carrying label `foo`.
- `--dry-run` — list issues that would be processed; do not invoke `gh-issue`.

Strip leading `#` if user passes `#123` style.

## Phase 1: Discover

Fetch open issues that are unassigned **or** assigned to `@me`, oldest first. GitHub search does not OR these cleanly, so run two queries and merge:

```bash
# Unassigned
gh issue list \
  --state open \
  --search "no:assignee" \
  --json number,title,labels,assignees,createdAt \
  --limit 200

# Assigned to me
gh issue list \
  --state open \
  --assignee "@me" \
  --json number,title,labels,assignees,createdAt \
  --limit 200
```

Merge:
- If either query returns 200 rows, repeat it with a larger `--limit` until the result count falls below that limit.
- Deduplicate by `number`.
- Keep only issues whose `assignees` array is empty **or** contains the current user (`gh api user -q .login`).
- Drop issues assigned to anyone else (defensive).
- Apply `--label` filter if given.
- Apply `--limit` if given.
- Sort ascending by `createdAt` (FIFO).

Print the queue: `#<num> <title> [assignee]` per line, where `[assignee]` is `unassigned` or `@me`. If empty, exit cleanly.

## Phase 2: Worktree Sanity

Before touching any issue:

```bash
test -z "$(git status --porcelain)" || exit 1
git fetch origin main
git switch main
test "$(git rev-list --count origin/main..main)" -eq 0 || exit 1
git pull --ff-only
```

Abort if the worktree is dirty or local `main` is ahead of `origin/main`. Never auto-stash or discard local commits.

## Phase 3: Process Loop

For each issue in the queue:

1. Re-check assignment state (someone else may have grabbed it):
   ```bash
   gh issue view <num> --json assignees -q '.assignees[].login'
   me=$(gh api user -q .login)
   ```
   - Empty output → unassigned, proceed.
   - Only `$me` listed → already mine, proceed (skip self-assign step).
   - Any other login present → skip this issue.

2. Invoke the `gh-issue` skill with the issue number. That skill owns:
   - self-assign via `gh issue edit <num> --add-assignee @me` (no-op if already assigned).
   - branch from fresh `main` (prefix from labels: `fix/`, `feat/`, `docs/`).
   - TDD implementation.
   - `go test ./...` green locally.
   - regen of derived artifacts (schema / sync / playground) when applicable.
   - changelog entry under `## [Unreleased]`.
   - commit with `Related to #<num>`.
   - final diff review before committing.
   - PR opened with `--assignee Chemaclass`, matching label, `Closes #<num>` in body.
   - CI checked, PR merged when allowed, and local `main` updated.

3. Confirm the PR merged and local `main` is clean. If the PR awaits approval or a check is red, stop and report its state. Otherwise continue with the next issue.

## Stop Conditions

Halt the loop and surface the failure when:

- `gh-issue` errors out or leaves the worktree dirty.
- `go test ./...` fails after implementation.
- `agnostic-ai sync --check` drifts after spec/adapter edits.
- CI stays red after one fix attempt.
- Merge is blocked by branch protection beyond `--admin` bypass.
- `--limit` reached.
- Queue empty.

Do **not** retry blindly. Report which issue failed and why.

## Dry Run

With `--dry-run`, only execute Phase 1 and print the queue. No assignment, no branching, no commits.

## Preconditions

- `gh` authenticated, can read issues, open and merge PRs.
- Worktree clean.
- `main` exists and tracks `origin/main`.
- `gh-issue` skill available in this session.

## Notes

- Treat GitHub CI as the full quality gate; locally run focused tests during implementation, full `go test ./...` once before commit.
- Never split bundled changes into multiple PRs unless the issue explicitly demands it.
- One concern per PR (`.agnostic-ai/rules/go-style.md`). Open separate PRs for refactors that the issue did not ask for.