giuseppe-trisciuoglio/developer-kit / plugins/developer-kit-typescript/skills/nx-monorepo
nx-monorepo
VerifiedProvides 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
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.9 KB |
| references/advanced.md | markdown | 7.4 KB |
| references/basics.md | markdown | 3.9 KB |
| references/ci-cd.md | markdown | 7.8 KB |
| references/generators.md | markdown | 5.2 KB |
| references/nestjs.md | markdown | 7.1 KB |
| references/react.md | markdown | 6.3 KB |
| references/typescript.md | markdown | 6.8 KB |
references/basics.md
View on GitHub# Nx Basics Reference
## Workspace Creation
### New Workspace with Presets
```bash
npx create-nx-workspace@latest
```
Interactive prompts guide you through:
- Workspace name
- Package manager (npm, yarn, pnpm, bun)
- Preset selection (React, Angular, Node, TypeScript, etc.)
### Initialize Nx in Existing Project
For projects with existing `package.json`:
```bash
nx@latest init
```
For npm workspace projects, create `package.json` first:
```json
{
"name": "my-workspace",
"version": "1.0.0",
"private": true,
"workspaces": ["packages/*", "apps/*"]
}
```
Then run `nx@latest init`.
## Project Structure
### Standard Layout
```
my-workspace/
├── apps/ # Deployable applications
│ ├── web-app/ # React app
│ └── api/ # NestJS API
├── libs/ # Shared libraries
│ ├── shared-ui/ # UI components
│ └── utils/ # Utilities
├── tools/ # Workspace tools
├── nx.json # Nx workspace config
├── tsconfig.base.json # Base TS config
└── package.json # Root package.json
```
### Configuration Files
**nx.json** - Workspace-level configuration:
```json
{
"namedInputs": {
"default": ["{projectRoot}/**/*"],
"production": [
"default",
"!{projectRoot}/**/*.spec.ts",
"!{projectRoot}/**/*.test.ts"
]
},
"targetDefaults": {
"build": {
"cache": true,
"dependsOn": ["^build"]
}
}
}
```
**project.json** - Project-level configuration (per project):
```json
{
"name": "my-app",
"projectType": "application",
"sourceRoot": "apps/my-app/src",
"targets": {
"build": { "executor": "@nx/react:webpack" },
"serve": { "executor": "@nx/react:dev-server" },
"test": { "executor": "@nx/vite:test" },
"lint": { "executor": "@nx/linter:eslint" }
}
}
```
## Essential Commands
### Running Tasks
```bash
# Run specific target on project
nx run <project>:<target>
# Run target with configuration
nx run <project>:<target> --configuration=production
# Run task for all affected projects
nx affected -t <target>
# Run multiple targets for affected projects
nx affected -t lint test build
# Run task across specific projects
nx run-many -t <target> -p <proj1> <proj2>
# Run task across all projects
nx run-many -t <target>
# Run with parallel control
nx run-many -t build --parallel=3
# Run sequentially
nx run-many -t build --parallel=false
```
### Project Operations
```bash
# List all projects
nx show projects
# Show project graph
nx graph
# Show project details
nx show project <project-name>
# Show dependencies
nx show project <project-name> --web=false --json
```
### Generator Shortcuts
```bash
# g = generate
nx g <collection>:<generator>
# Examples
nx g @nx/react:component my-component
nx g @nx/js:lib shared-utils
```
## Installation
### Install Nx Plugins
```bash
# React plugin
nx add @nx/react
# Angular plugin
nx add @nx/angular
# Node/NestJS plugin
nx add @nx/node
# JavaScript/TypeScript plugin
nx add @nx/js
```
Ensure plugin version matches Nx version.
### Global Installation (Optional)
```bash
# Ubuntu/Debian
sudo add-apt-repository ppa:nrwl/nx
sudo apt update
sudo apt install nx
# Use globally
nx build my-project
nx generate application
nx graph
```
## Common Workflows
### New Feature Development
```bash
# 1. Generate feature library
nx g @nx/js:lib feature-a --directory=libs/features
# 2. Add component/service
nx g @nx/react:component button --project=feature-a
# 3. Run tests
nx run-many -t test --projects=feature-a
# 4. Build affected
nx affected -t build
# 5. Update dependency graph
nx graph
```
### Debugging Task Execution
```bash
# Show what would run without running
nx affected -t build --dry-run
# Show task graph
nx affected -t build --graph
# Verbose output
nx run my-app:build --verbose
# Skip cache
nx run my-app:build --skip-nx-cache
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |