PluginBench
Skill
Review
Audit score 70

nx-monorepo

giuseppe-trisciuoglio/developer-kit

Comprehensive Nx monorepo management for TypeScript/JavaScript projects with workspace creation, generators, and CI/CD integration.

What is nx-monorepo?

Provides guidance for managing Nx monorepos in TypeScript/JavaScript, covering workspace creation, project generation, task execution, caching, Module Federation, and CI/CD pipelines. Use when setting up or scaling a monorepo, generating apps/libraries, running affected commands, or configuring advanced features like Module Federation and NestJS backends.

  • Create and initialize Nx workspaces with interactive or preset-based setup
  • Generate applications, libraries, and components using Nx generators for React, NestJS, and TypeScript
  • Run affected commands to execute tasks only on changed projects, optimizing build times
  • Configure Module Federation for micro-frontend architectures with host and remote applications
  • Set up CI/CD pipelines using affected commands to minimize build scope
  • Manage project dependencies, tags, and workspace organization for scalable monorepos

How to install nx-monorepo

npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill nx-monorepo
Prerequisites
  • Node.js 18.10 or higher
  • npm or yarn package manager
  • Git for version control (recommended for affected commands)
Claude Code
Cursor
Windsurf
Cline

How to use nx-monorepo

  1. 1.Create a new workspace with `npx create-nx-workspace@latest` or initialize Nx in an existing project with `nx@latest init`
  2. 2.Generate applications and libraries using `nx g @nx/react:app`, `nx g @nx/react:lib`, or `nx g @nx/nest:app` commands
  3. 3.Run tasks with `nx affected -t lint test build` for changed projects or `nx run-many -t build` for all projects
  4. 4.Visualize dependencies with `nx graph` to understand project relationships and identify issues
  5. 5.Configure CI/CD workflows to use `nx affected` commands, ensuring only changed projects are tested and built
  6. 6.Set up Module Federation by generating host and remote applications with `nx g @nx/react:host` and `nx g @nx/react:remote`

Use cases

Good for
  • Creating a new Nx workspace with React, Angular, or NestJS and setting up initial project structure
  • Running tests and builds only for projects affected by recent code changes in CI/CD pipelines
  • Building a shared UI library and consuming it across multiple applications with automatic TypeScript path mapping
  • Configuring Module Federation to deploy micro-frontends independently while sharing code at runtime
  • Debugging build performance issues by analyzing the dependency graph and optimizing cache strategies
Who it's for
  • Full-stack TypeScript/JavaScript developers managing monorepos
  • Frontend teams using React or Angular with shared component libraries
  • Backend teams implementing NestJS applications within a monorepo
  • DevOps engineers setting up CI/CD pipelines for monorepo projects
  • Architects designing micro-frontend architectures with Module Federation

nx-monorepo FAQ

When should I use `nx affected` vs `nx run-many`?

`nx affected` runs tasks only on projects changed since a base branch (ideal for CI), while `nx run-many` executes tasks across all or specified projects. Use `nx affected` in CI pipelines and `nx run-many` for local development or when you need to rebuild everything.

How do I prevent circular dependencies in my monorepo?

Use tags consistently to organize projects by domain and scope, configure `workspaceLayout` boundaries in `nx.json`, and regularly check the dependency graph with `nx graph`. The graph visualization will highlight circular dependencies in red.

What is Module Federation and when should I use it?

Module Federation allows separate applications to share code at runtime, enabling independent deployment of micro-frontends. Use it when you have multiple teams deploying independently or need to load features dynamically without rebuilding the host application.

How can I speed up builds in a large monorepo?

Enable remote caching with Nx Cloud, use `nx affected` in CI to avoid rebuilding unchanged projects, configure `namedInputs` to exclude test files from production cache keys, and organize libraries by domain to minimize unnecessary rebuilds.

Do I need Nx Cloud for caching to work?

No, Nx includes local caching by default. Nx Cloud adds distributed caching across team members and CI agents, significantly improving build times in team environments, but is optional.

Full instructions (SKILL.md)

Source of truth, from giuseppe-trisciuoglio/developer-kit.


name: nx-monorepo description: Provides comprehensive Nx monorepo management guidance for TypeScript/JavaScript projects. Use when creating Nx workspaces, generating apps/libraries/components, running affected commands, setting up CI/CD, configuring Module Federation, or implementing NestJS backends within Nx allowed-tools: Read, Write, Edit, Bash, Glob, Grep

Nx Monorepo

Overview

Provides guidance for Nx monorepo management in TypeScript/JavaScript projects. Covers workspace creation, project generation, task execution, caching strategies, Module Federation, and CI/CD integration.

When to Use

