Home › Coding › Fix a failing build: how to do it with AI
Fix a failing build: how to do it with AI
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.
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
- Work on a branch, never directly on main.
- Give the agent the failing log and the command that reproduces it locally.
- Tell it the rules: don't delete or skip tests, don't change CI config without asking, explain each change.
- Let it iterate, but read every diff before accepting.
- Run the full test suite yourself after it says it's green.
- 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
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 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.
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
- Cursor: Agent edits code and runs terminal commands; Cloud Agents run in isolated VMs and open PRs, away from your laptop's credentials. Free plan can do this Visit official website ↗
- GitHub Copilot: The cloud agent works in GitHub Actions on issues, branches and pull requests, so changes land as reviewable PRs. Free plan can do this Visit official website ↗
- Claude (incl. Claude Code): Connectors are on the Free plan; Claude Code asks permission before running commands. Visit official website ↗
- ChatGPT (incl. Work & Codex): Codex includes PR review; Free has limited Codex access. Free plan can do this Visit official website ↗
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
- Letting the agent work on main.
- Accepting a green build without reading the diff.
- Allowing it to skip tests to pass.
- Running an agent with production credentials in the environment.
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