Best ways to use AI coding agents without wrecking your codebase
AI coding agents can now read a repository, edit multiple files, run commands and iterate on test failures. Used well, they speed things up a lot. Used carelessly, they create subtle messes.
Habits that help
- Give clear, scoped tasks. "Add pagination to the orders endpoint, matching the pattern in users" works better than "improve the API."
- Provide context. Point the agent to relevant files, conventions and project instruction files many tools support.
- Work on a branch. Keep changes reviewable and easy to discard.
- Make tests the referee. Agents do far better when they can run a test suite and see failures.
- Review every diff. Read the code as you would a teammate's pull request. Watch for removed checks, weakened tests and invented APIs.
- Commit in small steps. Smaller changes are easier to verify and roll back.
Common pitfalls
- Agents "fixing" a failing test by changing the assertion instead of the bug
- Unnecessary new dependencies
- Duplicated helpers that already exist elsewhere
- Large rewrites when a small fix was needed
- Running commands with broader permissions than needed
Where they tend to shine Boilerplate, migrations between similar APIs, writing tests for existing code and explaining unfamiliar modules.
What tasks do you delegate to coding agents now? What review habit has saved you from merging something bad?
Comments · 3
The review habit matters most. If an agent writes the code and nobody understands it, you've taken on debt that doesn't show up until something breaks.
I like small scoped tasks. Asking for one component at a time gives output you can actually evaluate, versus a giant diff nobody reads.
Cost angle: long agent loops can burn through usage, so it's worth setting limits. Cheap per task, but not if it retries blindly.