Use this skill when:

  • Creating a new Nx workspace or initializing Nx in an existing project
  • Generating applications, libraries, or components with Nx generators
  • Running affected commands or executing tasks across multiple projects
  • Setting up CI/CD pipelines for Nx projects (GitHub Actions, CircleCI, etc.)
  • Configuring Module Federation with React or Next.js
  • Implementing NestJS backend applications within Nx
  • Managing TypeScript package libraries with buildable and publishable libs
  • Setting up remote caching or Nx Cloud
  • Optimizing monorepo build times and caching strategies
  • Debugging dependency graph issues or circular dependencies

Trigger phrases: "create Nx workspace", "Nx monorepo", "generate Nx app", "Nx affected", "Nx CI/CD", "Module Federation Nx", "Nx Cloud"

Instructions

Workspace Creation

  1. Create a new workspace with interactive setup:

    npx create-nx-workspace@latest
    

    Follow prompts to select preset (Integrated, Standalone, Package-based) and framework stack.

  2. Initialize Nx in an existing project:

    nx@latest init
    
  3. Create with specific preset (non-interactive):

    npx create-nx-workspace@latest my-workspace --preset=react
    

    Verify: nx show projects lists the new workspace projects

Project Generation

  1. Generate a React application:

    nx g @nx/react:app my-app
    
  2. Generate a library:

    # React library
    nx g @nx/react:lib my-lib
    
    # TypeScript library
    nx g @nx/js:lib my-util
    

    Verify: nx show projects lists the new lib

  3. Generate a component in lib:

    nx g @nx/react:component my-comp --project=my-lib
    
  4. Generate NestJS backend:

    nx g @nx/nest:app my-api
    

    Verify: nx show projects lists my-api and nx run my-api:build succeeds

Task Execution

  1. Run tasks for affected projects only:

    nx affected -t lint test build
    
  2. Run tasks across all projects:

    # Build all projects
    nx run-many -t build
    
    # Test specific projects
    nx run-many -t test -p=my-app,my-lib
    
    # Test by pattern
    nx run-many -t test --projects=*-app
    
  3. Run specific target on single project:

    nx run my-app:build
    
  4. Visualize dependency graph:

    nx graph
    

Project Configuration

Each project has a project.json defining targets, executor, and configurations:

{
  "name": "my-app",
  "projectType": "application",
  "sourceRoot": "apps/my-app/src",
  "targets": {
    "build": {
      "executor": "@nx/react:webpack",
      "outputs": ["{workspaceRoot}/dist/apps/my-app"],
      "configurations": {
        "production": {
          "optimization": true
        }
      }
    },
    "test": {
      "executor": "@nx/vite:test"
    }
  },
  "tags": ["type:app", "scope:frontend"]
}

Dependency Management

  1. Set up project dependencies:

    {
      "targets": {
        "build": {
          "dependsOn": [
            { "projects": ["shared-ui"], "target": "build" }
          ]
        }
      }
    }
    
  2. Use tags for organization:

    { "tags": ["type:ui", "scope:frontend", "platform:web"] }
    

Module Federation (Nx 17+)

  1. Generate a remote (micro-frontend):

    nx g @nx/react:remote checkout --host=dashboard
    
  2. Generate a host:

    nx g @nx/react:host dashboard
    

CI/CD Setup

Use affected commands in CI to only build/test changed projects:

# .github/workflows/ci.yml
- run: npx nx affected -t lint --parallel
- run: npx nx affected -t test --parallel
- run: npx nx affected -t build --parallel

Examples

Example 1: Create New React Workspace

Input: "Create a new Nx workspace with React and TypeScript"

Steps:

npx create-nx-workspace@latest my-workspace
# Select: Integrated Monorepo → React → Integrated monorepo (Nx Cloud)

Verify: cd my-workspace && nx show projects lists the created app

Expected Result: Workspace created with:

  • apps/ directory with React app
  • libs/ directory for shared libraries
  • nx.json with cache configuration
  • CI/CD workflow files ready

Example 2: Run Tests for Changed Projects

Input: "Run tests only for projects affected by recent changes"

Command:

nx affected -t test --base=main~1 --head=main

Expected Result: Only tests for projects affected by changes between commits are executed, leveraging cached results from previous runs.

Example 3: Generate and Build a Shared Library

Input: "Create a shared UI library and use it in the app"

Steps:

# Generate library
nx g @nx/react:lib shared-ui

# Generate component in library
nx g @nx/react:component button --project=shared-ui

# Import in app (tsconfig paths auto-configured)
import { Button } from '@my-workspace/shared-ui'

Verify: nx run shared-ui:build completes successfully and nx graph shows the dependency link to your app

Expected Result: Buildable library at libs/shared-ui with proper TypeScript path mapping configured.

Example 4: Set Up Module Federation

Input: "Configure Module Federation for micro-frontends"

