PluginBench
Skill
Pass
Audit score 90

nx-workspace-patterns

wshobson/agents

Configure and optimize Nx monorepo workspaces with production patterns for project boundaries, caching, and affected commands.

What is nx-workspace-patterns?

This skill provides production patterns for Nx monorepo management, including workspace architecture, library organization, and optimization strategies. Use it when setting up Nx workspaces, configuring project boundaries, optimizing CI with affected commands, implementing remote caching, or managing dependencies between projects.

  • Establish Nx workspace architecture with apps, libs, and tools directories
  • Define and enforce library types (feature, ui, data-access, util, shell) with consistent tagging
  • Configure project boundaries to prevent circular dependencies and maintain acyclic dependency graphs
  • Optimize CI pipelines using affected commands to test only changed projects
  • Implement build caching strategies for significant CI performance gains
  • Provide generators and templates to ensure consistency across workspace

How to install nx-workspace-patterns

npx skills add https://github.com/wshobson/agents --skill nx-workspace-patterns
Prerequisites
  • Nx installed in your project
  • Basic understanding of monorepo concepts
  • Node.js and npm or yarn package manager
Claude Code
Cursor
Windsurf
Cline

How to use nx-workspace-patterns

  1. 1.Review the workspace architecture pattern (apps, libs, tools structure) in the skill documentation
  2. 2.Define your library types and tagging strategy based on the provided table (feature, ui, data-access, util, shell)
  3. 3.Configure nx.json and workspace.json with appropriate project boundaries and tags
  4. 4.Set up module boundary rules to enforce the dependency graph and prevent circular dependencies
  5. 5.Enable caching in nx.json for build and test tasks
  6. 6.Implement affected commands in your CI pipeline to test only changed projects
  7. 7.Create custom generators using the templates provided to maintain consistency
  8. 8.Document your boundaries and library organization for your team

Use cases

Good for
  • Setting up a new Nx monorepo from scratch with proper folder structure and library organization
  • Migrating an existing codebase to Nx and establishing module boundaries
  • Optimizing CI/CD pipelines by implementing affected commands to reduce build times
  • Configuring remote caching to share build artifacts across team members and CI environments
  • Refactoring a monorepo to eliminate circular dependencies and enforce architectural boundaries
Who it's for
  • Monorepo architects and maintainers
  • Full-stack teams managing multiple applications and shared libraries
  • DevOps engineers optimizing CI/CD pipelines
  • Development teams migrating to Nx
  • Tech leads establishing coding standards and project structure

nx-workspace-patterns FAQ

What is the difference between apps and libs in Nx?

Apps are deployable applications (web, api, etc.) while libs are reusable, focused libraries organized by type (feature, ui, data-access, util, shell). This separation enables code sharing and independent testing.

How do I prevent circular dependencies in my monorepo?

Use module boundaries with tags in nx.json to enforce dependency rules. The dependency graph should remain acyclic. Nx will warn or error when boundaries are violated based on your configuration.

What are the performance benefits of using affected commands?

Affected commands (nx affected:test, nx affected:build) only run tasks on projects that have changed, significantly reducing CI time. Combined with caching, this can provide substantial savings.

When should I use remote caching?

Enable remote caching when you have a team or CI environment where multiple developers/machines build the same projects. It allows sharing of build artifacts to avoid redundant computation.

How granular should my libraries be?

Balance between having too many small libraries (hard to manage) and too few large ones (reduced reusability). Each library should have a single responsibility and clear purpose based on its type.

Full instructions (SKILL.md)

Source of truth, from wshobson/agents.


name: nx-workspace-patterns description: Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.

Nx Workspace Patterns

Production patterns for Nx monorepo management.

When to Use This Skill

  • Setting up new Nx workspaces
  • Configuring project boundaries
  • Optimizing CI with affected commands
  • Implementing remote caching
  • Managing dependencies between projects
  • Migrating to Nx

Core Concepts

1. Nx Architecture

workspace/
├── apps/              # Deployable applications
│   ├── web/
│   └── api/
├── libs/              # Shared libraries
│   ├── shared/
│   │   ├── ui/
│   │   └── utils/
│   └── feature/
│       ├── auth/
│       └── dashboard/
├── tools/             # Custom executors/generators
├── nx.json            # Nx configuration
└── workspace.json     # Project configuration

2. Library Types

TypePurposeExample
featureSmart components, business logicfeature-auth
uiPresentational componentsui-buttons
data-accessAPI calls, state managementdata-access-users
utilPure functions, helpersutil-formatting
shellApp bootstrappingshell-web

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's

  • Use tags consistently - Enforce with module boundaries
  • Enable caching early - Significant CI savings
  • Keep libs focused - Single responsibility
  • Use generators - Ensure consistency
  • Document boundaries - Help new developers

Don'ts

  • Don't create circular deps - Graph should be acyclic
  • Don't skip affected - Test only what changed
  • Don't ignore boundaries - Tech debt accumulates
  • Don't over-granularize - Balance lib count