Skip to main content
skill CX Codex

nx — Claude Code skill: Nx monorepo conventions

A skill that tells the agent how to work inside an Nx workspace: apps and libs layout, tags, module boundaries, generators, caching. Useful once your repo runs on Nx.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Mindrally/skills --skill nx -a claude-code
Open on GitHub

What nx does

This skill is a set of conventions the agent follows in an Nx workspace. Projects sit under apps/ and libs/, names follow scope-type-name, and related libraries go into feature folders. Workspace-wide settings live in nx.json, while each project gets a project.json with its own sourceRoot, projectType and tags.

Module boundaries are enforced through the ESLint rule @nx/enforce-module-boundaries and its depConstraints: an app may depend only on libs and utils, and a scope like scope:web reaches its own scope plus scope:shared. Builds and tests are cached, and affected commands run tasks only for changed projects. Generators look like nx g @nx/react:app my-app, with --dry-run previewing changes before anything is written.

The skill installs nothing into your repo and edits no configs on its own — it is guidance for the agent. If your projects carry no tags, the boundary rule has nothing to compare, so cross-domain imports slip through unchecked. It advises starting with nx graph to see current links, then assigning tags.

What it helps with

  • split projects into apps and libs instead of one flat folder
  • stop an app from importing another domain
  • scaffold an app or library with a single generator call
  • run tasks only for affected projects instead of rebuilding everything
  • turn on build and test caching in nx.json

Example prompts for the agent

  • Generate a React library shared-ui-button and tag it scope:shared and type:lib
  • Read project.json and tell me which tags break the module boundary rule
  • Set up targetDefaults in nx.json so build depends on dependency builds and is cached

How to install nx

1Skills CLI (Vercel)

npx skills add Mindrally/skills --skill nx -a claude-code

2Manually: put the files in place

~/.claude/skills/nx/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nx/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about nx

How do I install nx in Claude?

Run npx skills add Mindrally/skills --skill nx -a claude-code. The skill file then lives at ~/.claude/skills/nx/SKILL.md.

What does the nx skill do?

It explains Nx workspace conventions to the agent: apps and libs layout, nx.json and project.json config, generators, module boundaries and affected commands. The agent leans on those rules while writing code and editing config.

Why do tags in project.json matter?

The ESLint rule @nx/enforce-module-boundaries reads them. Without tags in depConstraints there is nothing to compare, so the ban on cross-domain dependencies never fires.

Source text

SKILL.md · Apache-2.0
---
name: nx
description: Best practices for Nx monorepo development, project configuration, and code generation
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Nx Monorepo Development

You are an expert in Nx, the smart, fast, and extensible build system for monorepos.

## Project Structure

- Organize projects following Nx conventions:
  - `apps/` - Application projects (web apps, APIs, mobile apps)
  - `libs/` - Library projects (shared code, features, utilities)
- Use consistent naming patterns: `scope-type-name` (e.g., `shared-ui-button`)
- Group related libraries under feature folders

## Workspace Configuration

Configure `nx.json` for workspace-wide settings:

```json
{
  "targetDefaults": {
    "build": {
      "dependsOn": ["^build"],
      "cache": true
    },
    "test": {
      "cache": true
    }
  },
  "defaultBase": "main"
}
```

- Use `project.json` for project-specific configuration
- Define proper `tags` for enforcing module boundaries

## Project Configuration

Each project should have a `project.json`:

```json
{
  "name": "my-app",
  "sourceRoot": "apps/my-app/src",
  "projectType": "application",
  "tags": ["scope:web", "type:app"],
  "targets": {
    "build": { },
    "serve": { },
    "test": { }
  }
}
```

- Define clear project types: `application` or `library`
- Use tags for enforcing dependency constraints

## Code Generation

- Use Nx generators for consistent code scaffolding:
  - `nx g @nx/react:app my-app` - Generate React application
  - `nx g @nx/react:lib my-lib` - Generate React library
  - `nx g @nx/react:component my-component --project=my-lib` - Generate component
- Create custom generators for project-specific patterns
- Use `--dry-run` to preview changes before execution

## Module Boundaries

Enforce boundaries using ESLint rules:

```json
{
  "@nx/enforce-module-boundaries": [
    "error",
    {
      "depConstraints": [
        { "sourceTag": "type:app", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
        { "sourceTag": "type:lib", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
        { "sourceTag": "scope:web", "onlyDependOnLibsWithTags": ["scope:web", "scope:shared"] }
      ]
    }
  ]
}
```

- Define clear dependency rules between project types
- Use scopes to separate domain boundaries

## Caching and Performance

- Enable computation caching for faster builds
- Configure Nx Cloud for distributed caching and task execution
- Use affected commands to only run tasks for changed projects:
  - `nx affected:build`
  - `nx affected:test`
  - `nx affected:lint`
- Define proper `inputs` and `outputs` for accurate caching

## Task Execution

- Run tasks with Nx CLI:
  - `nx build my-app` - Build specific project
  - `nx run-many -t build` - Build all projects
  - `nx affected -t test` - Test affected projects
- Use task pipelines for proper dependency ordering
- Configure parallel execution for independent tasks

## Testing Strategy

- Use Jest for unit testing with Nx presets
- Configure Cypress or Playwright for E2E testing
- Implement component testing for UI libraries
- Use `nx affected:test` in CI for efficient test runs

## CI/CD Integration

- Use Nx Cloud for distributed task execution
- Configure GitHub Actions with Nx:
  ```yaml
  - uses: nrwl/nx-set-shas@v4
  - run: nx affected -t lint test build
  ```
- Implement proper caching strategies
- Use `nx-cloud record` for capturing metrics

## Best Practices

- Keep applications thin; move logic to libraries
- Create shared utility libraries for common code
- Use barrel exports (`index.ts`) for clean imports
- Implement proper type exports from libraries
- Document library purposes and public APIs
- Use Nx Console VS Code extension for visual project management
- Leverage the project graph for understanding dependencies: `nx graph`

© Mindrally · Apache-2.0 · Mindrally/skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set168

salesforce-dx A skill that makes your coding agent follow Salesforce DX conventions: Apex, triggers, LWC, scratch orgs and SFDX CLI workflows. CX Codex +1 688installs micronaut Tells the agent how to write Micronaut code: compile-time DI, GraalVM native builds, reactive services. Useful when your Java project should follow the framework instead of generic advice. CX Codex +1 687installs julia Turns the agent into a Julia-aware pair programmer: multiple dispatch, type stability, docstrings and tests. Useful for numerical and scientific code. CX Codex +1 687installs clerk-authentication Rules for wiring Clerk into Next.js: middleware, hooks, protected server actions and API routes. Useful once your app already runs on Clerk. CX Codex +1 683installs langchain-development Gives your agent a rulebook for LangChain and LangGraph work in Python: chain composition, agents, memory, RAG. Useful once a Python LLM project outgrows one file. CX Codex +1 681installs apollo-graphql A skill that gives the agent rules for Apollo Client work: queries, mutations, fragments, caching and optimistic updates in React GraphQL apps. CX Codex +1 677installs monorepo-tamagui Gives your agent a rulebook for cross-platform monorepos built on Tamagui, Turbo, Next.js, Expo and Supabase. Useful when web and mobile apps share one repo. CX Codex +1 677installs swiftui-development A rule pack that keeps your coding agent on MVVM, modern state management and Swift 6 concurrency when it writes SwiftUI. CX Codex +1 676installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor