agentleFS
d-oitd-oit/rust-2026-template/.agents/skills/self-fix-loop/SKILL.md

self-fix-loop

Skill15 starsChanged 5 months agoMITView on GitHub

Self-learning fix loop - commit, push, monitor CI, auto-fix failures using swarm agents with skills on demand, loop until all checks pass. Supports GitHub Actions and GitLab CI. Use when CI fails and you need to iteratively fix until green. Triggers: "fix CI", "loop until green", "auto-fix failures", "self-fix".

  • Deletes or force-pushes
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

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

  • 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. Distinctive:

    Self-Fix Threshold: If 2+ similar errors occur during the loop, pause and diagnose the root cause before attempting another fix.

    line 24
  2. Very specific:

    If the current branch is part of a gh stack (check: gh stack view --json 2>/dev/null succeeds):

    line 119
  3. Distinctive:

    Commit fixes as NEW commits — never amend stacked commits

    line 121
  4. Very specific:

    Run gh stack rebase --upstack to propagate changes to dependent branches

    line 122
  5. Very specific:

    Run gh stack push to update all dependent PRs

    line 123
  6. Very specific:

    Do NOT use git push --force on stacked branches — use gh stack push instead.

    line 125
  7. Distinctive:

    Do NOT use git commit --amend — it breaks upstack branch ancestry.

    line 126

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

Self-Fix Loop Skill

When to Use

Automated self-learning cycle: commit → push → monitor → analyze failures → fix → retry until all CI checks pass.

Self-Fix Threshold: If 2+ similar errors occur during the loop, pause and diagnose the root cause before attempting another fix.

Overview

Continuous improvement loop that:

  1. Commits all changes atomically
  2. Pushes to feature branch
  3. Creates/updates PR/MR
  4. Monitors CI (GitHub Actions or GitLab CI)
  5. On failure: diagnoses and fixes
  6. Repeats until ALL checks pass

Platform Detection

Auto-detect from git remote:

REMOTE=$(git remote get-url origin)
if echo "$REMOTE" | grep -qi "github"; then
  PLATFORM="github"; CLI="gh"
elif echo "$REMOTE" | grep -qi "gitlab"; then
  PLATFORM="gitlab"; CLI="glab"
fi

CLI Command Mapping

ActionGitHub (gh)GitLab (glab)
Check CIgh pr checksglab ci status
Create PR/MRgh pr createglab mr create
View logsgh run view --log-failedglab ci view

Arguments

ArgumentDescriptionDefault
--max-retries NMaximum fix iterations5
--platform github|gitlabForce platformauto-detect
--auto-researchUse web research on failurestrue
--fix-issuesAttempt automatic fixestrue
--strict-validationALL checks must passtrue
--timeout SECONDSPer-iteration timeout1800
--dry-runSimulate without pushingfalse

Loop Phases

[Start]
   ↓
Phase 1: COMMIT & PUSH
   - Stage all changes
   - Run quality gate
   - Atomic commit
   - Push to feature branch
   ↓
Phase 2: CREATE/UPDATE PR/MR
   - Create new PR/MR or update existing
   ↓
Phase 3: MONITOR CI
   - Poll GitHub Actions / GitLab CI
   - Wait for all checks complete
   ↓
Phase 4: ANALYZE FAILURES
   - Identify failed checks
   - Extract error messages
   - Categorize failure type
   ↓
Phase 5: FIX (if failures)
   - Diagnose root cause
   - Apply fixes
   - Commit fix
   ↓
Phase 6: RETRY LOOP
   - If retries remaining → Phase 1
   - If max retries → FAIL
   - If all pass → SUCCESS

Rust Failure Types

Failure TypeAction
cargo fmtRun cargo fmt --all
cargo clippyFix warnings, respect -D warnings
cargo testDebug test failures, fix or skip flaky
cargo auditUpdate vulnerable dependency (refer to .agents/ci/regression-matrix.json)
cargo denyFix license or advisory violations (refer to .agents/ci/regression-matrix.json)
markdownlintFix heading increments/links (refer to .agents/ci/regression-matrix.json)
gitleaksRemove secret or add exception (refer to .agents/ci/regression-matrix.json)
cargo macheteRemove unused dependencies
Linker errorsCheck build-essential, pkg-config

Stacked PR Interaction

If the current branch is part of a gh stack (check: gh stack view --json 2>/dev/null succeeds):

  1. Commit fixes as NEW commits — never amend stacked commits
  2. Run gh stack rebase --upstack to propagate changes to dependent branches
  3. Run gh stack push to update all dependent PRs

Do NOT use git push --force on stacked branches — use gh stack push instead. Do NOT use git commit --amend — it breaks upstack branch ancestry.

Rationalizations

RationalizationReality
"The loop is stuck, I'll just force merge"Force merging defeats the purpose of CI and introduces regressions.
"One more retry should fix it"Repeated identical failures indicate a root cause, not a flaky test.
"I'll disable strict validation to pass faster"Strict validation catches issues early; disabling it pushes bugs to production.

Red Flags

  • Exceeding max retries without diagnosing root cause
  • Disabling strict validation to bypass failing checks
  • Force merging when the self-fix loop reports failure
  • Using git commit --amend or git push --force on stacked branches (use gh stack push instead)

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.