> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Integration

> Set up the Nx MCP server to give AI coding assistants deep workspace context, terminal integration, and autonomous CI workflows.

AI coding assistants often hallucinate outdated Nx commands and lack context about your workspace structure. Without workspace awareness, they suggest commands that don't exist or miss project relationships entirely.

The Nx AI integration gives assistants accurate, real-time information about your workspace, projects, and available commands — making them smarter when working in an Nx monorepo and more autonomous when iterating on CI failures.

## Configure Nx AI integration

### Automatic setup

To automatically configure your Nx monorepo to work best with AI agents and assistants, run:

```bash theme={null}
npx nx configure-ai-agents
```

This command prompts you to select which AI agents and assistants to configure, then sets up:

* The **Nx MCP server** — gives your AI real-time access to workspace structure, project graph, and available tasks
* **Agent configuration files** — `AGENTS.md`, `CLAUDE.md`, and similar files that prime the agent with workspace-specific guidance
* **Agent skills** — for workspace exploration, code generation, and task execution

For Claude Code, skills are installed via a plugin. For other agents (Cursor, Copilot, etc.), they are copied directly into your workspace.

<Note>
  Alternatively, you can install just the skills without the Claude Code plugin:

  ```bash theme={null}
  npx skills add nrwl/nx-ai-agents-config
  ```

  This copies the skills into your workspace but does not install the Claude Code plugin.
</Note>

## What the Nx MCP server provides

The Nx MCP server exposes structured, real-time workspace data to your AI agent. Instead of the agent grepping through files and guessing, it gets:

<CardGroup cols={2}>
  <Card title="Workspace understanding" icon="diagram-project">
    Graph-aware exploration of project dependencies and relationships. The agent gets structured data about every project, target, and how they connect.
  </Card>

  <Card title="Real-time terminal integration" icon="terminal">
    The AI can read your terminal output, running processes, and error messages directly — no copy-pasting required.
  </Card>

  <Card title="Reliable code generation" icon="code">
    The agent invokes Nx generators for predictable scaffolding, then adapts the result to your workspace. Faster, standardized, and fewer hallucinations.
  </Card>

  <Card title="Autonomous CI workflows" icon="repeat">
    The CI monitor skill bridges your local agent with Nx Cloud. Push, monitor, get failures, fix, repeat — until CI is green. You review the final PR, not every intermediate fix.
  </Card>
</CardGroup>

## Files Nx manages for AI agents

After running `nx configure-ai-agents`, Nx creates and manages several files that help AI agents understand your workspace:

<Accordion title="AGENTS.md">
  A markdown file at the root of your workspace that describes the workspace structure, available commands, and conventions. AI agents that support `AGENTS.md` (such as Claude Code) automatically load this file at the start of each session.

  ```
  my-workspace/
  └── AGENTS.md    # Agent-readable workspace context
  ```
</Accordion>

<Accordion title="CLAUDE.md">
  A Claude Code-specific configuration file that provides additional context and primes the agent with Nx-specific knowledge, including which commands to use and which to avoid.
</Accordion>

<Accordion title=".cursor/ directory">
  For Cursor users, Nx writes rule files into `.cursor/rules/` that configure how Cursor's AI understands the workspace. These rules cover available generators, workspace conventions, and Nx-specific patterns.

  ```
  my-workspace/
  └── .cursor/
      └── rules/
          └── nx.mdc
  ```
</Accordion>

## AI-enhanced CI

Nx also integrates AI directly into your CI runs to automatically detect failed tasks, analyze errors, and propose fixes that can be reviewed and applied directly to your pull request.

This is called **Self-Healing CI**: an AI agent on your CI pipeline detects failures, analyzes the root cause, proposes a fix, and verifies it — automatically.

<Card title="Self-Healing CI" icon="wrench" href="/features/self-healing-ci">
  Learn how Nx Cloud's AI agent automatically detects, analyzes, and fixes CI failures before you even see them.
</Card>

## Creating new workspaces with AI

When using AI assistants to create new Nx workspaces, use the CLI command:

```bash theme={null}
npx create-nx-workspace@latest --template=nrwl/<name>-template
```

Available templates include `react-template`, `angular-template`, and `typescript-template`. For adding Nx to an existing project:

```bash theme={null}
npx nx init
```

## Learn more

* [Autonomous AI Agents at Scale](https://nx.dev/blog/ai-agents-and-continuity) — Infrastructure requirements for scaling AI agent workflows
* [Why Nx and AI Work So Well Together](https://nx.dev/blog/nx-and-ai-why-they-work-together)
* [Nx MCP CLI reference](/reference/cli-overview)
