DEP-007 recommended monorepo-structure

Turborepo for monorepos

Monorepos use Turborepo with proper workspace config, no hidden apps

Question to ask

"Any apps hiding in the monorepo nobody remembers deploying?"

Verification guide

Severity: Recommended

Check automatically:

  1. Scan for multiple package.json files (detect hidden apps):

    # Find all package.json files in first 2 levels (excluding node_modules)
    find . -maxdepth 3 -name "package.json" -not -path "*/node_modules/*" 2>/dev/null
    
  2. Check for app-like directories without workspace setup:

    # Common app directory patterns that might be hidden apps
    ls -d */package.json */*/package.json 2>/dev/null | grep -v node_modules
    
    # Check for directories with their own node_modules (red flag)
    find . -maxdepth 3 -type d -name "node_modules" -not -path "./node_modules" -not -path "./node_modules/*" 2>/dev/null
    
  3. Detect if this is a monorepo:

    # Check for workspace configuration
    cat package.json | jq '.workspaces' 2>/dev/null
    cat pnpm-workspace.yaml 2>/dev/null
    
    # Check for typical monorepo directories
    ls -d apps/ packages/ libs/ services/ 2>/dev/null
    
  4. Cross-reference: all package.json files should be in workspaces:

    # Get workspace globs
    cat pnpm-workspace.yaml 2>/dev/null
    cat package.json | jq '.workspaces' 2>/dev/null
    
    # Compare against found package.json locations
    
  5. If monorepo, check for Turborepo:

    ls -la turbo.json 2>/dev/null
    
  6. Check Turborepo configuration:

    # Verify pipeline is configured
    cat turbo.json | jq '.pipeline // .tasks' 2>/dev/null
    
    # Check for proper task dependencies
    cat turbo.json | jq '(.pipeline // .tasks) | keys' 2>/dev/null
    
  7. Check root package.json uses turbo:

    cat package.json | jq '.scripts' | grep -E "turbo"
    
  8. Check for alternative monorepo tools (flag if present instead of Turborepo):

    # Nx
    ls -la nx.json 2>/dev/null
    
    # Lerna
    ls -la lerna.json 2>/dev/null
    
    # Rush
    ls -la rush.json 2>/dev/null
    
  9. Check CI uses turbo for builds:

    grep -rE "(turbo run|turbo build|turbo test|npx turbo)" .github/workflows/ 2>/dev/null
    
  10. Check caching is enabled:

    # Check .turbo is gitignored (local cache)
    grep -E "\.turbo" .gitignore 2>/dev/null
    

Note: Only applies to monorepos or repos with multiple apps. Skip if truly single-package.

Pass criteria:

  • Single-package repo (only root package.json) - N/A, skip this check
  • All package.json files are covered by workspace config
  • No rogue node_modules directories outside root
  • Monorepo with Turborepo configured (turbo.json exists)
  • Pipeline/tasks properly defined for build, test, lint
  • Root scripts use turbo run commands
  • CI workflows use turbo for builds
  • .turbo cache directory is gitignored

Fail criteria:

  • Multiple package.json files but no workspace configuration (hidden monorepo)
  • package.json files not covered by workspaces glob
  • Nested node_modules directories (apps installing deps independently)
  • Monorepo without any build orchestration tool
  • Using Lerna, Nx, or Rush instead of Turborepo (flag for discussion)
  • Turborepo configured but not used in scripts or CI
  • Missing pipeline configuration for key tasks (build, test, lint)
  • .turbo not in .gitignore

If hidden apps detected, ask user: "Found package.json files not in workspaces config: [list paths]. Are these separate apps that should be workspace packages? Nested node_modules at [paths] suggests they're being managed independently."

If alternative tool found, ask user: "Monorepo uses [Nx/Lerna/Rush] instead of Turborepo. Is there a specific reason? Turborepo is preferred for its simplicity and caching."

If monorepo without orchestration, ask user: "This appears to be a monorepo (multiple package.json files) but no build orchestration tool found. How are cross-package builds and dependencies managed?"

Evidence to capture:

  • All package.json locations found
  • Which are covered by workspaces config
  • Any rogue node_modules directories
  • Is properly configured monorepo (yes/no)
  • Orchestration tool (Turborepo/Nx/Lerna/Rush/none)
  • turbo.json tasks defined
  • Whether scripts and CI use turbo
  • Cache configuration status

Section

02. Dependencies & Code Quality

Infrastructure & Setup