---
title: 'Run Language-Agnostic Conformance Rules'
description: 'Learn how to use Nx Enterprise conformance rules to enforce organizational standards, maintain consistency, and ensure security across your workspace.'
sidebar:
  order: 8

filter: 'type:Guides'
---

{% youtube src="https://youtu.be/6wg23sLveTQ" title="Nx Conformance" /%}

The [`@nx/conformance`](/docs/reference/conformance/overview) plugin allows [Nx Enterprise plan](https://nx.dev/enterprise) users to write and apply rules for your entire workspace that help with **consistency**, **maintainability**, **reliability** and **security**.

## Why conformance?

Large organizations struggle with maintaining consistency across teams and projects. Manual audits don't scale and developers can't remember every standard. Conformance provides **automated governance** that catches issues before they reach production and enforces policies without manual intervention.

## What does conformance do?

The `@nx/conformance` plugin lets you write custom rules in TypeScript that enforce your organization's standards across **any language or technology** in your codebase. Rules can complement existing linting tools by verifying proper configuration, or enforce entirely new policies around security, architecture, or documentation requirements.

The plugin also provides the following pre-written rules:

- **Enforce Project Boundaries**: Similar to the Nx [ESLint Enforce Module Boundaries rule](/docs/kb/enforce-module-boundaries), but enforces the boundaries on every project dependency, not just those created from TypeScript imports or `package.json` dependencies.
- **Ensure Owners**: Require every project to have an owner defined for the [`@nx/owners` plugin](/docs/reference/owners)

## Setup

The `@nx/conformance` plugin requires an [Nx Enterprise plan](https://nx.dev/enterprise) to function. [Activating your license](/docs/enterprise/activate-license) is a simple process.

{% call_to_action title="Get a License and Activate Nx Enterprise" icon="nx" description="Unlock all the features of the Nx CLI" url="/docs/enterprise/activate-license" /%}

Then, add the Conformance plugin to your workspace.

{% linkcard title="Conformance Overview"  href="/docs/reference/conformance/overview" /%}

## Configure conformance rules

Conformance rules are configured in the `conformance` property of the `nx.json` file. You can use the pre-defined rules or reference [your own custom rule](/docs/reference/conformance/create-conformance-rule). See the [plugin documentation](/docs/reference/conformance) for more details.

```jsonc
// nx.json
{
  "conformance": {
    "rules": [
      {
        "rule": "@nx/conformance/enforce-project-boundaries",
        "options": {
          "depConstraints": [
            {
              "sourceTag": "scope:shared",
              "onlyDependOnProjectsWithTags": ["scope:shared"],
            },
          ],
        },
      },
      {
        "rule": "@nx/conformance/ensure-owners",
        "projects": ["!experimental-app"],
      },
      {
        "rule": "./tools/local-conformance-rule.ts",
      },
    ],
  },
}
```

## Enforce rules with the `nx conformance` and `nx conformance:check` commands

The `@nx/conformance` plugin enables two commands:

- **`nx conformance`**: Evaluates rules and applies any available fix generators. Changes are written to disk and rules are evaluated once more to calculate how many violations were fixed. Use this locally while working on feature branches.
- **`nx conformance:check`**: Evaluates rules only. Fix generators are not applied (useful for CI).

Fix generators are only applied for rules whose final status is not `disabled`.

{% tabs %}
{% tabitem label="Nx CLI" %}

```yaml
- name: Enforce all conformance rules
  run: npx nx conformance:check
```

{% /tabitem %}
{% tabitem label="Nx Cloud" %}

```yaml
- name: Enforce all conformance rules
  run: npx nx record -- npx nx conformance:check
```

Use `npx nx record --` to capture the logs for `nx conformance:check` in the Nx Cloud dashboard.

{% /tabitem %}
{% tabitem label="Nx Cloud w/ Enterprise Plan" %}

```yaml
- name: Enforce all conformance rules
  run: npx nx record -- npx nx-cloud conformance:check
```

Here we are using the `nx-cloud` CLI to run the `conformance:check` command so that we can hook into the power of Conformance rules configured in your Nx Cloud Enterprise organization. Learn more about [conformance rules in Nx Cloud](/docs/enterprise/configure-conformance-rules-in-nx-cloud).

{% /tabitem %}
{% /tabs %}

If a valid license is not available to the workspace (either locally or via Nx Cloud), the `conformance` and `conformance:check` commands will fail without checking any rules.

Pass `--printConfig` to either command to print the resolved conformance configuration for the workspace.

## Taking things further with Nx Cloud Enterprise

Organizations on the Nx Cloud Enterprise plan can [publish custom conformance rules](/docs/enterprise/publish-conformance-rules-to-nx-cloud) to their Nx Cloud organization without the friction of a custom registry, and then [configure the rules](/docs/enterprise/configure-conformance-rules-in-nx-cloud) to apply to the workspaces in their organization automatically when `nx-cloud conformance` or `nx-cloud conformance:check` is run (note that the `nx-cloud` CLI is used in this case in order to handle the authentication with Nx Cloud).

The license will be applied automatically via Nx Cloud in all contexts, and so there is zero setup required for the end developer.

Simply add an appropriate invocation of the `nx-cloud conformance:check` command to your CI process and all cloud configured rules will be applied and merged with any local rules:

```yaml
- name: Enforce all conformance rules
  run: npx nx record -- npx nx-cloud conformance:check
```

Learn more about [publishing](/docs/enterprise/publish-conformance-rules-to-nx-cloud) and [configuring conformance rules in Nx Cloud](/docs/enterprise/configure-conformance-rules-in-nx-cloud).

## Learn more

- [Conformance Plugin API Reference](/docs/reference/conformance/overview) - Detailed documentation on configuration options and provided rules
- [Create a Custom Conformance Rule](/docs/reference/conformance/create-conformance-rule) - Step-by-step guide to writing your own rules
- [Testing Conformance Rules](/docs/reference/conformance/test-conformance-rule) - Learn how to test your conformance rules
- [Publish Conformance Rules to Nx Cloud](/docs/enterprise/publish-conformance-rules-to-nx-cloud) - Share rules across your organization
- [Configure Conformance Rules in Nx Cloud](/docs/enterprise/configure-conformance-rules-in-nx-cloud) - Manage rules via the Nx Cloud dashboard
- [Blog: Automating Consistency with Nx Cloud Conformance](https://nx.dev/blog/nx-cloud-conformance-automate-consistency) - Learn about the philosophy and benefits of conformance
