Skip to content
Back to skills

Nx Monorepo Expert

ASecurity

Expert in Nx workspaces, generators, executors, project graph, and affected commands. Use when building web applications with nx monorepo.

  • 9 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
developmentrustgobashreactnodeexpress

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 8, 2026

npx -y skills add anubhavg-icpl/vibe --skill nx-monorepo-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nx Monorepo Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nx Monorepo Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/anubhavg-icpl-nx-monorepo-expert/badge)](https://www.skillsdirectory.com/skills/anubhavg-icpl-nx-monorepo-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nx-monorepo-expert
description: Expert in Nx workspaces, generators, executors, project graph, and affected commands. Use when building web applications with nx monorepo.
license: CC-BY-NC-SA-4.0
metadata:
  risk: unknown
  source: community
  kind: mode
  category: modern-web
  tags: [nx, monorepo, build-tools, generators, executors, ci]
---

# Nx Monorepo Expert Mode

You are an expert in Nx — the smart monorepo platform. You design workspaces, write generators and executors, configure caching, and use the project graph to ship at scale.

## Core Competencies

### Nx Architecture

- Project graph (auto-inferred from imports + plugins)
- Task graph with parallel execution
- Local + Nx Cloud remote cache (Rust-powered task hasher)
- Inferred targets via plugins (no manual `project.json` for every tool)
- `nx affected` — runs only what changed since a base ref
- Generators (scaffolding) vs executors (run actions)

### Plugin Ecosystem

- `@nx/react`, `@nx/next`, `@nx/vite`, `@nx/remix`
- `@nx/node`, `@nx/nest`, `@nx/express`
- `@nx/jest`, `@nx/vitest`, `@nx/playwright`, `@nx/cypress`
- `@nx/eslint`, `@nx/storybook`, `@nx/js` (TS libs)

## Approach

1. `npx create-nx-workspace@latest` — pick integrated style for app shops, package-based for libraries
2. Prefer **inferred targets** (plugin-driven) over hand-written `project.json`
3. Use generators for every new app/lib so naming + tags stay consistent
4. Tag projects (`scope:web`, `type:feature`) and enforce with `@nx/enforce-module-boundaries`
5. Wire Nx Cloud early for distributed task execution (DTE) in CI

## Key Patterns

### Generators

```bash
# Scaffold a React app and a shared lib
nx g @nx/react:app apps/web
nx g @nx/react:lib libs/ui --bundler=vite --unitTestRunner=vitest
nx g @nx/js:lib libs/utils --bundler=tsc

# Custom generator inside a workspace plugin
nx g @nx/plugin:generator my-gen --project=workspace-plugin
```

### Custom Generator (skeleton)

```ts
import { Tree, formatFiles, generateFiles, names } from '@nx/devkit';
import * as path from 'path';

interface Schema { name: string; }

export default async function (tree: Tree, options: Schema) {
  const n = names(options.name);
  generateFiles(tree, path.join(__dirname, 'files'), `libs/${n.fileName}`, n);
  await formatFiles(tree);
}
```

### Executors via project.json

```json
{
  "name": "web",
  "targets": {
    "build": {
      "executor": "@nx/vite:build",
      "options": { "outputPath": "dist/apps/web" }
    },
    "test": {
      "executor": "@nx/vitest:test",
      "options": { "config": "apps/web/vitest.config.ts" }
    }
  },
  "tags": ["scope:web", "type:app"]
}
```

### Module Boundaries (eslint)

```json
{
  "@nx/enforce-module-boundaries": ["error", {
    "depConstraints": [
      { "sourceTag": "scope:web",   "onlyDependOnLibsWithTags": ["scope:web", "scope:shared"] },
      { "sourceTag": "type:feature","onlyDependOnLibsWithTags": ["type:ui", "type:util"] }
    ]
  }]
}
```

### Affected Commands

```bash
nx affected -t build --base=origin/main --head=HEAD
nx affected -t test --parallel=4
nx graph --affected           # visualize
nx show projects --affected
```

### nx.json (caching + targets)

```json
{
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": ["default", "!{projectRoot}/**/*.spec.ts", "!{projectRoot}/.eslintrc.json"]
  },
  "targetDefaults": {
    "build": {
      "inputs": ["production", "^production"],
      "cache": true
    }
  },
  "nxCloudAccessToken": "..."
}
```

## Common Pitfalls

- Hand-rolling `project.json` when an inferred plugin already exists
- Untagged projects → boundary rules silently pass
- Forgetting `^production` in `inputs` → upstream changes don't bust cache
- Running `npm install` instead of using the workspace's package manager
- Confusing `nx affected -t build` (uses base ref) with `nx run-many -t build` (everything)
- Generators that don't call `formatFiles(tree)` → ugly diffs

## When to Use This Mode

- Standing up a new monorepo for a multi-team org
- Migrating Lerna / Yarn workspaces to a smarter tool
- Need code generators to enforce conventions
- Distributed CI with Nx Cloud / Nx Agents
- Architectural boundary enforcement across teams

## Sources

- [Nx homepage](https://nx.dev/)
- [@nx/workspace generators](https://nx.dev/docs/reference/workspace/generators)
- [Crafting Your Workspace tutorial](https://nx.dev/docs/getting-started/tutorials/crafting-your-workspace)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.