Monorepo Workspace Optimization

AI Rules & Context for Turborepo, Nx & pnpm

Stop monorepo context bloat in Cursor, Claude Code, and Windsurf. Compile granular, package-scoped MDC rules and serve target-specific directives via Model Context Protocol.

Direct Answer: Monorepo AI Context Management

Meto solves monorepo AI context degradation by compiling package-scoped rules instead of monolithic root files. By generating targeted .cursor/rules/*.mdc files equipped with precise glob matchers (e.g. apps/web/** vs packages/database/**) and exposing on-demand MCP tools, Meto ensures coding assistants receive only the architectural rules relevant to the active file.

The Monorepo Dilemma: Root Bloat vs Scoped Directives

The Monolithic Trap

Single Root .cursorrules File

  • Dumps 1,000+ lines into every prompt, exhausting LLM attention and token budget.
  • Next.js web rules leak into Expo mobile components or backend worker lambdas.
  • AI hallucinates incorrect relative imports across package boundaries.
The Meto Compiler

Granular Package-Scoped Rules

  • Frontmatter glob filters activate rules only when matching files are edited.
  • MCP server filters ADRs dynamically based on workspace package context.
  • Preserves 80%+ of prompt tokens for actual code and conversation history.

Compiled Monorepo Rule Output

Generated structure via 'npx meto-cli sync':
my-monorepo/
├── .cursor/rules/
│   ├── 00-global-standards.mdc       # globs: ["**/*"] (TypeScript strict, git)
│   ├── 10-apps-web.mdc               # globs: ["apps/web/**/*"] (Next.js 15, Tailwind v4)
│   ├── 20-apps-mobile.mdc            # globs: ["apps/mobile/**/*"] (React Native, Expo)
│   └── 30-packages-db.mdc            # globs: ["packages/db/**/*"] (Drizzle ORM, Postgres)
├── CLAUDE.md                         # Scoped terminal directives for Claude Code
├── .windsurfrules                     # Cascade rules with package path triggers
└── turbo.json

Frequently Asked Questions

Why do static rule files fail in monorepos?

In a monorepo with multiple apps (e.g. Next.js web app, React Native mobile app) and shared packages (database, UI library, API client), a single root .cursorrules or CLAUDE.md file dumps every rule into every prompt. This confuses AI models, causing them to suggest web APIs in mobile code or backend imports in UI components.

How does Meto scope rules to individual packages?

Meto compiles modern Cursor MDC files (.cursor/rules/*.mdc) with explicit frontmatter glob patterns (e.g. 'apps/web/**', 'packages/ui/**'). When you open a file in apps/web, Cursor only loads the web directives. Similarly, Meto's MCP server filters architectural records by target package path.

Does Meto support Turborepo, Nx, and pnpm workspaces?

Yes. Meto CLI automatically detects workspace configuration files (pnpm-workspace.yaml, turbo.json, nx.json) and compiles both root and package-level rule definitions.

Can I share common architectural standards across all monorepo packages?

Yes. Meto allows you to define global workspace standards (e.g. TypeScript strictness, formatting, Git workflow) that apply everywhere, while attaching framework-specific rules only to designated sub-packages.

Tame your monorepo AI context today

Compile clean, scoped rules for Cursor, Claude Code, and Windsurf in under 2 minutes.