CClaude Code Catalog
All Patterns

Monorepo Structure

Folder StructureAdvanced

Monorepos are powerful but can overwhelm AI coding assistants with their size and complexity. This structure pattern shows how to organize a monorepo so that Claude Code can efficiently navigate between apps and shared packages. The key insight is layered CLAUDE.md files — a root file for shared conventions plus per-package files for specific rules.

monorepoturborepopnpmworkspacefolder-structure

Pattern Code

my-monorepo/ ├── apps/ │ ├── web/ # Next.js frontend │ │ ├── src/ │ │ ├── CLAUDE.md # Web-specific rules │ │ ├── package.json │ │ └── tsconfig.json │ ├── api/ # Express/Fastify backend │ │ ├── src/ │ │ ├── CLAUDE.md # API-specific rules │ │ ├── package.json │ │ └── tsconfig.json │ └── mobile/ # React Native app │ ├── src/ │ ├── CLAUDE.md │ └── package.json ├── packages/ │ ├── shared/ # Shared types & utils │ │ ├── src/ │ │ │ ├── types/ # Cross-app type definitions │ │ │ ├── utils/ # Shared helper functions │ │ │ └── index.ts # Barrel export │ │ └── package.json # @repo/shared │ ├── ui/ # Shared UI component library │ │ ├── src/ │ │ │ ├── Button/ │ │ │ ├── Input/ │ │ │ └── index.ts │ │ ├── CLAUDE.md # Component conventions │ │ └── package.json # @repo/ui │ └── config/ # Shared configs │ ├── eslint/ │ ├── tsconfig/ │ └── tailwind/ ├── tooling/ # Build & dev tooling │ ├── scripts/ │ └── docker/ ├── CLAUDE.md # Root: shared conventions ├── turbo.json # Turborepo pipeline ├── pnpm-workspace.yaml └── package.json # Root CLAUDE.md: # - Use pnpm only. Never npm or yarn. # - Import between packages via @repo/* alias. # - All packages use TypeScript strict mode. # - Run single package: pnpm --filter @repo/api test # - Run affected: pnpm turbo test --filter=...[HEAD~1] # - Dependency graph: # packages/shared → packages/ui → apps/web # packages/shared → apps/api # packages/shared → apps/mobile

Copy this pattern into your project configuration to implement.

Terminal Preview

Monorepo Structure

About Monorepo Structure

Claude Code patterns are proven architectural designs and workflow structures that help you tackle complex development scenarios. Monorepo Structure is a Folder Structure pattern at the Advanced level that provides a tested, repeatable approach you can adapt to your projects for more efficient and consistent results.

Related Patterns