Steps:

# Create host app
nx g @nx/react:host dashboard

# Add remote to host
nx g @nx/react:remote product-catalog --host=dashboard

# Start dev servers
nx run dashboard:serve
nx run product-catalog:serve

Verify: Both servers start without errors and nx graph shows dashboard → product-catalog remote connection

Expected Result: Two separate applications running where product-catalog loads dynamically into dashboard at runtime.

Example 5: Debug Build Dependencies

Input: "Why is my app rebuilding when unrelated lib changes?"

Diagnosis:

# Show project graph
nx graph --focused=my-app

# Check implicit dependencies
nx show project my-app --json | grep implicitDependencies

Solution: Add explicit dependency configuration or use namedInputs in nx.json to exclude certain files from triggering builds.

Verify Fix Worked: Make a change to the unrelated lib, run nx affected -t buildmy-app should not appear in the affected projects list.

Best Practices

  • Always use nx affected in CI to only test/build changed projects
  • Organize libs by domain/business capability, not by technical layer
  • Use tags consistently (type:app|lib, scope:frontend|backend|shared)
  • Prevent circular dependencies by configuring workspaceLayout boundaries in nx.json
  • Enable remote caching with Nx Cloud for team productivity
  • Keep project.json simple - use defaults from nx.json when possible
  • Leverage generators instead of manual file creation for consistency
  • Configure namedInputs to exclude test files from production cache keys
  • Use Module Federation for independent deployment of micro-frontends
  • Keep workspace generators in tools/ for project-specific scaffolding

Constraints and Warnings

  • Node.js 18.10+ is required for Nx 17+
  • Windows users: Use WSL or Git Bash for best experience
  • First-time setup may take longer due to package installation
  • Large monorepos (50+ projects) should use distributed task execution
  • Module Federation requires webpack 5+ and specific Nx configuration
  • Some generators require additional plugins to be installed first
  • Cache location: Default ~/.nx/cache can grow large; configure cacheDirectory in nx.json if needed
  • Circular dependencies will cause build failures; use nx graph to visualize
  • Preset migration: Converting between Integrated/Standalone/Package-based requires manual effort

Reference Files

For detailed guidance on specific topics, consult:

TopicReference File
Workspace setup, basic commandsreferences/basics.md
Generators (app, lib, component)references/generators.md
React, Next.js, Expo patternsreferences/react.md
NestJS backend patternsreferences/nestjs.md
TypeScript packagesreferences/typescript.md
CI/CD (GitHub, CircleCI, etc.)references/ci-cd.md
Caching, affected, advancedreferences/advanced.md

Related skills

More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

PRprompt-engineering logo

prompt-engineering

giuseppe-trisciuoglio/developer-kit

Design, debug, and optimize LLM prompts with few-shot learning, chain-of-thought, and template systems.

1.5k installs
QDqdrant logo

qdrant

giuseppe-trisciuoglio/developer-kit

Qdrant vector database integration for Java with LangChain4j—semantic search and RAG pipelines.

1.4k installs
QWqwen-coder logo

qwen-coder

giuseppe-trisciuoglio/developer-kit

Provides Qwen Coder CLI delegation workflows for coding tasks using Qwen2.5-Coder and QwQ models, including English prompt formulation, execution flags, and safe result handling. Use when the user explicitly asks to use Qwen for tasks such as code generation, refactoring, debugging, or architectural analysis. Triggers on "use qwen", "use qwen coder", "delegate to qwen", "ask qwen", "second opinion from qwen", "qwen opinion", "continue with qwen", "qwen session".

923 installs
RArag logo

rag

giuseppe-trisciuoglio/developer-kit

Document chunking, embedding generation, and vector storage for Retrieval-Augmented Generation systems.

1.3k installs
RAralph-loop logo

ralph-loop

giuseppe-trisciuoglio/developer-kit

Ralph Wiggum-inspired automation loop for specification-driven development. Orchestrates task implementation, review, cleanup, and synchronization using a Python script. Use when: user runs /loop command, user asks to automate task implementation, user wants to iterate through spec tasks step-by-step, or user wants to run development workflow automation with context window management. One step per invocation. State machine: init → choose_task → implementation → review → fix → cleanup → sync → update_done. Supports --from-task and --to-task for task range filtering. State persisted in fix_plan.json.

936 installsAudited
REreact-code-review logo

react-code-review

giuseppe-trisciuoglio/developer-kit

Provides comprehensive code review capability for React applications, validates component architecture, hooks usage, React 19 patterns, state management, performance optimization, accessibility compliance, and TypeScript integration. Use when reviewing React code changes, before merging pull requests, after implementing new features, or for component architecture validation. Triggers on "review React code", "React code review", "check my React components".

1.2k installsAudited