agentleFS
jaskirat1616jaskirat1616/grok-skills/skills/ci-fix-loop/SKILL.md

ci-fix-loop

Skill22 starsChanged 2 months agoMITView on GitHub

Diagnose GitHub Actions CI failures in a loop: fetch the failing check logs, identify the root cause, apply a targeted fix, push, and wait for the next run: repeating until all checks are green or a real blocker needs a human. Use when CI is red after a push, when the user says "fix CI", "make tests pass", "diagnose CI failures", or "drive this to green". Direct analog of qodoloop / coderabbitloop for automated test and lint failures.

  • Installs packages
  • Commits and pushes

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stop if the working set is empty: all required checks are green.

    line 69
  2. Distinctive:

    Before touching any code, verify the failure is not already present on main:

    line 73
  3. Very specific:

    If the same check is failing on the base branch, stop and report: this is not your PR's fault.

    line 80
  4. Very specific:

    Wait for a Base branch recovered notice before re-trying.

    line 82
  5. Distinctive:

    Wait for the rerun result.

    line 119
  6. Very specific:

    Wait until all previously-failing checks show a new result (pass or fail) on the current SHA.

    line 175

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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

🤖 Auto-generated by weekly-pattern-learner · qodoloop and coderabbitloop share the push→poll→diagnose→fix→repeat loop; CI failures have the same shape but no dedicated skill existed

CI Fix Loop

Drive a GitHub Actions CI run from red to green: fetch failure logs, diagnose, apply a targeted fix, push, and repeat until all required checks pass or a blocker is hit.

Inputs

  • PR number (optional): detect from current branch if not given.
  • Check names (optional): limit to specific failing checks instead of all.
  • Max iterations (default: 5)

Workflow

1. Identify the PR and current CI state

# Detect PR from current branch
gh pr view --json number,headRefName,headRefOid \
  -q '{number, branch: .headRefName, sha: .headRefOid}'

# Current check status
gh pr checks --json name,state,conclusion 2>/dev/null \
  || gh run list --branch <branch> --limit 5

Classify each check as: pass, fail, pending, or skipped.

Exit immediately if all required checks already pass: nothing to do.

2. Loop (max 5 iterations)

A. Identify failing checks

gh pr checks --json name,state,conclusion \
  --jq '.[] | select(.conclusion == "failure" or .state == "FAILURE")'

For each failing check, record: check name, workflow file, job name.

Stop if the working set is empty: all required checks are green.

B. Check for base-branch regression first

Before touching any code, verify the failure is not already present on main:

gh run list --branch <base-branch> --workflow <workflow-name> --limit 3 \
  --json conclusion --jq '.[].conclusion'

If the same check is failing on the base branch, stop and report: this is not your PR's fault. Do not attempt a fix that masks a base-branch problem. Wait for a Base branch recovered notice before re-trying.

C. Fetch failure logs

For each failing check:

# Latest run ID for this branch/workflow
gh run list --branch <branch> --workflow <workflow-name> --limit 1 \
  --json databaseId --jq '.[0].databaseId'

# Fetch only failing steps (not the full log)
gh run view <run-id> --log-failed

Cap log reading at ~200 lines per job: the error is almost always in the last 50 lines of a failed step.

D. Diagnose

Classify the failure before writing any code:

CategoryExamplesFix target
Test failureFAIL TestFoo, AssertionError, expected X got YSource or test
Lint / formatgofmt, eslint, ruff, prettierRun auto-formatter
Build errorcompile error, missing import, type mismatchSource
Dependencynpm ERR!, missing module, lockfile mismatchUpdate lockfile
CI configYAML parse error, bad action ref, missing secretWorkflow YAML
Flaky testsame test passes on manual re-runRe-run first; mark if it keeps failing

For flaky-looking failures, re-run the check before touching code:

gh run rerun <run-id> --failed

Wait for the rerun result. If it passes on rerun, skip this iteration and go to step F to poll for the new result.

E. Apply a targeted fix

Fix only what the log names as the failure. Do not refactor surrounding code, add unrelated tests, or touch files the failing step never mentioned.

Common one-liners:

# Go format
gofmt -w .
goimports -w .

# Node format / lint
npx prettier --write .
npx eslint --fix .

# Python
ruff check --fix .
black .

# Lockfile
npm install          # Node
poetry lock --no-update  # Python
go mod tidy          # Go

For test failures: read the failing test and the code it exercises. Fix the code or the assertion, but not both in one commit unless the test was clearly wrong and the fix is trivial.

F. Commit and push

Stage only the files touched in step E: never git add -A, which can sweep in unrelated local changes:

git add <files touched>
git commit -m "fix(ci): <what was broken> (ci-fix-loop iteration N)"
git push

Confirm the push succeeded before polling. A resolved check whose fix never reached the branch is worse than an unresolved one.

G. Wait for CI on the new SHA

Poll every ~15s (timeout ~8min) for all previously-failing checks to complete on the new push:

gh pr checks --json name,state,conclusion,startedAt

Wait until all previously-failing checks show a new result (pass or fail) on the current SHA. Do not act on a result that still shows the old SHA.

Go back to step A.

3. Report

FieldValue
IterationsN
Checks fixednames + root cause
Checks blockednames + reason (flaky / needs human / base-branch red)
Final statusall green / partial / blocked
CI fix loop complete.
  Iterations:  2
  Fixed:       lint (gofmt: 3 files), test (TestUserCreate: nil pointer in fixture)
  Blocked:     none
  Status:      all required checks green

Chaining

Before this skillAfter this skill
olko:pr-description-writerolko:qodoloop
Any git push with failing CIolko:coderabbitloop

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.