If you've got consistency problems in your organization, we've got the solution for you. Conformance is a powerful new tool within Nx Cloud's Polygraph suite that brings automated consistency and maintainability to your entire organization—regardless of what technology stack you're using.
Say goodbye to spreadsheets for tracking compliance. Get those maintenance items out of your backlog. It's time to solve everything with one tool.
The Problem: Manual Compliance Is Killing Your Productivity
Picture this: Your director of engineering asks, "Why does it take so long to get a PR merged around here?" Sound familiar?
After some investigation, you discover that developers are struggling to get code reviews because not every PR gets assigned to someone. Most of the time, developers are pinging colleagues in Slack, hoping someone can review their code that day. This creates bottlenecks, delays releases, and frustrates your team.
A CODEOWNERS file can solve this problem by automatically assigning reviewers based on directory ownership. But here's the catch: even good solutions need to be used consistently across your organization.
How do you enforce the use of CODEOWNERS files across different teams, different repositories, and different technology stacks? How do you ensure they follow your organization's standards without manually checking each repository?
This is where Conformance comes in.
What Is Conformance?
Conformance is part of Nx Cloud's Polygraph suite: a collection of features that extend the benefits of Nx workspaces to your entire organization. Conformance allows you to write technology-agnostic rules that you can enforce across your organization, no matter what technology you're using.
Think of it as automated governance for your entire codebase. Platform teams can now:
- Eliminate manual compliance tracking - No more spreadsheets or manual audits
- Enforce standards at scale - Write rules once, apply them everywhere
- Schedule future enforcement - Set deadlines for compliance transitions
Real-World Example: Enforcing CODEOWNERS Standards
Let's solve this code review problem. We'll create a Conformance rule that ensures every repository has a properly configured CODEOWNERS file.
First, we need to define our requirements:
- A CODEOWNERS file must exist at the root of the repository
- It should start with a catch-all rule so unassigned directories get reviewers
- Every rule should include at least one team so PRs are assigned to groups of people to ensure coverage
Setting Up Your Conformance Rules
You have two options for storing Conformance rules:
Create a new workspace from the @nx/conformance
preset
- Create a new example workspace with the
@nx/conformance
preset:npx create-nx-workspace WORKSPACE_NAME --preset=@nx/conformance
- Connect your new example workspace to Nx Cloud by following the instructions during
create-nx-workspace
. - Run
npx nx login
in your new example workspace. - Publish your rules using the
publish-conformance-rules
target on theconformance-rules
project:npx nx publish-conformance-rules
Add Conformance rules to an existing workspace
You can check out the full details in our docs, but here's an overview of adding Conformance rules to an existing workspace.
- Open your existing Nx workspace.
- Add the
@nx/conformance
plugin:npx nx add @nx/conformance
. - Set up a new library project for your conformance rules.
- Run
npx nx login
in your workspace. - Be sure to bundle your rules using the
@nx/conformance:bundle-rules
executor (covered in the above docs). - Publish the rules using the
nx-cloud
CLI:npx nx-cloud publish-conformance-rules /path/to/rule-outputs
.
For our example today, we'll create a new workspace named stellar-conformance
:
❯
npx create-nx-workspace@latest stellar-conformance --preset=@nx/conformance
This creates a new Nx workspace specifically for managing your organization's Conformance rules. The preset includes example rules and the structure you need to get started.
Writing Your First Conformance Rule
We'll use the @nx/conformance:conformance-rule
generator to create our CODEOWNERS rule:
❯
npx nx g @nx/conformance:create-rule codeowners-lint
1 NX Generating @nx/conformance:create-rule
2
3✔ Which directory do you want to create the rule directory in? · packages/conformance-rules/src
4✔ What category does this rule belong to? · consistency
5✔ What is the description of the rule? · Enforce existence and style of CODEOWNERS file
6CREATE packages/conformance-rules/src/codeowners-lint/index.ts
7CREATE packages/conformance-rules/src/codeowners-lint/schema.json
8
You'll be asked for the name, description, and directory for your new rule. You'll also be asked for a category. Choose from:
- Consistency - Enforcing uniform standards across workspaces
- Maintainability - Making code easier to maintain and modify
- Reliability - Ensuring dependable and stable code behavior
- Security - Protecting against vulnerabilities and risks
For our CODEOWNERS rule, we'll choose consistency
since it helps make the code review process more consistent.
Implementing the Rule Logic
Here's what our CODEOWNERS Conformance rule looks like:
1import {
2 createConformanceRule,
3 ConformanceViolation,
4 ConformanceRuleResultSeverity,
5} from '@nx/conformance';
6import { workspaceRoot } from '@nx/devkit';
7import { join } from 'path';
8import { readFileSync } from 'fs';
9
10export default createConformanceRule({
11 name: 'codeowners-lint',
12 category: 'consistency',
13 description: 'Check for existence and format of CODEOWNERS file',
14 implementation: async (context) => {
15 // Check if CODEOWNERS file exists
16
17 let codeowners;
18
19 try {
20 // try to read CODEOWNERS file from the root of the repo
21 codeowners = readFileSync(join(workspaceRoot, 'CODEOWNERS'), 'utf-8');
22 } catch (error) {
23 // if not found, return high severity violation
24 return {
25 severity: 'high',
26 details: {
27 violations: [
28 {
29 workspaceViolation: true,
30 message: 'CODEOWNERS file is missing',
31 },
32 ],
33 },
34 };
35 }
36
37 // Check if CODEOWNERS file is empty
38
39 const violations: ConformanceViolation[] = [];
40
41 // iterate through CODEOWNERS file and remove blank or commented lines
42 const codeownersLines = codeowners
43 .split('\n')
44 .filter(
45 (line: string) => line.trim().length > 0 && !line.startsWith('#')
46 );
47
48 if (codeownersLines.length === 0) {
49 // if there are no lines left, return high severity violation
50 return {
51 severity: 'high',
52 details: {
53 violations: [
54 {
55 workspaceViolation: true,
56 message: 'CODEOWNERS file is empty',
57 },
58 ],
59 },
60 };
61 }
62
63 // Check if CODEOWNERS file has valid format
64
65 const severity: ConformanceRuleResultSeverity = 'medium';
66
67 // check that first rule starts with a wildcard
68 if (!codeownersLines.at(0)?.startsWith('*')) {
69 // if it doesn't, add medium severity violation to report
70 violations.push({
71 workspaceViolation: true,
72 message: 'CODEOWNERS file should start with a wildcard (*) pattern',
73 });
74 }
75
76 // check that each rule contains the org name, indicating a team assignment
77 if (
78 codeownersLines.some(
79 (line: string) => !line.includes('@stellar-dynamics')
80 )
81 ) {
82 // if it doesn't, add low severity violation to report
83 violations.push({
84 workspaceViolation: true,
85 message:
86 'CODEOWNERS rules should contain at least one @stellar-dynamics team',
87 });
88 }
89
90 return {
91 severity,
92 details: {
93 violations,
94 },
95 };
96 },
97});
98
Testing Your Rule Locally
Before publishing, test your rule locally by adding it to your nx.json
:
1{
2 "conformance": {
3 "rules": [
4 {
5 "rule": "./packages/conformance-rules/src/codeowners-lint"
6 }
7 ]
8 }
9}
10
Run the rule:
❯
npx nx conformance check
Retrieve a personal access token
Because publishing Conformance rules is a privileged action, you'll need to have a personal access token. Run npx nx login
to retrieve this.
Publishing Rules to Nx Cloud
Once you're satisfied with your rule, publish it to Nx Cloud:
❯
nx publish-conformance-rules conformance-rules
This makes your rule available to your entire organization through Nx Cloud.
Applying Rules Organization-Wide
After publishing, head to your Nx Cloud dashboard and navigate to the Conformance section. You'll see your newly published rule ready to be configured.
Rule Configuration Options
When configuring a rule, you have three status options:
- Enforced - Rule runs and fails builds when violations are found
- Evaluated - Rule runs and reports violations but won't fail builds (perfect for gradual rollout)
- Disabled - Rule is turned off completely
You can start with "evaluated" mode to see current compliance levels, then schedule automatic transition to "enforced" mode with a specific deadline.
Running Rules with Custom Workflows
Here's where Conformance really shines. Instead of requiring every team to add Conformance checks to their CI pipelines, you can use Custom Workflows to run these checks automatically.
Custom Workflows allow you to:
- Run Conformance checks on any repository without requiring local configuration changes
- Schedule recurring checks (daily, weekly, etc.) to maintain compliance
- Apply rules to non-Nx repositories through metadata-only workspaces
- Collect compliance data without impacting individual team workflows
Supporting Non-Nx Repositories
One of the most powerful aspects of Conformance is that it works with any repository, even those that don't use Nx. You can connect legacy repositories as metadata-only workspaces and apply the same Conformance rules.
This means your platform team can enforce standards across your entire organization's codebase, regardless of the underlying technology or build system.
The Platform Engineering Superpower
Conformance transforms how platform teams operate. Instead of manually tracking compliance across dozens or hundreds of repositories, a single platform engineer can:
- Write a rule once in TypeScript (but apply it to any technology)
- Publish it to Nx Cloud with a single command
- Apply it organization-wide through the dashboard
- Get automated compliance reporting without any work from development teams
No more spreadsheets. No more manual audits. No more begging developers to add something to their backlog.
Beyond CODEOWNERS: Endless Possibilities
While we've focused on CODEOWNERS files, Conformance can enforce any organizational standard:
- Security standards - Ensure all repos run security audits and address vulnerabilities
- Dependency management - Keep third-party libraries up to date across your entire tech stack
- Tool standardization - Enforce consistent linting rules, formatting, and build configurations
- Architecture compliance - Ensure new projects follow established patterns and structures
- Documentation requirements - Verify that READMEs, API docs, and other documentation exist
From Reactive to Proactive
Conformance represents a fundamental shift from reactive to proactive organizational management. Instead of discovering problems when they cause production issues, you can:
- Prevent issues before they occur with automated compliance checking
- Maintain consistency across all repositories without manual intervention
- Scale your platform team's impact exponentially across your organization
- Reduce the burden on development teams while improving overall code quality
Getting Started Today
Conformance is available now for all Nx Enterprise customers as part of the Polygraph suite. If you're an existing Enterprise customer, you can start using Conformance immediately in your Nx Cloud dashboard.
The combination of technology-agnostic rules, automated enforcement, and organization-wide visibility makes Conformance a game-changer for platform teams looking to scale their impact.
What's Next?
Conformance is just the beginning. As part of the Polygraph suite, it works alongside:
- Workspace Graph - Visualize dependencies across all your repositories
- Custom Workflows - Run scheduled tasks and automation beyond traditional CI
- Metadata-Only Workspaces - Include non-Nx repositories in your organizational tooling
Together, these features bring the power of monorepo-level visibility and efficiency to your entire organization, regardless of how many repositories you have.
Learn more: