Nx Agent Rules

A build system and workspace toolkit for monorepos and their plugins.

Overview

Nx's AGENTS.md contains contributor workflows and a generated workspace section. It sends documentation work to the Astro site guide, distinguishes issue analysis from implementation, and explains how to test local packages in another repository.

Documents

├── 
├── 
├── .github
│   └── 
├── astro-docs
│   └── 
├── node_modules
│   └── @nx
│       └── <plugin>
│           └── PLUGIN.mdInstalled plugin guidance, when available
├── packages
│   ├── devkit
│   │   └── 
│   └── nx
│       └── src
│           └── native
│               └── 
└── 

Techniques in this file

01 / Behavioral framing

Select a work mode from the request

The issue-response section defaults analytical or ambiguous requests to a plan and reserves immediate implementation for explicit action requests. The file makes this distinction before describing the issue workflow.

Source excerpt starting at line 35.
### Plan-First Mode (Default) Use this approach when users ask you to: - "analyze", "investigate", "assess", "review", "examine", or "plan"- Or when the request is ambiguous

02 / Verification by change type

Expand validation through the dependency graph

The testing sequence begins with the specific project, then affected projects, and finally affected E2E tests. Each stage adds evidence beyond the directly edited package.

Source excerpt starting at line 111.
nx affected -t build,test,lint

03 / Verification by change type

Provide an external-consumer test workflow

A dedicated command builds and copies a local package into another repository. The guide explicitly says this includes native Rust code, so integration testing is not limited to JavaScript-only packages.

Source excerpt starting at line 97.
This builds the package and copies it into the target repo's `node_modules`. It works for all packages including native Rust code.

04 / Router files

Route scaffolding before exploration

Generator discovery goes through a skill before workspace exploration or MCP calls. Advanced documentation questions follow a separate path from basic generator syntax.

Source excerpt starting at line 226.
- For scaffolding tasks (creating apps, libs, project structure, setup), ALWAYS invoke the `nx-generate` skill FIRST before exploring or calling MCP tools

Ideas for your repo

  1. Distinguish investigation requests from implementation requests.
  2. Expand testing from changed components to their dependents.
  3. Provide a repeatable way to test a local package in a consumer repository.
  4. Load task-specific discovery guidance before using generic exploration tools.
Sponsored byModem

Give your agents the whole story.

These instructions explain how to work in Nx. Modem shows your agents what customers said, who is affected, and what changed.

See how Modem works