self-heal-ci
Skill0 starsChanged 4 months agoMITView on GitHub
Detect a red CI and relay \"fix → re-verify\" until CI is green, BOUNDED by an attempt cap. A goal-loop wrapper whose stop condition is a deterministic gate (gh conclusion=success), not the model's self-report. Triggers: self-heal-ci, self heal ci, CI self-heal, red CI heal, fix failing CI, keep fixing CI until green.
In this repository46 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- a11y-standardsSkill
- a11y-static-gateSkill
- adversarial-refute-voteSkill
- antigravity-buildSkill
- architecture-parity-gateSkill
- ci-required-check-installerSkill
- codex-buildSkill
- codex-imagegenSkill
- codex-spark-delegateSkill
- commit-convention-gateSkill
- commit-msg-quality-scoreSkill
- consumer-finding-ledgerSkill
- context-bloat-trackerSkill
- coverage-floor-lockSkill
- destructive-env-guardSkill
- dev-standardsSkill
- eval-dataset-buildSkill
- eval-regression-guardSkill
- fanout-verify-synthSkill
- gate-forgeSkill
- hallucination-rate-meterSkill
- harness-kpi-ledgerSkill
- judge-rubric-voteSkill
- knowledge-citation-coverageSkill
- knowledge-dedup-scanSkill
- knowledge-index-guardSkill
- live-state-verify-guardSkill
- maker-checker-relaySkill
- memory-distillSkill
- mistake-rule-distillSkill
- oneshotSkill
- prompt-ab-evalSkill
- report-shapeSkill
- retry-failure-classifierSkill
- review-finding-reproSkill
- rule-dedup-scanSkill
- rule-promote-auditSkill
- rule-promotion-extractSkill
- secret-scan-hardeningSkill
- session-length-compact-auditSkill
- startSkill
- subagent-usage-analyzerSkill
- task-success-rate-trackSkill
- token-codegen-gateSkill
- trigger-vocab-dedupSkill
The file
Files
self-heal-ci
A wrapper over scripts/goal-loop.sh (the stop primitive) that self-heals a red CI:
when the latest run is red it relays "fix → re-verify" until CI is green, or until an
attempt cap is reached. The stop / counting discipline is delegated to goal-loop.sh — this
wrapper only drives detection and the fix cycle, it never loops forever on its own.
The goal test is a single deterministic point: gh run list -L1 → latest run's
conclusion == "success". Everything else (failure / cancelled / timed_out /
null=in-progress / ""=fetch failed) is treated as red (fail-safe — an empty gh
result is "red (unknown)", never "0 runs / green"). "Done" is decided by that gate's exit
code, never by the model reporting "I fixed it".
How to run
- From the target repository's working tree (or with
--repo O/R), start the loop:bash "${CLAUDE_PLUGIN_ROOT:-.}/scripts/self-heal-ci.sh" [--repo <owner/repo>] [--max <N>] [--escalate-file <path>] - Each round the wrapper calls
goal-loop.shand measures whether the latest run is green:- green (exit 0) → ✅ done, stop.
- red & under cap (exit 1) → run ONE fix cycle. If
claudeis on PATH it runs headless (one fix = feature branch + PR, followingCYCLE-PROMPT.md). WithDRY_RUN=1or noclaudeon PATH it is gate-only: it returnsexit 1so an outer caller fixes and re-runs. - cap reached (exit 2) → escalate (see below) and stop, so it never burns tokens forever.
- Fixes are PR-only. No self-merge / tag push / push to main — that boundary lives in
CYCLE-PROMPT.md(the prompt the fix agent reads). - The Verifier of "is it really green?" is a deterministic gate, not the fixer. Independent
review of the actual diff can be done by the kit's
dev-revieweragent (read-only), a/reviewsession, or a human.
Modes / options
| Flag / env | Meaning |
| (none) | run the self-heal loop (default) |
--repo O/R | target repository (defaults to the cwd repo) |
--max N | attempt cap (default 5; SELF_HEAL_MAX env also works) |
--escalate-file <path> | on CAP, append the escalation line here instead of stdout (SELF_HEAL_ESCALATE_FILE env also works) |
--state <path> | where the attempt counter persists (SELF_HEAL_STATE env; default .self-heal-ci.state) |
--ci-check | exit 0 if latest run is green, exit 1 if red (the body of goal-loop's --check) |
--self-test | gh-independent deterministic self-test (exit 0 = PASS) |
DRY_RUN=1 | gate-only: detect once and exit; do not launch claude (smoke test) |
Escalation sink
On CAP the wrapper prints a single escalation line to stdout by default. Pass
--escalate-file <path> (or set SELF_HEAL_ESCALATE_FILE) to append it to a file of your
choice instead — e.g. an action list, a log, or an issue body draft. No path is hardcoded.
Deterministic --check (self-test)
The skill / script's own health is machine-verified without any dependency on gh:
bash "${CLAUDE_PLUGIN_ROOT:-.}/scripts/self-heal-ci.sh" --self-test- exit 0 = PASS. It verifies (no hardcoded success):
bash -n(its own syntax).- that it references
goal-loop.shand that the stop primitive exists. - the
ci_conclusion_okpredicate on fixtures (onlysuccessis green; every other value, including empty andSUCCESS, is red). - the
--ci-checkpath end-to-end with a fake gh (hermetic fixture):success→exit0 /failure→exit1 / empty→exit1 (fail-safe).
- non-zero: a gap in the conclusion truth table, the wiring, or syntax.
When to use / not
- ✅ A repo has a red CI you want driven to green with a bounded, deterministic stop.
- ❌ No
gh-reported CI, or a one-off manual fix that needs no re-verify loop (use/build).
Related
- primitive:
scripts/goal-loop.sh(exit 0=GOAL MET / 1=CONTINUE / 2=CAP REACHED) - wrapper:
scripts/self-heal-ci.sh(--ci-check/--self-test/--repo/--max/--escalate-file) - fix cycle prompt:
skills/self-heal-ci/CYCLE-PROMPT.md - Verifier role: the
dev-revieweragent (read-only), a/reviewsession, or a human - command:
/goal-loop; the green-CI pattern lives inexamples/ci/all-checks-pass-pattern.md
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
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.

