
Nx Monorepo
Configure Nx task graphs, local and remote caching, and affected CI runs so a solo builder’s monorepo builds only what changed.
Overview
nx-monorepo is an agent skill most often used in Build (also Ship) that teaches Nx task orchestration, caching, and affected CI patterns for monorepos.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill nx-monorepoWhat is this skill?
- Declarative task dependencies in project.json with dependsOn across projects and targets
- targetDefaults for build, test, and lint with cache, ^build, and production inputs
- Local cache under .nx/cache plus --skip-nx-cache and nx reset
- Remote cache via @nx/azure-cache (NX_KEY) and nxCloudId / nxCloudUrl in nx.json
- Affected workflows with nx-set-shas, base/head, and --files filters for CI
Adoption & trust: 1.1k installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have multiple apps and libs in one repo but builds feel slow, order is wrong, or CI runs everything on every push.
Who is it for?
Solo builders standardizing an Nx monorepo with shared libs, remote cache, and GitHub Actions affected pipelines.
Skip if: Single-package repos with no Nx workspace, or teams that only need generic npm scripts without graph-based orchestration.
When should I use this skill?
Working in an Nx workspace on task dependencies, caching, affected runs, or remote cache setup.
What do I get? / Deliverables
You get explicit dependsOn graphs, cache-aware targetDefaults, and affected commands aligned with your main branch so local and CI runs stay fast and predictable.
- project.json / nx.json target patterns
- affected CI command snippets
- remote cache configuration notes
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Monorepo orchestration is where you structure apps and libs before day-to-day feature work stabilizes. Workspace and target configuration (project.json, nx.json, affected) is classic build-phase product management for multi-package repos.
Where it fits
Define ^build dependsOn so shared-ui builds before consumer apps.
Add @nx/azure-cache and NX_KEY so teammates reuse CI artifacts.
Run nx affected -t test with nrwl/nx-set-shas on pull requests.
Use nx reset after toolchain upgrades when cached outputs look wrong.
How it compares
Reference skill for Nx graph and cache semantics—not a one-click deploy integration or generic Makefile cheat sheet.
Common Questions / FAQ
Who is nx-monorepo for?
Indie and solo developers maintaining Nx monorepos who want agent help configuring targets, caches, and affected CI without rereading scattered Nx docs.
When should I use nx-monorepo?
During Build when defining project.json and nx.json; during Ship when wiring nx affected, skip-nx-cache, and remote cache in CI; when debugging stale cache or missing upstream builds.
Is nx-monorepo safe to install?
Treat it as documentation-style guidance that may suggest shell and CI changes; review the Security Audits panel on this Prism page and inspect the skill bundle before granting repo or cloud credentials.
SKILL.md
READMESKILL.md - Nx Monorepo
# Advanced Nx Reference ## Task Orchestration ### Dependencies Define task dependencies in `project.json`: ```json { "targets": { "build": { "dependsOn": [ { "projects": ["shared-ui"], "target": "build" }, { "projects": ["api"], "target": "build", "params": "ignore" } ] } } } ``` ### Target Defaults Configure default behavior in `nx.json`: ```json { "targetDefaults": { "build": { "cache": true, "dependsOn": ["^build"], "inputs": ["production", "^production"] }, "test": { "cache": true, "inputs": ["default", "^production"] }, "lint": { "cache": true } } } ``` ## Caching ### Local Cache Enabled by default. Cache location: ``` .nx/cache ``` ### Bypass Cache ```bash # Single run nx run my-app:build --skip-nx-cache # Reset cache nx reset ``` ### Remote Cache ```bash # Install Azure cache nx add @nx/azure-cache # Generates activation key saved to .nx/key/key.ini # Set as environment variable: NX_KEY ``` Configuration in `nx.json`: ```json { "nxCloudId": "your-workspace-id", "nxCloudUrl": "https://cloud.nx.app" } ``` ## Affected Commands ### Base Configuration ```yaml # GitHub Actions - uses: nrwl/nx-set-shas@v4 with: main-branch-name: 'main' ``` ### Affected Patterns ```bash # Basic affected nx affected -t build # With base/head nx affected -t build --base=origin/main~1 --head=HEAD # With files nx affected -t build --files=libs/shared/* # Exclude projects nx affected -t build --exclude=legacy-app # Run multiple targets nx affected -t lint test build # Parallel execution nx affected -t build --parallel=5 ``` ## Project Graph ### Visualize Graph ```bash # Open in browser nx graph # Output as JSON nx graph --json=output.json # Output as static HTML nx graph --file=graph.html # Watch mode nx graph --watch ``` ### Query Projects ```bash # List all projects nx show projects # List projects with specific tags nx show projects --tags=type:ui # Show project details nx show project my-app # Show dependencies (JSON) nx show project my-app --json # Show affected projects nx show projects --affected ``` ## Module Federation ### Micro-Frontends Architecture ``` host-app (Shell) ├── remote1 (Checkout) ├── remote2 (Catalog) └── remote3 (User Profile) ``` ### Setup Host ```bash nx g @nx/react:host shell-app ``` ### Setup Remote ```bash nx g @nx/react:remote checkout --name=remote1 --port=4201 ``` ### Add Remote to Host ```bash nx g @nx/react:remote-configuration shell-app \ --remote=remote1 \ --port=4201 \ --type=module ``` ### Module Federation Config ```typescript // apps/shell-app/module-federation.config.ts module.exports = { name: 'shell', remotes: { remote1: 'remote1@http://localhost:4201/remoteEntry.js', }, }; ``` ## Named Inputs ### Configuration in nx.json ```json { "namedInputs": { "default": ["{projectRoot}/**/*"], "production": [ "default", "!{projectRoot}/**/*.spec.ts", "!{projectRoot}/**/*.test.ts", "!{projectRoot}/**/*.stories.ts" ], "nonProduction": [ "default", "{projectRoot}/**/*.spec.ts", "{projectRoot}/**/*.test.ts" ] }, "targetDefaults": { "build": { "inputs": ["production", "^production"] }, "test": { "inputs": ["default", "^production"] } } } ``` ## Workspace Layout ### Integrated Layout ``` my-workspace/ ├── apps/ ├── libs/ └── tools/ ``` ### Standalone Projects ``` my-workspace/ ├── packages/ │ ├── app1/ │ └── lib1/ ``` Set in `nx.json`: ```json { "workspaceLayout": { "appsDir": "packages", "libsDir": "packages" } } ``` ## Plugins ### Use Plugins ```json // nx.json { "plugins": [ { "plugin": "@nx/react" }, { "plugin": "@nx/js", "options": { "buildTargetName": "build", "testTargetName": "test" } } ] } ``` ### Custom Plugin Options ```json { "plugins": [ {