Skip to content

This tutorial walks you through configuring CI for your Nx workspace. You'll set up a CI pipeline, enable remote caching to speed up runs, and configure self-healing CI to automatically fix failures.

What you'll learn:

  • How to connect your workspace to Nx Cloud
  • How to generate a CI workflow for GitHub Actions
  • How remote caching avoids redundant work across CI runs
  • How self-healing CI detects and fixes failures automatically

Connect your workspace to Nx Cloud to enable remote caching and CI features:

Terminal window
npx nx connect

This creates an Nx Cloud account (if you don't have one) and connects your workspace. Once connected, you can see your workspace in your Nx Cloud organization.

Generate a CI workflow configuration for GitHub Actions:

Terminal window
npx nx g ci-workflow

This creates a .github/workflows/ci.yml file that runs your tasks through Nx and includes the fix-ci command for self-healing:

.github/workflows/ci.yml
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
actions: read
contents: read
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: tree:0
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npx nx run-many -t lint test build
- run: npx nx-cloud fix-ci
if: always()

The npx nx-cloud fix-ci command at the end is responsible for enabling self-healing CI. It analyzes any failing tasks and automatically suggests fixes.

You will need the Nx Console editor extension for VS Code, Cursor, or IntelliJ to receive CI notifications and apply fixes directly from your editor.

Visual Studio Code

Install Nx Console for VSCodeThe official VSCode extension for Nx.

IntelliJ IDEA

For the complete AI setup guide, see our AI integration documentation.

Step 4: Push a PR and see self-healing in action

Section titled “Step 4: Push a PR and see self-healing in action”

Create a branch, make a change (or introduce an intentional test failure), and push it:

Terminal window
git checkout -b my-feature
git add .
git commit -m 'my changes'
git push origin my-feature
# Don't forget to open a pull request on GitHub

When CI runs and encounters a failure, Nx Console notifies you that the run has completed and that it has a suggested fix. You don't have to waste time babysitting your PRs — the fix can be applied directly from your editor.

From the Nx Console notification, click the Show Suggested Fix button. Review the suggested fix and approve it by clicking Apply Fix.

You don't have to leave your editor or do any manual work to fix it. This is the power of self-healing CI with Nx Cloud.

After the fix has been applied and committed, CI will re-run automatically, and you will be notified of the results in your editor.

When you view the results in Nx Cloud, you'll notice something interesting. Tasks for projects that weren't affected by your change were read from remote cache and did not have to run again, each taking less than a second to complete.

This happens because Nx Cloud caches the results of tasks and reuses them across different CI runs. As long as the inputs for each task have not changed (e.g. source code), then their results can be replayed from Nx Cloud's Remote Cache.

This significantly speeds up the time to green for your pull requests, because subsequent changes to them have a good chance to replay tasks from cache.

Also, make sure you