Skip to content
Agent loop · Build & CI

CI Watch and Fix

A loop that watches the CI run on your pull request, reads the failing job's logs, pushes a focused fix, and waits for the next run to go green.

Up to 5 iterationsStop rules and safety limits
The prompt

Copy the CI Watch and Fix loop

Stops when every required check on the pull request reports success, or after 5 iterations. Edit the settings block, then paste the whole prompt into your agent.

ci-watch-and-fix.prompt.md
You are running the "CI Watch and Fix" loop on the current branch.

Settings (edit before running):
- Branch or pull request: the current branch
- Max fix pushes: 5
- Poll interval: 60 seconds, give up on a single run after 30 minutes

Goal: every required CI check on the pull request reports success.

Each iteration:
1. Find the newest CI run for this branch. If it is still running, wait and poll at the interval above.
2. If any required job failed, open the first one and read its logs. Quote the step name and the 5 to 15 lines that show the error.
3. If the failing command can run locally, run it to confirm the cause.
4. Make the smallest fix, commit it with a message like "ci: fix <job name>: <cause>", and push to the same branch.
5. Go back to step 1 and wait for the new run.

Stop when:
- All required checks pass. Success.
- You have pushed the max number of fixes.
- A failure is caused by infrastructure, secrets, quotas, or a flaky external service rather than the code. Report it instead of changing code.

Rules:
- Only push to this branch. Never force-push, never push to the default branch, never merge.
- Do not edit CI workflow files to skip, disable, or mark jobs as allowed to fail.
- Do not print secret values from logs or environment variables.
- Re-running a job is allowed once per failure when the logs point to a flaky network step.

Final report: a table of iterations with job name, cause, fix commit, and resulting status.
When to use it

When this loop fits

  • CI fails on checks you cannot easily run locally, such as a different OS, a database service, or an integration suite.
  • You pushed a branch and want the agent to follow it through CI while you work on something else.
  • A pull request is blocked by a long tail of small failures: lint in one job, a snapshot in another, a missing env var in a third.
How it works

What happens on each pass

The agent repeats these steps until the stop condition holds or it runs out of iterations.

  1. Find the latest run. Look up the CI runs for the current branch or pull request and wait until the newest one finishes.
  2. Read the failing logs. Open the first failing job and extract the step and error lines that explain the failure.
  3. Reproduce if possible. Run the same command locally to confirm the cause before editing anything.
  4. Push one focused fix. Commit a small fix with a message that names the job it addresses, then push to the same branch.
  5. Wait and re-check. Wait for the new run, then repeat until all required checks pass or the push limit is reached.
Recommended servers

MCP servers for this loop

The 6 strongest of 801 matching servers, ranked by how closely they fit and then by trust score.

More in Version control
  • Trust score 76 of 100, Good

    OpenOSINT

    by openosint · Python

    AI-powered OSINT agent & MCP server. 21 tools: email, breach, IP, WHOIS, DNS, Shodan, GitHub & more.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 16 days ago.
    1.8K stars—/wk weekly downloads— tools
  • Trust score 70 of 100, Good

    Github

    by pipeworx-io · TypeScript

    GitHub MCP — wraps the GitHub public REST API (no auth required for public endpoints)

    RegistryRemote
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 13 days ago.
    0 stars797/wk weekly downloads— tools
  • Trust score 69 of 100, Good

    SandboxAPIs

    by driftwork-llc · TypeScript

    Drop-in read-only replicas of GitHub, Jira, Slack and 22 more, preloaded with one fake company.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 19 days ago.
    0 stars266/wk weekly downloads— tools
  • Trust score 68 of 100, Good

    mcp-gitlab

    by vish288 · Python

    GitLab MCP server (MCP 2026-07-28): projects, MRs, pipelines, CI/CD, issues; writes or read-only

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 13 days ago.
    6 stars—/wk weekly downloads— tools
  • Trust score 68 of 100, Good

    GraphQL gateway for LLMs. Handles huge GitHub GraphQL & @neo4j/graphql schemas without crashing

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 12 days ago.
    6 stars—/wk weekly downloads— tools
  • Trust score 68 of 100, Good

    Gitlab Public

    by pipeworx-io · JavaScript

    GitLab Public MCP — wraps the GitLab REST API v4 (public endpoints, no auth)

    RegistryRemote
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 10 days ago.
    1 stars21/wk weekly downloads— tools
Run it

How to run this loop

  1. Connect the tools. Install a server the loop can use, for example OpenOSINT, or rely on your agent's built-in terminal and file access.
  2. Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
  3. Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
  4. Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
FAQ

CI Watch and Fix questions

When does the CI Watch and Fix loop stop?

It stops as soon as every required check on the pull request reports success. It also stops after 5 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.

Which CI systems does this loop work with?

Any CI the agent can read. GitHub and GitLab MCP servers expose workflow runs and job logs directly, and CLI tools such as gh or glab work too. For Jenkins, CircleCI, or Buildkite, install a server for that system or give the agent its CLI.

Is it safe to let an agent push to my branch?

Scope it tightly. Use a fine-grained token that can push to the repository but cannot bypass branch protection, keep required reviews on the default branch, and keep the push cap low. The loop only ever pushes to the feature branch and never merges.

Keep exploring
All loops