agentleFS
gssajithgssajith/claude-skills/skills/fix-repo/SKILL.md

fix-repo

Skill2 starsChanged 4 months agoMITView on GitHub

Triage every open GitHub issue in one repo, auto-fix and open a reviewed PR for whatever is safe to fix without human judgment, and set aside anything that genuinely needs a human decision. Trigger: /fix-repo <reponame>

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 7 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Scope guard: <org> org only: If the target repo's GitHub owner isn't <org>, stop before doing anything else — do not sync, do not list …

    line 14
  2. Very specific:

    Read the remote and extract owner/repo:

    line 37
  3. Very specific:

    Scope guard: if $owner is not exactly <org>, stop immediately and tell the user this skill only operates on <org> org repos — take no …

    line 45
  4. Distinctive:

    If this prints anything at all, stop and ask the user how to proceed — never stash or discard automatically.

    line 55
  5. Distinctive:

    If this errors (no access, rate limit), stop and report the error — do not guess at the issue list.

    line 70
  6. Distinctive:

    No PR, no branch, no code change.

    line 110
  7. Distinctive:

    Every remaining issue (reproduces, and classified auto-fixable) carries forward into Step 5.

    line 125
  8. Distinctive:

    Write a failing test reproducing the issue.

    line 153
  9. Very specific:

    Run the full test suite for the affected package/module.

    line 156
  10. Distinctive:

    Do not merge: Leave the PR open and approved.

    line 198
  11. Distinctive:

    Do not poll or wait for the merge inside this run — that could block indefinitely on someone else's schedule.

    line 210

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

fix-repo

Works through every open issue in one repo in a single run: triages each one, fixes and opens a PR for everything judged safe (implemented with TDD, independently reviewed by a separate adversarial subagent before the PR opens), and sets aside anything that needs a human decision instead of guessing. Nothing merges automatically — every PR this skill opens waits for a human to click merge on GitHub, even after an automated approval.

Scope guard: <org> org only. If the target repo's GitHub owner isn't <org>, stop before doing anything else — do not sync, do not list issues, do not touch the repo.

Announce at start: "Using fix-repo to triage and fix issues in <reponame>."

Step 1: Resolve the target repo and enforce the scope guard

<reponame> is a local directory name (not a URL) — the argument to /fix-repo.

Find it as a workspace subdirectory with a .git present:

repo_dir="<reponame>"
if [ ! -d "$repo_dir/.git" ]; then
  echo "No local checkout named '$repo_dir' found here."
fi
  • Not found → stop and ask the user for the correct directory name. Do not guess, and do not speculatively gh repo clone — unlike fix-issue, there's no issue URL here to derive a clone target from, so a wrong guess could clone the wrong thing.
  • Found → continue.

Read the remote and extract owner/repo:

remote=$(git -C "$repo_dir" remote get-url origin 2>/dev/null)
slug=$(echo "$remote" | sed -E 's#\.git$##; s#.*[:/]([^/]+/[^/]+)$#\1#')
owner="${slug%%/*}"

Scope guard: if $owner is not exactly <org>, stop immediately and tell the user this skill only operates on <org> org repos — take no further action (no sync, no issue list, nothing). This check must run before Step 2.

Step 2: Sync

git -C "$repo_dir" status --short

If this prints anything at all, stop and ask the user how to proceed — never stash or discard automatically. Only continue once the tree is confirmed clean.

default_branch=$(git -C "$repo_dir" remote show origin | grep "HEAD branch" | awk '{print $NF}')
git -C "$repo_dir" checkout "$default_branch"
git -C "$repo_dir" pull

Step 3: Triage every open issue

gh issue list --repo "$slug" --state open --json number,title,body,labels,url

If this errors (no access, rate limit), stop and report the error — do not guess at the issue list.

