Category: Engineering · AI-Assisted Development
For the better part of a decade, the monolith-vs-microservices debate has been a rite of passage in every engineering team. Split everything into small, independently deployable services — that was the gospel. Then the bills came in. The distributed tracing hell arrived. And now, quietly, a countermovement is gaining momentum: the monorepo renaissance.
The twist? AI-assisted development tools like GitHub Copilot, Cursor, and Claude-powered agents are accelerating this shift in ways nobody predicted. When your coding assistant can traverse an entire codebase in seconds, the game changes.
💡 TL;DR Monorepos aren't new — Google and Meta have used them for years. What's new is that AI coding assistants thrive in them, making the developer experience argument overwhelmingly compelling in 2026.
01 — The Microservices Dream (and Its Hangover)
The microservices wave peaked around 2018–2021. The pitch was seductive: independent deployments, technology freedom per service, fault isolation, and teams that could work autonomously. For companies like Netflix or Uber, it made enormous sense.
But for the other 99% of engineering teams, microservices introduced accidental complexity — complexity that wasn't inherent to the problem, but to the architecture itself:
- To do: Service discovery, API versioning, and contract drift between teams
- To do: Debugging failures across 12 services and 4 different logging systems
- To do: Shared library updates requiring coordinated releases across dozens of repos
- To do: Local development needing Docker Compose files the size of novels
🗣️ "We replaced a distributed monolith with a distributed system of distributed monoliths."
The irony: many "microservice" architectures were just monoliths with HTTP calls between layers. All the operational pain, none of the independence benefits.
Architecture at a Glance
| Polyrepo (Microservices) | Monorepo | |
|---|---|---|
| Repos | user-service, payment-service, notification-svc, shared-utils | One repo: my-app/ |
| Shared code | ❌ Publish to npm, version manually | ✅ Workspace references |
| Atomic changes | ❌ Multiple PRs required | ✅ Single PR |
| Tooling consistency | ❌ Diverges per team | ✅ Enforced centrally |
| AI context | ❌ Fragmented | ✅ Complete graph |
02 — What Is a Monorepo, Actually?
⚠️ Common misconception A monorepo is not a monolith. A monorepo is a single version-control repository containing multiple projects or services — each of which can still be deployed independently.
| Property | Monolith | Polyrepo | Monorepo |
|---|---|---|---|
| Deployment unit | One big app | Per service | ✅ Per package/app |
| Shared code | ✅ Easy | ❌ Hard | ✅ Easy |
| Atomic cross-project changes | ✅ | ❌ | ✅ |
| Independent scaling | ❌ | ✅ | ✅ |
| Consistent tooling | ✅ | ❌ | ✅ |
| AI context window fit | 🟡 Partial | ❌ | ✅ |
Tools like Turborepo, Nx, and Bazel brought the infrastructure needed to make monorepos tractable — caching builds, running only affected tasks, and managing dependency graphs at scale.
Minimal Turborepo Setup
// turbo.json
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"]
},
"test": {
"dependsOn": ["build"],
"inputs": ["src/**", "tests/**"]
},
"lint": {},
"dev": {
"cache": false,
"persistent": true
}
}
}# pnpm-workspace.yaml
packages:
- "apps/*"
- "packages/*"
- "tooling/*"03 — The AI Factor: Why This Changes Everything
Here's what nobody was talking about in 2019 when monorepo tooling first matured: AI coding assistants fundamentally prefer monorepos.
When an AI agent like Claude, Copilot, or Cursor indexes your codebase to answer a question or refactor a function, it needs context. In a polyrepo world, that context is fractured. In a monorepo, the agent sees the complete dependency graph.
What AI Agents Can Do in a Monorepo
- Trace a type from
packages/types→apps/apiautomatically - Refactor a shared utility and update all consumers in one PR
- Understand which tests are affected by a change without being told
- Generate consistent code that matches patterns across the whole repo
AI Workflow Diagram
┌─────────────┐ ┌──────────────────┐ ┌─────────────────┐ ┌────────────────┐ ┌──────────────────┐
│ AI Agent │ → │ Indexes full │ → │ Finds all │ → │ Single atomic │ → │ Turborepo only │
│ (Claude / │ │ monorepo graph │ │ affected files │ │ PR / change │ │ rebuilds delta │
│ Copilot) │ │ │ │ │ │ │ │ │
└─────────────┘ └──────────────────┘ └─────────────────┘ └────────────────┘ └──────────────────┘Cross-Package Refactor Example
// packages/types/src/user.ts — shared across all apps
export interface User {
id: string;
email: string;
displayName: string; // AI adds this and updates ALL consumers
}
// apps/web/src/components/UserCard.tsx — auto-updated by AI
import { User } from '@acme/types';
export function UserCard({ user }: { user: User }) {
return (
<div>
<h2>{user.displayName}</h2> // ← AI added this
<p>{user.email}</p>
</div>
);
}
// apps/api/src/routes/users.ts — also updated atomically
async function formatUser(raw: DBUser): Promise<User> {
return {
id: raw.id,
email: raw.email,
displayName: raw.full_name ?? raw.email, // ← AI inferred this
};
}✅ Key Insight In a polyrepo, this same change requires 3 separate PRs, 3 pipeline runs, and careful sequencing. In a monorepo with an AI agent: one PR, one review, one deploy pipeline.
04 — Real-World Structure: A Full-Stack Monorepo
my-app/
├── apps/
│ ├── web/ # React.js / Vue.js / Next.js - frontend
│ ├── api/ # Nodejs / Fastify API / Laravel - backend
│ ├── mobile/ # Expo React Native
│ └── docs/ # Mintlify / Nextra docs
├── packages/
│ ├── ui/ # Shared React component library
│ ├── types/ # Shared TypeScript types/interfaces
│ ├── db/ # Drizzle ORM schema + migrations
│ ├── auth/ # Auth logic (Better Auth / Clerk)
│ └── utils/ # Shared pure utilities
├── tooling/
│ ├── eslint-config/ # Shared ESLint rules
│ ├── tsconfig/ # Shared tsconfig base
│ └── prettier-config/ # Shared Prettier rules
├── turbo.json
├── pnpm-workspace.yaml
└── package.jsonShared tsconfig
// tooling/tsconfig/base.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"noUncheckedIndexedAccess": true
}
}Importing Across Packages
// No npm publish, no version bumps — it just works.
import { Button, Input } from "@acme/ui";
import { formatDate, slugify } from "@acme/utils";
import type { User, Post } from "@acme/types";
import { db, schema } from "@acme/db";05 — CI/CD: Only Build What Changed
❓ Common objection: "If everything's in one repo, doesn't every PR rebuild everything?" Answer: No. Turborepo's remote caching + affected-task computation runs only what needs to run.
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # needed for turbo to diff
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with: { node-version: "22", cache: "pnpm" }
- run: pnpm install --frozen-lockfile
- name: Build + Test (affected only)
run: pnpm turbo build test lint --filter=...[HEAD^1]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}📌 Note on --filter=...[HEAD^1]
Only processes packages that changed vs. the previous commit, plus their dependents. A change in packages/utils cascades to rebuild apps/web and apps/api, but not unrelated packages.
06 — When NOT to Use a Monorepo
| Situation | Recommendation |
|---|---|
| Teams fully autonomous, zero shared code | ❌ Stick with polyrepo |
| Hard security/compliance isolation needed | ❌ Keep separate repos |
| Org culture can't enforce shared standards | ❌ Not yet |
| Independent teams owning dedicated services | ❌ Polyrepo fits better |
| 2–50 engineers on related products | ✅ Monorepo |
| Shared types, UI, or data models | ✅ Monorepo |
| Fullstack developer with unified app workflow | ✅ Ideal fit |
| 100k+ files, Google-scale org | ⚠️ Need custom VFS tooling |
📏 Rule of thumb If you have 2–50 engineers working on related products that share code, data models, or design systems — a monorepo will almost certainly improve velocity. If teams are fully siloed shipping to separate customers, benefits diminish.
🧑💻 Best fit: Fullstack developers & unified workflows
If you're a fullstack developer — or a team where engineers touch the frontend, backend, and shared packages — a monorepo is close to an ideal setup. Your entire app lives in one place: one git pull, one pnpm install, one turbo dev to spin everything up. No context-switching between repos, no version drift between the API types and the UI consuming them. The unified workflow is the feature.
🏢 Doesn't fit: Independent teams with dedicated services If your organisation is structured around fully independent teams — each owning a dedicated service, deploying on their own cadence, and sharing little to no code — a monorepo adds friction without payoff. Forcing those teams into a shared repo means shared CI queues, shared lint configs they didn't agree to, and PRs that touch code they don't own. In this model, polyrepo respects team autonomy and is the right call.
07 — Putting It Together: AI Agent + Monorepo Workflow
/**
* Scenario: PM requests a new "user profile" feature.
*
* AI agent workflow in a monorepo:
* 1. Reads packages/types/src/user.ts for existing User shape
* 2. Reads packages/db/src/schema.ts to understand DB structure
* 3. Generates migration in packages/db/src/migrations/
* 4. Generates API route in apps/api/src/routes/profile.ts
* 5. Generates React component in packages/ui/src/ProfileCard.tsx
* 6. Wires component into apps/web/src/pages/profile/[id].tsx
* 7. Generates tests for all touched packages
* 8. All in one PR — Turborepo knows exactly what to rebuild
*/
// packages/db/src/migrations/0012_add_user_bio.ts
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
export const userProfiles = pgTable("user_profiles", {
userId: text("user_id").primaryKey(),
bio: text("bio"),
avatarUrl: text("avatar_url"),
updatedAt: timestamp("updated_at").defaultNow(),
});The AI doesn't guess at types or database structure. It reads them from the same repository. The result: consistent, type-safe, immediately testable code — with zero context-switching between repos.
08 — Conclusion: The Architecture That Meets AI Halfway
The microservices era gave us operational independence at the cost of developer experience. The monorepo renaissance isn't a regression — it's an evolution.
- Turborepo / Nx / pnpm workspaces → solved build and scale problems
- AI coding assistants → solved the human problem of understanding large codebases fast
- Fullstack developers → get a unified workflow: one repo, one install, one dev command across the entire stack
- Independent org teams → monorepos won't help; polyrepo respects team autonomy when there's no shared code
"The best architecture for AI-assisted development isn't the one that isolates complexity. It's the one that makes complexity legible.**"
You don't have to abandon microservices deployment targets. Your services can still run independently, scale independently, and own their own data. But keeping the source of truth in one place — one repo, one dependency graph, one toolchain — is proving to be the right call for most teams.
The environment evolved enough that monorepos became efficient, scalable, and developer-friendly.



