agentleFS
BiswaVirajBiswaViraj/agent-skills/skills/ciloop/SKILL.md

ciloop

Skill0 starsChanged 5 months agoMITView on GitHub

Use when CI is failing on a branch/PR and the user wants it driven back to green — "fix the failing CI", "CI is red, sort it out", "make the checks pass", "loop until CI is green". Pulls the real error from the failing GitHub Actions logs, reproduces it locally, fixes the confident failures, pushes once, and re-watches until green. The red-CI twin of reviewloop.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 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.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read the actual error from --log-failed — not just "job X failed".

    line 71
  2. Very specific:

    Run that exact command locally (e.g.

    line 86
  3. Distinctive:

    Only after every fixable job is green locally:

    line 93
  4. Distinctive:

    Only hand-back failures remain → stop and report (don't burn iterations on what you won't fix).

    line 116
  5. Distinctive:

    If stopped at max iterations or on hand-back failures, list each remaining failure with its real error and a suggested next step.

    line 140

≈ “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

Ciloop

Drive a failing CI run to green. Pull the real error from the logs, reproduce it locally, fix the failures you're confident about, push once, and confirm — looping until green.

Core principle: CI is slow and costs minutes, so don't use it as your edit-test loop. Reproduce the failure locally, fix until local is green, then push once. And don't flail: fix what you can diagnose with confidence; for failures you can't (flaky, infra, secrets, ambiguous logic), stop and hand back rather than guess. Loop the fixable; hand back the judgment calls.

When to use

  • A push/PR has red checks and you want them green without babysitting each run.
  • "Fix the failing CI", "make the checks pass", "CI is red, loop until it's clean".

When NOT to use: You only want to read why CI failed without fixing → just gh run view --log-failed. The failures are all infra/deploy/flaky (nothing to fix in code) → ciloop will just hand those back.

Classify every failure first

CategoryExamplesAction
Confident-fixlint, format/prettier, type errors (tsc), clear test/assertion failures, missing import, obvious compile errorreproduce locally → fix → loop
Hand-backflaky/non-deterministic tests, infra/network timeouts, missing secrets/credentials, deploy/release steps, ambiguous logic failures you can't pin downdon't touch — record the real error + why, report at the end

A step that can't run locally (needs live services, secrets, a built artifact) is hand-back, not a guess. Never push a speculative fix for something you couldn't reproduce.

Inputs

  • branch / PR (optional): default = current branch.
  • --max-iterations N (optional, default 5): cap on the fix→push→watch loop.

The loop

0. Find the red run

BRANCH=$(git rev-parse --abbrev-ref HEAD)
HEAD_SHA=$(git rev-parse HEAD)
gh run list --branch "$BRANCH" --limit 5 \
  --json databaseId,headSha,status,conclusion,workflowName

Pick the most recent run for HEAD_SHA. If it's success → report "already green" and stop. If still in_progress → wait (gh run watch). See references/gh-ci.md.

1. Pull the real failures

gh run view <run-id> --json jobs \
  --jq '.jobs[] | select(.conclusion=="failure") | {name, steps: [.steps[] | select(.conclusion=="failure") | .name]}'
gh run view <run-id> --log-failed

Read the actual error from --log-failed — not just "job X failed". Find the line that caused it.

2. Classify each failing job (table above)

Split into fix and hand-back. If there are zero fixable failures, skip to the report.

3. Reproduce + fix locally

For each fixable job, map it to its local command by reading the workflow that ran it:

# find the failed step's exact command
cat .github/workflows/*.y*ml   # locate the failing job → its `run:` step

Run that exact command locally (e.g. pnpm lint, pnpm typecheck, pnpm test <file>), read the error in context, fix the root cause, and re-run the command until it passes locally. Repeat per fixable job. (If the YAML is a composite/opaque action, fall back to the obvious local command for the job's purpose — but if you can't reproduce it, treat it as hand-back.)

4. Push once

Only after every fixable job is green locally:

git add -A
git commit -m "fix CI: <what failed> (ciloop iteration N)"
git push

One push per iteration — not one per fix.

5. Confirm the re-run

git rev-parse HEAD   # new sha — watch THIS run, not the stale one
gh run watch <new-run-id> --exit-status

Guard against acting on a stale run: only evaluate the run whose headSha matches the new local HEAD.

6. Exit conditions

  • New run is green → done.
  • Still red with fixable failures → back to step 1, until --max-iterations.
  • Only hand-back failures remain → stop and report (don't burn iterations on what you won't fix).

Common mistakes

MistakeFix
Using CI as the edit-test loop (push every fix)Reproduce locally, fix to local-green, push once.
Pushing a fix you couldn't reproduce locallyIf it won't run locally, it's hand-back — don't guess.
Reading "job failed" but not the actual errorAlways --log-failed and find the causing line.
Watching the old run after pushingRe-resolve the run id for the new HEAD sha before watching.
Looping forever on a flaky/infra failureClassify it hand-back; stop and report instead.
"Fixing" a flaky test by rerunning until it passesThat's hand-back — report it; don't mask flakiness.

Report

Ciloop complete.
  Branch:      eng-522-migrate-the-voice_service
  Iterations:  2
  Fixed:       lint (3 files), typecheck (1 error), unit test auth.spec.ts
  Handed back: e2e job — flaky (timeout on external service), not a code issue
  Final CI:    green ✅

If stopped at max iterations or on hand-back failures, list each remaining failure with its real error and a suggested next step.

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.