{"slug":"shared-monorepo-nx","title":"shared-monorepo-nx","summary":"Nx monorepo build system — workspace configuration, project graph, task pipelines, caching, generators, plugins, and release management","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-29T15:28:17.167597Z","repo":{"url":"https://github.com/agents-inc/skills","stars":24,"forks":8,"license":"MIT","updatedAt":"2026-09-07T17:50:55Z"},"bodyHtml":"<hr>\n<h2>name: shared-monorepo-nx\ndescription: Nx monorepo build system — workspace configuration, project graph, task pipelines, caching, generators, plugins, and release management</h2>\n<h1>Monorepo Orchestration with Nx</h1>\n<blockquote>\n<p><strong>Quick Guide:</strong> Nx 22 for monorepo orchestration and build intelligence. Project graph for dependency analysis. Task pipelines with topological ordering and <code>dependsOn</code>. Local computation caching + Nx Cloud remote caching for massive speed gains. Inferred tasks (Project Crystal) auto-detect targets from tool config files. <code>nx affected</code> runs only what changed. <code>nx release</code> for versioning, changelogs, and publishing. Generators scaffold code, executors run tasks.</p>\n</blockquote>\n<hr>\n<p>&lt;critical_requirements&gt;</p>\n<h2>CRITICAL: Before Using This Skill</h2>\n<blockquote>\n<p><strong>All code must follow project conventions in CLAUDE.md</strong> (kebab-case, named exports, import ordering, <code>import type</code>, named constants)</p>\n</blockquote>\n<p><strong>(You MUST enable caching with <code>\"cache\": true</code> on cacheable targets — builds, tests, linting — and set <code>\"cache\": false</code> or omit for side-effect tasks like <code>serve</code>)</strong></p>\n<p><strong>(You MUST define <code>dependsOn: [\"^build\"]</code> in targetDefaults for build tasks to ensure topological ordering across the project graph)</strong></p>\n<p><strong>(You MUST declare <code>inputs</code> and <code>outputs</code> for cached targets so Nx knows what to hash and what to restore)</strong></p>\n<p><strong>(You MUST use inferred tasks (Project Crystal) as the default — only add <code>project.json</code> targets when overriding inferred configuration)</strong></p>\n<p><strong>(You MUST use <code>nx affected -t &lt;target&gt;</code> in CI to only run tasks for changed projects and their dependents)</strong></p>\n<p>&lt;/critical_requirements&gt;</p>\n<hr>\n<p><strong>Auto-detection:</strong> Nx workspace, nx.json, project.json, nx generate, nx affected, nx graph, nx release, @nx/ plugins, Nx Cloud, inferred tasks, Project Crystal, nx migrate, targetDefaults, namedInputs, nx run-many, nx serve</p>\n<p><strong>When to use:</strong></p>\n<ul>\n<li>Setting up a new Nx monorepo or adding Nx to an existing repo</li>\n<li>Configuring task pipelines, caching, and dependency ordering in nx.json</li>\n<li>Generating projects, libraries, and components with Nx generators</li>\n<li>Running affected commands to optimize CI builds</li>\n<li>Configuring Nx Cloud for remote caching and distributed task execution</li>\n<li>Managing releases with <code>nx release</code> (versioning, changelogs, publishing)</li>\n<li>Setting up module federation for micro-frontend architectures</li>\n<li>Migrating between Nx versions with <code>nx migrate</code></li>\n</ul>\n<p><strong>When NOT to use:</strong></p>\n<ul>\n<li>Single application with no shared libraries (standard build tools suffice)</li>\n<li>Projects already using Turborepo (do not mix monorepo orchestrators)</li>\n<li>Very small projects where Nx setup overhead exceeds benefits</li>\n<li>When all you need is <code>npm workspaces</code> without task orchestration</li>\n</ul>\n<p><strong>Key patterns covered:</strong></p>\n<ul>\n<li>Workspace setup and nx.json configuration</li>\n<li>Task pipelines with <code>targetDefaults</code> and <code>dependsOn</code></li>\n<li>Local + remote caching strategies</li>\n<li>Inferred tasks (Project Crystal) and plugin system</li>\n<li>Affected commands and project graph</li>\n<li>Generators and executors</li>\n<li>Release management (<code>nx release</code>)</li>\n<li>Module federation for micro-frontends</li>\n</ul>\n<h2>Examples</h2>\n<ul>\n<li><a href=\"examples/core.md\">Workspace Setup</a> — Directory structure, nx.json config</li>\n<li><a href=\"examples/tasks.md\">Task Pipeline &amp; Caching</a> — dependsOn ordering, namedInputs, cache configuration, affected commands</li>\n<li><a href=\"examples/generators.md\">Generators</a> — Built-in generators, custom generators, schemas, migrations</li>\n<li><a href=\"examples/ci.md\">CI &amp; Release Management</a> — GitHub Actions, Nx Cloud, release configuration, module federation</li>\n</ul>\n<p><strong>Additional resources:</strong></p>\n<ul>\n<li>For CLI reference and decision frameworks, see <a href=\"reference.md\">reference.md</a></li>\n</ul>\n<hr>\n\n<hr>\n\n<hr>\n\n<hr>\n<p>&lt;decision_framework&gt;</p>\n<h2>Decision Framework</h2>\n<h3>When to Use Nx</h3>\n<pre><code>Is this a monorepo with shared code?\n├─ NO → Standard build tools (Vite, esbuild, tsc)\n└─ YES → Do you need task orchestration and caching?\n    ├─ NO → npm/pnpm/bun workspaces alone may suffice\n    └─ YES → Do you need a project graph and affected analysis?\n        ├─ YES → Nx\n        └─ NO → Turborepo may be simpler\n</code></pre>\n<h3>Nx vs Turborepo</h3>\n<pre><code>Which monorepo tool?\n├─ Need project graph analysis → Nx\n├─ Need generators and code scaffolding → Nx\n├─ Need module federation support → Nx\n├─ Need distributed task execution (Nx Agents) → Nx\n├─ Need simplest possible config → Turborepo\n├─ Already using Vercel ecosystem → Turborepo\n└─ Need polyglot support (.NET, Java, Gradle) → Nx\n</code></pre>\n<h3>Where to Put New Code</h3>\n<pre><code>New code to write?\n├─ Deployable application → apps/\n├─ Shared across 2+ apps → libs/ or packages/\n├─ App-specific code → Feature folder within the app\n├─ Build tooling or generators → tools/\n└─ Shared configuration → packages/ (e.g., eslint-config, tsconfig)\n</code></pre>\n<h3>Fixed vs Independent Releases</h3>\n<pre><code>How to version packages?\n├─ All packages always release together → \"fixed\" (default)\n├─ Packages have different consumers → \"independent\"\n├─ Internal-only packages → Fixed (simpler)\n└─ Published to npm with different audiences → Independent\n</code></pre>\n<p>For comprehensive decision trees and anti-patterns, see <a href=\"reference.md\">reference.md</a>.</p>\n<p>&lt;/decision_framework&gt;</p>\n<hr>\n\n<hr>\n<p>&lt;red_flags&gt;</p>\n<h2>RED FLAGS</h2>\n<p><strong>High Priority Issues:</strong></p>\n<ul>\n<li>Missing <code>dependsOn: [\"^build\"]</code> for build targets — dependencies may not build first, causing import errors</li>\n<li>Missing <code>cache: true</code> on cacheable targets — every run recomputes from scratch, negating Nx's primary value</li>\n<li>Caching long-running tasks (dev servers, watch mode) — <code>serve</code> and <code>dev</code> must have <code>cache: false</code></li>\n<li>Running <code>nx run-many -t test</code> in CI instead of <code>nx affected -t test</code> — wastes compute on unchanged projects</li>\n<li>Missing <code>inputs</code> on cached targets — Nx cannot determine when cache is stale, leading to incorrect cache hits</li>\n</ul>\n<p><strong>Medium Priority Issues:</strong></p>\n<ul>\n<li>Not using inferred tasks — manually defining every target in <code>project.json</code> when plugins can auto-detect</li>\n<li>Missing <code>namedInputs</code> for production — test file changes invalidate build caches unnecessarily</li>\n<li>Not connecting to Nx Cloud — every developer rebuilds everything locally instead of sharing cache</li>\n<li>Overly broad <code>outputs</code> — caching framework cache directories (<code>.next/cache/</code>) bloats cache storage</li>\n</ul>\n<p><strong>Common Mistakes:</strong></p>\n<ul>\n<li>Using <code>dependsOn: [\"build\"]</code> (same project) when <code>dependsOn: [\"^build\"]</code> (dependency projects) was intended</li>\n<li>Forgetting to set <code>continuous: true</code> on serve tasks — dependent e2e tasks wait forever for serve to \"complete\"</li>\n<li>Running <code>nx migrate</code> without <code>--run-migrations</code> — migrations are generated but not applied</li>\n<li>Not setting <code>defaultBase</code> in nx.json — affected analysis defaults to <code>main</code> which may not be your branch</li>\n</ul>\n<p><strong>Gotchas &amp; Edge Cases:</strong></p>\n<ul>\n<li><code>dependsOn: [\"^task\"]</code> runs the target on <strong>dependency</strong> projects; <code>dependsOn: [\"task\"]</code> runs it on the <strong>same</strong> project. Mixing these up causes subtle ordering bugs.</li>\n<li><code>nx affected</code> requires git history — in CI, ensure <code>fetch-depth: 0</code> (full history) or at least <code>fetch-depth: 2</code> for shallow comparison.</li>\n<li>Plugin order in <code>nx.json</code> matters — when multiple plugins create the same target name, the last plugin wins.</li>\n<li><code>maxCacheSize: \"0\"</code> means unlimited, not zero. To disable caching, use <code>cache: false</code> on targets.</li>\n<li>Nx merges <code>project.json</code> and <code>package.json</code> scripts. If both define the same target, <code>project.json</code> takes precedence for configuration but <code>package.json</code> scripts are still registered as targets.</li>\n<li><code>nx reset</code> clears the local cache AND shuts down the Nx Daemon. Use <code>nx reset --only-cache</code> to preserve the daemon.</li>\n</ul>\n<p>&lt;/red_flags&gt;</p>\n<hr>\n<p>&lt;critical_reminders&gt;</p>\n<h2>CRITICAL REMINDERS</h2>\n<blockquote>\n<p><strong>All code must follow project conventions in CLAUDE.md</strong></p>\n</blockquote>\n<p><strong>(You MUST enable caching with <code>\"cache\": true</code> on cacheable targets — builds, tests, linting — and set <code>\"cache\": false</code> or omit for side-effect tasks like <code>serve</code>)</strong></p>\n<p><strong>(You MUST define <code>dependsOn: [\"^build\"]</code> in targetDefaults for build tasks to ensure topological ordering across the project graph)</strong></p>\n<p><strong>(You MUST declare <code>inputs</code> and <code>outputs</code> for cached targets so Nx knows what to hash and what to restore)</strong></p>\n<p><strong>(You MUST use inferred tasks (Project Crystal) as the default — only add <code>project.json</code> targets when overriding inferred configuration)</strong></p>\n<p><strong>(You MUST use <code>nx affected -t &lt;target&gt;</code> in CI to only run tasks for changed projects and their dependents)</strong></p>\n<p><strong>Failure to follow these rules will cause incorrect builds, stale caches, wasted CI compute, and broken task ordering.</strong></p>\n<p>&lt;/critical_reminders&gt;</p>\n","files":[{"path":"examples/ci.md","sizeBytes":5790,"isText":true},{"path":"examples/core.md","sizeBytes":5080,"isText":true},{"path":"examples/generators.md","sizeBytes":5803,"isText":true},{"path":"examples/nx.md","sizeBytes":436,"isText":true},{"path":"examples/tasks.md","sizeBytes":6213,"isText":true},{"path":"reference.md","sizeBytes":15095,"isText":true},{"path":"SKILL.md","sizeBytes":18634,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"notes-only","suspicious":0,"notes":1,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-29T15:31:28.86782Z","sha256":"4797F8309D58E309C89EAF1283B4E7BA7C4FCC48A44CA4D560D7611E652DA892","sizeBytes":20044},"review":null,"source":{"repositoryUrl":"https://github.com/agents-inc/skills","path":"dist/plugins/shared-monorepo-nx/skills/shared-monorepo-nx","license":"MIT","commit":"3a51ef571e996b18294bf776d53dbdad26de0617","subtreeSha":"841A85C63F39BD3055CDD30BE08CB7B39BC6A6F86191B4A81000BF767F76759D","lastSyncedAt":"2026-09-29T15:27:48.914434Z"},"reviewedAt":"2026-09-29T15:38:07.139244Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/agents-inc/skills/tree/main/dist/plugins/shared-monorepo-nx/skills/shared-monorepo-nx"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install agents-inc-skills@llmmart"},{"target":"git","command":"git clone https://github.com/agents-inc/skills.git"}]}