$npx -y skills add wshobson/agents --skill nx-workspace-patternsConfigure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.
| 1 | # Nx Workspace Patterns |
| 2 | |
| 3 | Production patterns for Nx monorepo management. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | - Setting up new Nx workspaces |
| 8 | - Configuring project boundaries |
| 9 | - Optimizing CI with affected commands |
| 10 | - Implementing remote caching |
| 11 | - Managing dependencies between projects |
| 12 | - Migrating to Nx |
| 13 | |
| 14 | ## Core Concepts |
| 15 | |
| 16 | ### 1. Nx Architecture |
| 17 | |
| 18 | ``` |
| 19 | workspace/ |
| 20 | ├── apps/ # Deployable applications |
| 21 | │ ├── web/ |
| 22 | │ └── api/ |
| 23 | ├── libs/ # Shared libraries |
| 24 | │ ├── shared/ |
| 25 | │ │ ├── ui/ |
| 26 | │ │ └── utils/ |
| 27 | │ └── feature/ |
| 28 | │ ├── auth/ |
| 29 | │ └── dashboard/ |
| 30 | ├── tools/ # Custom executors/generators |
| 31 | ├── nx.json # Nx configuration |
| 32 | └── workspace.json # Project configuration |
| 33 | ``` |
| 34 | |
| 35 | ### 2. Library Types |
| 36 | |
| 37 | | Type | Purpose | Example | |
| 38 | | --------------- | -------------------------------- | ------------------- | |
| 39 | | **feature** | Smart components, business logic | `feature-auth` | |
| 40 | | **ui** | Presentational components | `ui-buttons` | |
| 41 | | **data-access** | API calls, state management | `data-access-users` | |
| 42 | | **util** | Pure functions, helpers | `util-formatting` | |
| 43 | | **shell** | App bootstrapping | `shell-web` | |
| 44 | |
| 45 | ## Templates and detailed worked examples |
| 46 | |
| 47 | Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates. |
| 48 | |
| 49 | ## Best Practices |
| 50 | |
| 51 | ### Do's |
| 52 | |
| 53 | - **Use tags consistently** - Enforce with module boundaries |
| 54 | - **Enable caching early** - Significant CI savings |
| 55 | - **Keep libs focused** - Single responsibility |
| 56 | - **Use generators** - Ensure consistency |
| 57 | - **Document boundaries** - Help new developers |
| 58 | |
| 59 | ### Don'ts |
| 60 | |
| 61 | - **Don't create circular deps** - Graph should be acyclic |
| 62 | - **Don't skip affected** - Test only what changed |
| 63 | - **Don't ignore boundaries** - Tech debt accumulates |
| 64 | - **Don't over-granularize** - Balance lib count |