Shobhit Sharma
Posted on:December 26, 2024 at 12:00 AM3 min read

Monorepos Are Back: Why AI Agents Make Them a Godsend

I’ve been experimenting with AI agents for the past few months, gradually giving them more control over my development tasks. What started as simple code suggestions has evolved into letting them handle complex features, refactoring, and even architecture decisions.

The sweet spot seems to be around 10 minutes of sustained attention—long enough for an agent to understand a problem, explore the codebase, and implement a solution.

But here’s what I didn’t expect: monolithic codebases work incredibly well with AI agents.

The Context Advantage

When I point an AI agent at a well-organized monorepo with good documentation, something magical happens. Instead of me explaining how the frontend talks to the backend, how the database schema works, or where to find similar patterns, the agent just… figures it out.

Me: "Add user notifications to the app"

Agent: *Scans the entire codebase*
"I see you have a notification service in `/backend/services/`,
React components in `/frontend/components/notifications/`,
and database migrations in `/db/migrations/`.
I'll extend the existing pattern and add the new notification types."

No context switching. No explaining. No “this is in another repo” conversations.

What Actually Works

After dozens of experiments, here’s what I’ve learned works best with AI agents:

Monolithic structure: Everything in one place where the agent can see it all Consistent patterns: When the agent sees how you solve similar problems, it follows the same approach Good documentation: README files, code comments, and architectural decisions help the agent understand intent Clear organization: Well-structured directories and naming conventions let the agent navigate confidently

The Polyrepo Problem

Compare this to working with multiple repositories. I spend half my time explaining context:

“This service depends on that API which uses this database schema that’s defined in another repo, and here’s how authentication works across these three different services…”

By the time I finish explaining, I could have built the feature myself.

Why Now?

Modern AI agents can hold context for much longer than before. Ten minutes of focused attention means they can:

  • Read through your entire codebase
  • Understand existing patterns and conventions
  • Plan multi-file changes
  • Execute complex refactoring
  • Test their changes against the existing system

This attention span is the game-changer. It’s long enough to understand a complete system but focused enough to execute well-defined tasks.

The Tooling Caught Up

The tools that made monorepos unwieldy are mostly solved now:

  • Build systems like Bazel and Nx only rebuild what changed
  • Testing tools run only affected tests
  • IDEs handle large codebases without breaking a sweat
  • CI/CD can deploy individual services from a monorepo

Combined with AI agents that thrive on complete context, monorepos aren’t just viable—they’re advantageous.

My New Workflow

Now when I start a new project, I default to a monorepo structure:

project/
├── docs/           # Architecture decisions, setup guides
├── frontend/       # All UI code
├── backend/        # All services and APIs
├── database/       # Schemas, migrations, seeds
├── shared/         # Common types, utilities
└── tools/          # Scripts, configs, dev tools

Everything an AI agent needs to understand and modify the system is right there. No hunting across repositories, no explaining distributed architectures, no managing dependency versions across repos.

The result? I can hand off increasingly complex tasks to AI agents and trust they’ll implement them consistently with the rest of the system.

Monorepos are back, and AI agents are the reason why.

Share:

Open to Collaboration

Hey there! If you've got a new project brewing in your head, or just want to share something cool, or even just drop a casual hi, please feel free to hit me up! It's always great to connect with folks who stop by, so don't be shy!