Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
["Monorepo architecture requirements","Build and test optimization needs","Project graph structure"]
outputs
["Nx workspace configuration","Generator and executor setup","CI pipeline configuration","Caching and affected command strategies"]
linksTo
["monorepo","cicd","turborepo","dev-workflow"]
linkedFrom
[]
preferredNextSkills
["cicd","monorepo"]
fallbackSkills
["turborepo","pnpm"]
riskLevel
low
memoryReadPolicy
selective
memoryWritePolicy
none
sideEffects
["code generation","build artifacts"]
Nx
Purpose
Manage monorepos and large-scale projects with Nx. Covers workspace setup, the project graph, task orchestration with caching, generators for code scaffolding, executors for custom build steps, affected commands for CI optimization, Nx Cloud for distributed caching, and plugin development.
# Run targets
nx serve web # Dev server for app
nx build web # Build specific project
nx test shared-utils # Test specific library
nx lint web # Lint specific project
nx run web:build:production # Run target with configuration# Run across projects
nx run-many -t build test lint # Run multiple targets across all projects
nx run-many -t build --projects=apps/* # Build all apps
nx run-many -t test --parallel=5 # Run tests in parallel# Affected commands (only what changed since base)
nx affected -t build # Build only affected projects
nx affected -t test# Test only affected projects
nx affected -t lint --base=main # Lint affected since main branch
nx show projects --affected # List affected project names# Project graph
nx graph # Open interactive dependency graph
nx graph --affected # Show only affected in graph# Generators
nx generate @nx/next:app my-app # Scaffold a Next.js app
nx generate @nx/react:lib my-lib # Scaffold a React library
nx generate @nx/js:lib utils --directory=libs/shared # JS library# Cache management
nx reset # Clear local cache
nx report # Show installed plugin versions# Migrations
nx migrate latest # Update Nx and plugins
nx migrate --run-migrations # Apply pending migrations
Inferred Targets (Plugin-Based)
// nx.json — plugins auto-detect and register targets{"plugins":[{"plugin":"@nx/vite/plugin","options":{"buildTargetName":"build","testTargetName":"test","serveTargetName":"serve"}}]}// No project.json needed — Nx infers targets from vite.config.ts presence
# Use the custom generator
nx generate @myorg/tools:feature-lib auth --scope=shared
CI Configuration (GitHub Actions)
# .github/workflows/ci.ymlname:CIon:push:branches: [main]
pull_request:jobs:main:runs-on:ubuntu-lateststeps:-uses:actions/checkout@v4with:fetch-depth:0# Needed for affected commands-uses:pnpm/action-setup@v4with:version:9-uses:actions/setup-node@v4with:node-version:22cache:pnpm-run:pnpminstall--frozen-lockfile# Set SHAs for affected commands-uses:nrwl/nx-set-shas@v4# Run only what's affected-run:pnpmnxaffected-tlinttestbuild--parallel=3# Or with Nx Cloud for distributed task execution# - run: pnpm nx-cloud start-ci-run --distribute-on="3 linux-medium-js"# - run: pnpm nx affected -t lint test build
Nx Cloud (Remote Caching)
# Connect workspace to Nx Cloud
npx nx connect
# CI sees cache hits from other developers and CI runs# Local dev benefits from CI cache — never rebuild what CI already built
Best Practices
Use tags and module boundaries — enforce architectural rules with @nx/enforce-module-boundaries
Prefer inferred targets — let plugins auto-detect config files instead of manual project.json targets
Use affected in CI — only run tasks for projects impacted by the current changeset
Define namedInputs — separate production inputs from test inputs for precise cache invalidation
Enable Nx Cloud — remote cache shared across CI and local dev eliminates redundant work
Use generators for scaffolding — ensures consistency and includes all boilerplate (tests, configs)
Set dependsOn: ["^build"] for build targets — ensures dependencies are built first
Keep libraries small and focused — better cache granularity and clearer dependency graph
Use --parallel with a reasonable limit (3-5) — over-parallelization causes memory issues
Run nx migrate regularly — keeps plugins compatible and applies codemods automatically