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- Nx installed in your project
- Basic understanding of monorepo concepts
- Node.js and npm or yarn package manager
How to use nx-workspace-patterns
- 1.Review the workspace architecture pattern (apps, libs, tools structure) in the skill documentation
- 2.Define your library types and tagging strategy based on the provided table (feature, ui, data-access, util, shell)
- 3.Configure nx.json and workspace.json with appropriate project boundaries and tags
- 4.Set up module boundary rules to enforce the dependency graph and prevent circular dependencies
- 5.Enable caching in nx.json for build and test tasks
- 6.Implement affected commands in your CI pipeline to test only changed projects
- 7.Create custom generators using the templates provided to maintain consistency
- 8.Document your boundaries and library organization for your team
Use cases
- 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
- 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
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.
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.
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.
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.
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
| Type | Purpose | Example |
|---|---|---|
| feature | Smart components, business logic | feature-auth |
| ui | Presentational components | ui-buttons |
| data-access | API calls, state management | data-access-users |
| util | Pure functions, helpers | util-formatting |
| shell | App bootstrapping | shell-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
Related skills
More from wshobson/agents and the wider catalog.

on-call-handoff-patterns
Master on-call shift handoffs with structured context transfer and escalation procedures.

openapi-spec-generation
Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.

parallel-debugging
Debug complex issues systematically using competing hypotheses and parallel investigation.

parallel-feature-development
Coordinate parallel feature development with file ownership strategies and conflict avoidance rules for multi-agent teams.

paypal-integration
Integrate PayPal payments with express checkout, subscriptions, and refund management.

pci-compliance
Implement PCI DSS compliance for secure payment card handling and processing.