AgentLint Verified 95/100420 Monorepo (Turborepo / Nx / Workspace) repos analyzed

    Monorepo (Turborepo / Nx / Workspace) CLAUDE.md & AGENTS.md Template

    Scoped root + package CLAUDE.md/AGENTS.md hierarchy and conditional loading for multi-package repos.

    # Monorepo (Turborepo / Nx / Workspace) Project — Workspace Harness
    
    Multi-package pnpm + Turborepo workspace (`apps/web`, `apps/api`, `packages/shared`).
    
    ## Commands
    
    - Fast package test: `pnpm --filter @acme/api test -- src/billing.test.ts`
    - Scoped typecheck: `pnpm --filter @acme/web typecheck`
    - Affected CI check: `pnpm turbo run lint typecheck test --affected`
    
    ## Progressive Disclosure Map
    
    - When editing `apps/web/`, read `apps/web/CLAUDE.md` for routing and UI tokens.
    - When editing `apps/api/`, read `apps/api/CLAUDE.md` for auth, migrations, and queues.
    - When editing `packages/shared/`, read `packages/shared/CLAUDE.md` before changing exported contracts.
    
    ## Workspace Rules
    
    - Don't duplicate package-specific instructions in this root file. Instead place them in each package's own `CLAUDE.md` / `AGENTS.md`. Because root bloat dilutes priority and risks the 40K character limit.
    - Don't run full workspace builds after editing one package. Instead scope every command with `pnpm --filter <pkg>`. Because unscoped builds waste minutes and confuse diffs.
    - Keep `.env*` and `CLAUDE.local.md` ignored across every workspace package; update `HANDOFF.md` on cross-package changes.

    Most Adopted Monorepo (Turborepo / Nx / Workspace) Rules Across Real Open-Source Repos

    Measured across 420 public Monorepo (Turborepo / Nx / Workspace) repositories in the 4,533-repo harness study:

    scoped-package-commandsworkability

    Scope build and test invocations to the edited package via --filter

    74.3%312 repos
    nested-context-filesfindability

    Keep root CLAUDE.md lean and place subsystem rules in package-level files

    68.8%289 repos
    shared-contract-guardworkability

    Require cross-package typecheck when shared schemas change

    47.1%198 repos
    cursor-glob-rulesfindability

    Use glob frontmatter in .cursor/rules/*.mdc to scope rules per directory

    39.0%164 repos
    Essential Commands (Checks W1 & W7)
    install
    pnpm install --frozen-lockfile
    fastTest
    pnpm --filter @org/pkg test -- src/target.test.ts
    fullTest
    pnpm turbo run test lint typecheck
    lint
    pnpm turbo run lint
    build
    pnpm turbo run build
    Common Monorepo (Turborepo / Nx / Workspace) Agent Pitfalls
    • 01Stuffing every app's rules into one giant root CLAUDE.md pushes past Claude Code's 40,000-character truncation ceiling.
    • 02Agents run unfiltered workspace builds instead of --filter <pkg>, burning 5+ minutes per edit.

    More Verified Stack Templates