For each open issue, dispatch one subagent (Agent tool, in parallel across issues — same pattern as file-issue's per-repo audit dispatch) with this exact brief:

"Given this GitHub issue (title, body, comments, labels), read the implicated code on the current default branch of $repo_dir — code-read only, never start services or run the app — and answer three things:

  1. Still reproduces? Reason explicitly about whether the described behavior is still present given what the code does today.
  2. Auto-fixable, or human-required? Answer human-required if any of these is true:
    • The issue is ambiguous or underspecified — you cannot determine a concrete correct fix without guessing at intent.
    • The fix would touch DB schema, migrations, or data deletion/backfill.
    • The fix would touch auth, RBAC, tenant isolation, or secrets handling.
    • The fix would break a public API, a cross-repo contract (e.g. <org>-app-contracts), or require a coordinated multi-repo change. When in doubt, answer human-required — this bar exists to keep blast radius small, not to maximize how much gets auto-fixed. If human-required, name exactly which criterion above it tripped.
  3. Implicated files — the concrete file paths a fix would touch. Best-effort; doesn't need to be exhaustive.

Report your answer as: reproduces (yes/no), classification (auto-fixable/human-required), criterion (if human-required), implicated_files (list of paths)."

Collect every subagent's verdict before moving on to Step 4. Keep the full per-issue result set (issue number, verdict, implicated files) in context — Step 5 (clustering) and Step 6 (per-issue fix) both consume it directly.

Step 4: Close already-fixed issues, label human-required ones

For every issue where the Step 3 triage found it no longer reproduces:

gh issue close <number> --repo "$slug" --comment "<what changed, or why the described behavior can no longer occur, per the triage subagent's reasoning>"

No PR, no branch, no code change. Record it for the final report.

For every issue triaged human-required:

gh label list --repo "$slug" --limit 200 | cut -f1 | grep -qxF "needs-human" || \
  gh label create "needs-human" --repo "$slug" --color "d876e3" --description "Set aside by fix-repo — needs a human decision, not auto-fixed"
gh issue edit <number> --repo "$slug" --add-label "needs-human"
gh issue comment <number> --repo "$slug" --body "fix-repo set this aside: <the criterion it tripped, from Step 3>."

Take no further action on this issue this run. Record it (issue number + criterion) for the final report. If the label-create or issue-edit calls fail (permissions), don't block the rest of the run — report which issues didn't get labeled.

Every remaining issue (reproduces, and classified auto-fixable) carries forward into Step 5.

Step 5: Cluster the auto-fixable issues by file overlap

This is plain computation over the Step 3 triage output — not a subagent call.

Build clusters from the auto-fixable issues' implicated_files lists: two issues belong to the same cluster if they share at least one implicated file, applied transitively (if issue A shares a file with B, and B shares a file with C, then A, B, and C are all one cluster even if A and C share no file directly). A simple way to compute this: treat each issue as a node, add an edge between any two issues that share a file, and take connected components as clusters.

  • A cluster with exactly one issue, or clusters that share no files with each other, are independent — safe to process concurrently in Step 6.
  • A cluster with more than one issue must be processed sequentially, in a stable order (e.g. ascending issue number) — Step 7 handles what happens after the first one.

Step 6: Fix, review, and open a PR — one issue at a time per cluster

Process clusters from Step 5: independent clusters concurrently, issues within one cluster one at a time in the stable order chosen in Step 5. For each auto-fixable issue:

  1. Implement with TDD, writing an inline spec first (same sections as fix-issue's spec — Problem, Root cause, Proposed fix, Affected files, Risks/edge cases, Test plan — saved to $repo_dir/docs/issue-fixes/<repo>-<issue_number>-spec.md, same convention fix-issue uses). Then:
    • Write a failing test reproducing the issue; run it, confirm it fails for the expected reason.
    • Implement the fix described in the spec.
    • Run the full test suite for the affected package/module. Branch is cut from the current default-branch tip (git checkout "$default_branch" && git pull right before branching) so it includes any earlier PR from this same run that has already merged.
  2. Independent adversarial review. Dispatch a fresh subagent (Agent tool) that is not the implementer and has not seen the implementer's reasoning — only the issue text, the spec file, the diff (git diff "$default_branch"), and the test run output. Brief:

    "You are reviewing this fix adversarially — your job is to find reasons to reject it, not to rubber-stamp it. Given the issue, the spec, the diff, and the test output, decide APPROVE or REQUEST-CHANGES. If REQUEST-CHANGES, give concrete, specific reasons tied to exact lines or exact spec sections — not general concerns."

    • REQUEST-CHANGES → the implementer retries, addressing the specific feedback. Cap: 2 retry attempts (3 tries total). Still not approved, or the suite is still red, after that → treat this issue exactly like Step 4's human-required path: apply the needs-human label, comment with the reviewer's final reasoning, no PR opens. Record it for the final report and move to the next issue.
    • APPROVE → continue to step 3.
  3. Open the PR:

    branch="fix/issue-<issue_number>-<short-slug>"
    git -C "$repo_dir" checkout -b "$branch"
    git -C "$repo_dir" add <changed files> "docs/issue-fixes/<repo>-<issue_number>-spec.md"
    git -C "$repo_dir" commit -m "fix: <one-line summary>
    
    Fixes #<issue_number>"
    git -C "$repo_dir" push -u origin "$branch"
    gh pr create --repo "$slug" --title "<title>" --body "Fixes #<issue_number>. See docs/issue-fixes/<repo>-<issue_number>-spec.md for the fix spec." --base "$default_branch"

    Then post the reviewer's approval as a real GitHub review, not just a comment, so it's visible on the PR itself:

    gh pr review <pr-number> --repo "$slug" --approve --body "<the adversarial reviewer's approval reasoning>"
  4. Do not merge. Leave the PR open and approved. Move immediately to the next issue — do not wait here for a human to merge it.

Step 7: Handle cluster conflicts

Within a cluster with more than one issue, only the first issue (in the Step 5 stable order) gets a PR opened this run. For every remaining issue in that same cluster:

gh issue comment <number> --repo "$slug" --body "Queued behind PR #<first-issue-pr-number> in this same repo (same-file conflict). Re-run \`/fix-repo <reponame>\` after merging it to continue with this issue."

Do not poll or wait for the merge inside this run — that could block indefinitely on someone else's schedule. A future /fix-repo <reponame> invocation re-triages from scratch and will pick these up once the blocking PR has actually merged (they'll no longer show as conflicting with anything already on the default branch).

Step 8: Report

Summarize the run in four groups:

  • PRs opened and approved, ready for your merge click — list URL + title, in cluster/dependency order.
  • Issues closed as already-fixed — issue number + one-line reason.
  • Issues labeled needs-human — issue number + which criterion it tripped (or, for ones dropped after failed review, the reviewer's final reasoning).
  • Clusters partially blocked — the first PR's link, and the remaining queued issue numbers in that cluster.

Error handling

SituationBehavior
<reponame> not found locallyStop, ask — no speculative clone
Repo owner isn't <org>Stop immediately, before any other step
Uncommitted changes before syncStop, ask — never auto-stash/discard
Issue no longer reproducesClose with explanation, no PR, report
Issue fails the human-required barLabel needs-human, comment why, no fix attempt
Reviewer requests changes twice (3 tries total)Drop to needs-human with reviewer's reasoning, no PR
Test suite red after implementation/retriesSame as above — never open a PR on a red suite
Cluster has 2+ conflicting issuesOpen first PR only; queue the rest with a pointer comment
gh collaborator/label calls fail (permissions)Don't block the run; report what wasn't applied

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.