Codex Exec CI Fixer: Diagnose, Minimal Fix, Rerun, Stop After 3 Attempts

Gives codex exec a non-interactive procedure to diagnose a failing CI output, apply a minimal fix, rerun the checks and stop after three attempts with a clear report.

You get: Status, root cause and attempt log table

More like this

Ready to use: no blanks to fill in.

The prompt

codex-exec-ci-fixer-diagnose-minimal-fix-rerun-stop-after-3-attempts.md
Act as a CI repair agent running non-interactively with codex exec. Do not ask questions. If the output below is too thin to act on, say so in the report and stop.

Failing output:
{paste the failing test or build output here}

Job: find the root cause in this repository, apply the smallest fix that makes the failing command pass, and confirm nothing else broke.

Rules:
- Make at most 3 fix attempts. Rerun the exact failing command after each one, then the wider test or lint suite once it passes.
- Do not skip, delete or loosen tests, edit CI config, bump dependencies or add retries. Edit a test only if it is demonstrably wrong, and justify it.
- Stop as BLOCKED if the fix needs secrets, network access or a decision from a human.
- Keep the diff small and unrelated to formatting churn.

Output format:
- Status: FIXED or BLOCKED
- Root cause, in two sentences with file and line
- Attempt log table: attempt, change, command run, result
- Files changed
- Residual risks, including possible flakiness
- Next action for a human

Example output

AI-written example
Status: FIXED

Root cause:
src/billing/invoice.py:42 computes the discounted total with float math and the built-in round(), which uses banker's rounding, so 89.995 becomes 89.99 instead of 90.00. The test in tests/test_invoice.py:58 expects half-up rounding on Decimal currency values.

Attempt log:
| # | Change                                                                 | Command run                                                   | Result                                                                                     |
|---|------------------------------------------------------------------------|---------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| 1 | Converted subtotal and discount to Decimal; kept round(total, 2)       | pytest tests/test_invoice.py::test_total_with_discount -q     | FAIL: Decimal('89.99') != Decimal('90.00'); round() still rounds half to even              |
| 2 | Replaced round() with total.quantize(Decimal("0.01"), ROUND_HALF_UP)   | pytest tests/test_invoice.py::test_total_with_discount -q     | PASS                                                                                       |
| 2 | (wider suite, run once after pass)                                     | pytest -q && ruff check src tests                             | PASS: 214 passed, 0 failed; ruff clean                                                     |

Files changed:
- src/billing/invoice.py (6 lines changed)

diff --git a/src/billing/invoice.py b/src/billing/invoice.py
@@ -1,5 +1,5 @@
-from decimal import Decimal
+from decimal import Decimal, ROUND_HALF_UP
@@ -40,5 +40,7 @@ def discounted_total(subtotal, discount_pct):
-    total = float(subtotal) * (1 - float(discount_pct) / 100)
-    return round(total, 2)
+    total = Decimal(str(subtotal)) * (
+        Decimal(1) - Decimal(str(discount_pct)) / Decimal(100)
+    )
+    return total.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)

Residual risks:
- discounted_total now returns Decimal instead of float. I grepped for callers: two internal ones (invoice.render and reports.monthly) both pass the value to str() or format(), and both are covered by passing tests. Any external consumer that does float arithmetic on the result would raise a TypeError.
- No flakiness observed. The failure was deterministic, and the target test passed on repeated runs (3 of 3).
- Other modules may still use round() on currency values. I found none in this diff's scope and left them alone.

Next action for a human:
- Review the return-type change in discounted_total and confirm that no downstream service expects a float.
- Consider a follow-up ticket to standardize currency rounding in one helper.
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use as the prompt in a CI step after a red build, with the failing log pasted in or piped from the job. Keep the job's token and write permissions as narrow as your policy allows.

Questions about this prompt

More in Codex

Codex CI Failure Triage: Reproduce, Classify, Fix or Hand Off

Guides Codex through reproducing a failing CI job locally, classifying the cause as code, test, environment, or flaky, applying a minimal fix when safe, and producing an evidence-based handoff for anything it cannot resolve.

Codex Characterization-Test-First Refactor with Verification Handoff

Runs a behavior-preserving refactor in Codex exec. It pins current behavior with characterization tests, refactors in small verified steps inside an allowed scope, and ends with an evidence-based handoff for the merge decision.

Codex Read-Only Repo Investigation for a Bug Report

Runs a read-only Codex investigation that maps the relevant code paths, test commands, and likely root causes for a bug report. It ends with a ranked hypothesis table and a go/no-go recommendation before any edits.

Outcome-First Codex Task Writer for a Feature or Bug Request

Turns a raw feature or bug request into a paste-ready Codex task with a goal, constraints, files in scope, definition of done and exact verification commands.

Codex Pre-Merge Diff Review with Severity-Ranked Findings

Has Codex review a branch diff against a base ref in read-only mode. It checks correctness, tests, security, and maintainability, and returns evidence-backed findings with severity and a merge recommendation.

Codex Pull Request Review With Comments Ranked by Severity

Has Codex review a pull request and return comments sorted into blocking, should-fix and nit, each with the file and line, the risk, and a suggested change.

Codex Writes an AGENTS.md for This Repository From the Real Setup

Has Codex inspect your repository and write a short, accurate AGENTS.md with the real build, test and lint commands, conventions and boundaries, checked by actually running them.

Agent Run Pre-Mortem and Self-Correction Loop Designer

Designs verification checks, error handling, and a self-correction loop for an agent task before it runs, based on likely failure modes.

Cursor .mdc Rules to Portable AGENTS.md Converter

Converts your pasted Cursor .mdc rules into a single AGENTS.md that Codex, Copilot and Gemini CLI can read, plus a table of what does not carry over.

Gemini Multimodal Evidence Audit: Screenshots, PDFs, and Charts to Verified Findings

Has Gemini inspect uploaded images, screenshots, charts, and PDFs, extract what is visible, and verify claims against online sources. Ends in a findings log with confidence ratings and next steps.

Source Credibility Check with Claim-by-Claim Verification Plan

Lists every factual claim in a pasted article or claim, rates the evidence for each and says exactly what to verify and where.