Home › Coding › Fix a failing build: how to do it with AI

Fix a failing build: how to do it with AI

Last checked

From official vendor pages; selected tasks also include dated logged-out free-plan trials. Report an error.

Advanced Risk: Medium 💻 Coding

Coding agents can read a failing build log, find the cause, edit the code and rerun the build until it passes. This is where agents save real time, and also where they can "fix" a build by deleting a test, so you review the diff like any pull request.

Who it’s for: Developers and DevOps engineers dealing with broken CI, dependency upgrades or flaky builds.

Why medium risk: An agent may skip or weaken tests, pin odd versions, or run commands with your credentials.

Best pick

ChatGPT has the highest score on our published rubric (94/100) of the 4 tools listed for this task. Codex includes PR review; Free has limited Codex access.

Step by step

  1. Work on a branch, never directly on main.
  2. Give the agent the failing log and the command that reproduces it locally.
  3. Tell it the rules: don't delete or skip tests, don't change CI config without asking, explain each change.
  4. Let it iterate, but read every diff before accepting.
  5. Run the full test suite yourself after it says it's green.
  6. Open a pull request so a teammate reviews the fix.

AI prompts to fix a failing build

Replace the [brackets] with your details. See all prompt examples

Diagnose first
Here is the failing build log and the command to reproduce it. Explain the root cause in plain English and propose a fix before editing anything.

[log]
Fix with guard rails
Fix the failing build on this branch. Rules: don't delete, skip or weaken tests; don't modify CI files; keep dependency changes minimal and explain each. Rerun [command] after each change.
Explain the diff
Summarise every change you made, why, and anything that could affect production or other teams.

Illustrative example

You paste

Log: "TypeError: Cannot read properties of undefined (reading 'map')" in UserList.test.js after a library upgrade.

A good answer looks like

Agent: The upgrade changed the API's empty response from [] to undefined. Fix: default to [] in fetchUsers(), no test changes. Reran npm test: all tests passed.

Illustrative example written for this guide, not output captured from a specific tool.

Which tool to pick, and why

Reasons come from the capabilities, free-plan details and prices we've checked on official pages (separate from any dated trial above). Sources: cursor.com/pricing · github.com/features/copilot/plans · claude.com/pricing · chatgpt.com/pricing

Common mistakes

Privacy tip

Run agents with least-privilege tokens and keep secrets out of the repository and the chat.

Cursor setting · GitHub Copilot setting · Claude (incl. Claude Code) setting · Sources: cursor.com/help/security-and-privacy/privacy · github.com/features/copilot/plans · privacy.claude.com/en/articles/12109829-how-do-i-change-my-model-improvement-privacy-settings

Related tasks

Report an error on this page