Building an AI agent team to write code
Over the past few months, I've been running an experiment on one of my projects: building an AI agent team to autonomously write code. The setup includes multiple specialized coding AI agents, each responsible for different aspects of development (React UI, CSS, API, Python and ML, database, DevOps, testing, and more). And myself as code reviewer and feedback provider.
So far, the results have been impressive. The code quality is quite good and the development speed is remarkably fast. But this experiment also surfaced a few key lessons:
Clear Role Isolation is Crucial. Each AI agent needs well-defined boundaries. For instance, an API test agent should not modify API code. Without strict role isolation, agents interfere with each other's work, leading to inconsistencies.
Microservices Work Best. To keep AI agent context manageable, projects should follow a modular architecture. A monolithic codebase can quickly overwhelm an agent context, whereas smaller, well-contained modules allow them to focus and excel.
A monolithic codebase can quickly overwhelm an agent's context. Smaller, well-contained modules are not optional anymore if you want multiple agents to work in parallel.
Modern Tech Stack Matters. AI coding agents work best with widely adopted technologies. If you use an exotic or legacy stack, the AI can still assist, but achieving full autonomy becomes difficult.
Strong Feedback Loop is Essential. AI agents don't learn on their own, but you can enhance their effectiveness by continuously refining their rules and constraints. A well-structured code review process helps improve their output over time, ensuring consistency and adherence to coding standards.
Test Coverage is Critical. Since AI agents sometimes rewrite existing code, comprehensive test coverage is non-negotiable. It helps catch regressions and ensures changes do not introduce new bugs.
Tools compared
I've primarily used Claude 3.5 Sonnet as the underlying model for these agents. I tested several AI-powered coding assistants:
- Cursor: My go-to AI coding agent. It offers the best flow and execution control with customizable prompts using cursor rules. Its ability to execute terminal commands makes it powerful for debugging, running tests, and auto-fixing deployment issues, setting it apart from static AI assistants.
- Trae (ByteDance): Has a visually appealing UI but lacks autonomy. While it can modify multiple files at once, it often requires several iterations to complete tasks that Cursor handles in one go. It often misses updates when working with multiple files or necessary imports.
- GitHub Copilot Agent: Although a latecomer to the autonomous agent space, it shows promise but needs better execution control and UI improvements. It's particularly good at fixing specific bugs without unnecessary rewriting, making it useful for targeted fixes.