The Nx Cloud command line interface provides various commands to connect and interact with Nx Cloud, manage distributed task execution, and handle authentication. Below is a complete reference for all available commands and their options.
Available commands
Section titled “Available commands”nx login
Section titled “nx login”Provision a local personal access token to access Nx Cloud features. This will open your browser to the Nx Cloud application and after signing in will generate a personal access token and save it in a configuration file locally called nxcloud.ini.
This command is the same as running nx login.
Usage:
npx nx login [nxCloudUrl]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
nxCloudUrl | string | The URL of the Nx Cloud instance to connect to | https://cloud.nx.app |
Configuration file location
Section titled “Configuration file location”We look for this file at the following locations:
$XDG_CONFIG_HOME/nxcloud/nxcloud.ini$HOME/config/nxcloud/nxcloud.ini$HOME/.nxcloud.ini
If we don't find an existing config file, we create one at $HOME/config/nxcloud/nxcloud.ini
We look for this file within the %LOCALAPPDATA%/nxcloud directory and if it does not exist, we will create a new nxcloud.ini file there.
The format of this file is as follows:
[https://cloud\.nx\.app]personalAccessToken=SOME_ACCESS_TOKENIf you have access to multiple instances of the Nx Cloud application (e.g. self-hosted Enterprise and our managed instance), each instance will be saved to this file under its URL.
nx logout
Section titled “nx logout”Revoke a personal access token from your local environment. This will remove the personal access token from the locally initialized configuration file and also invalidate the token from the Nx Cloud application. You will be prompted to remove a single token or all tokens from your local environment.
Usage:
npx nx logoutnx-cloud configure
Section titled “nx-cloud configure”To provision more than one personal access token for multiple contexts (e.g. home and work machines) you can use the personal access tokens page under your Nx Cloud profile. To save a personal access token to your local nxcloud.ini file without needing to edit the file yourself call nx-cloud configure.
Usage:
npx nx-cloud configureOptions
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--personalAccessToken | string | The personal access token to configure | |
--nx-cloud-url | string | The URL of the Nx Cloud instance | https://cloud.nx.app |
Examples
Section titled “Examples”npx nx-cloud configure --personalAccessToken=SOME_ACCESS_TOKENTo configure multiple tokens for different instances of the Nx Cloud app:
npx nx-cloud configure --personalAccessToken=SOME_ACCESS_TOKEN --nx-cloud-url=https://nx-cloud.my-domain.appnx-cloud convert-to-nx-cloud-id
Section titled “nx-cloud convert-to-nx-cloud-id”When logging into Nx Cloud with a Personal Access Token, your nx.json file needs to include the nxCloudId property, which acts as a unique identifier for your workspace. If you have been using the previous nxCloudAccessToken to connect, simply run npx nx-cloud convert-to-nx-cloud-id to automatically update your configuration to use nxCloudId.
If you are connecting to Nx Cloud with a workspace that is version 19.6 or lower, this command will also install the latest version of the Nx Cloud npm package and add it into your package.json. Only Nx versions 19.7 and higher natively support the nxCloudId property in the nx.json file; for versions 19.6 and lower, the Nx Cloud npm package will be needed to use that property.
Usage:
npx nx-cloud convert-to-nx-cloud-idnx-cloud onboard
Section titled “nx-cloud onboard”Connect a workspace to Nx Cloud. This command supports an interactive onboarding wizard for humans and JSON-based subcommands for automation and AI agents.
Authentication is required before using this command. Either run nx login first or configure a personal access token with nx-cloud configure.
Usage:
npx nx-cloud onboard [subcommand] [options]- Without flags, this starts the interactive onboarding wizard.
- With
--no-interactive, it runs an automation-friendly flow. - With
--no-interactiveand explicit workspace creation flags such as--repo,--template, or--detect-repo, it routes toworkspace create. - With
--no-interactiveand no explicit creation flags, it routes toconnect-workspaceand defaults to JSON output.
Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
--token | string | Use a specific Nx Cloud access token for this invocation | |
--no-interactive | boolean | Disable interactive prompts | false |
--workspace-name | string | Alias for --name | |
--name | string | Workspace or organization name, depending on the selected flow | |
--org | string | Organization ID to use | |
--detect-repo | boolean | Auto-detect the current Git repository | false |
--write-config | boolean | Write the returned nxCloudId to nx.json after workspace creation | false |
Examples
Section titled “Examples”npx nx-cloud onboardnpx nx-cloud onboard --no-interactive --jsonnpx nx-cloud onboard --no-interactive --org=org_123 --detect-repo --write-configSubcommands
Section titled “Subcommands”nx-cloud onboard status
Section titled “nx-cloud onboard status”Show onboarding status for the authenticated user, including organizations and GitHub connection state.
Usage:
npx nx-cloud onboard status| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard connect-workspace
Section titled “nx-cloud onboard connect-workspace”One-shot command intended for agents and automated flows. It:
- Detects the current repository from git remotes.
- Selects or creates an organization.
- Checks GitHub connection status.
- Creates an Nx Cloud workspace from the repository.
- Writes
nxCloudIdtonx.jsonwhen possible.
If GitHub authentication is required, JSON mode returns an actionRequired payload instead of failing the command.
Usage:
npx nx-cloud onboard connect-workspace| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
--org | string | Organization ID to use | |
--name | string | Workspace name override |
npx nx-cloud onboard connect-workspace --jsonnpx nx-cloud onboard connect-workspace --org=org_123 --name=my-workspacenx-cloud onboard connect github
Section titled “nx-cloud onboard connect github”Start GitHub device-flow authentication.
- In interactive mode, this prints instructions, attempts to open the browser, and polls until authorization completes.
- In JSON mode, this returns the device-flow payload and leaves polling to the caller.
Usage:
npx nx-cloud onboard connect github| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard connect github poll
Section titled “nx-cloud onboard connect github poll”Poll for completion of a GitHub device-flow authentication started with connect github.
Usage:
npx nx-cloud onboard connect github poll --device-code <code>| Option | Type | Description | Default |
|---|---|---|---|
--device-code | string | Device code returned by connect | |
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard orgs list
Section titled “nx-cloud onboard orgs list”List organizations available to the authenticated user.
Usage:
npx nx-cloud onboard orgs list| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard orgs create
Section titled “nx-cloud onboard orgs create”Create a new organization.
Usage:
npx nx-cloud onboard orgs create <name>| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard repos list
Section titled “nx-cloud onboard repos list”List repositories available to an organization.
Usage:
npx nx-cloud onboard repos list --org <org-id>| Option | Type | Description | Default |
|---|---|---|---|
--org | string | Organization ID | |
--search | string | Filter repositories by search term | |
--page | number | Page number to fetch | |
--per-page | number | Number of repositories per page | |
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard templates list
Section titled “nx-cloud onboard templates list”List available Nx Cloud workspace templates.
Usage:
npx nx-cloud onboard templates list| Option | Type | Description | Default |
|---|---|---|---|
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard vcs status
Section titled “nx-cloud onboard vcs status”Show GitHub App connection status for an organization.
Usage:
npx nx-cloud onboard vcs status --org <org-id>| Option | Type | Description | Default |
|---|---|---|---|
--org | string | Organization ID | |
--json | boolean | Output JSON for scripting | false |
nx-cloud onboard workspace create
Section titled “nx-cloud onboard workspace create”Create a workspace either from an existing repository or from a template.
Use exactly one of:
--repowith--repo-full-name--template--detect-repo
When --write-config is provided, the command attempts to add the returned nxCloudId to nx.json.
Usage:
npx nx-cloud onboard workspace create --org <org-id> [options]| Option | Type | Description | Default |
|---|---|---|---|
--org | string | Organization ID | |
--name | string | Workspace name | |
--workspace-name | string | Alias for --name | |
--repo | string | Repository ID for an existing repository | |
--repo-full-name | string | Repository full name in owner/repo format | |
--default-branch | string | Default branch for an existing repository | main |
--template | string | Template ID for template-based workspace creation | |
--github-organization | string | GitHub organization for template-based workspace creation | |
--repo-name | string | Repository name override for template-based workspace creation | |
--private | boolean | Mark the created workspace repository as private | true |
--installation-id | string | GitHub App installation ID override for existing repositories | |
--detect-repo | boolean | Auto-detect the current repository and populate repository arguments | false |
--write-config | boolean | Write the returned nxCloudId to nx.json | false |
--json | boolean | Output JSON for scripting | false |
npx nx-cloud onboard workspace create --org=org_123 --repo=repo_456 --repo-full-name=acme/web --name=webnpx nx-cloud onboard workspace create --org=org_123 --detect-repo --write-confignpx nx-cloud onboard workspace create --org=org_123 --template=tmpl_react --name=demoAutomation notes
Section titled “Automation notes”--jsonis supported across all onboarding subcommands intended for scripting.connect-workspaceis the best entry point for AI agents because it can detect the repository, create an organization when needed, and return actionable JSON when GitHub authorization is required.connect github --jsonstarts device flow, andconnect github poll --device-code ... --jsoncan be used to poll for completion.
nx-cloud start-ci-run
Section titled “nx-cloud start-ci-run”At the beginning of your main job, invoke npx nx start-ci-run. This tells Nx Cloud that the following series of command correspond to the same CI run.
Usage:
npx nx start-ci-runOptions
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--distribute-on | string | Configure the number of agents, launch templates and assignment rules for distributed execution | |
--assignment-rules | string | Path to the assignment rules configuration for manual distribution. | |
--require-explicit-completion | boolean | Disable automatic completion monitoring and require explicit nx complete-ci-run | false |
--stop-agents-after | string | Comma-separated list of targets after which agents should terminate | |
--stop-agents-on-failure | boolean | Terminate all agents when a command fails. This flag does not interrupt the command itself. To cancel the command on failure use nxBail | true |
--use-dte-by-default | boolean | Configure Nx to distribute all commands by default | true |
--with-env-vars | string | Comma-separated list of environment variables to pass to Nx Agents | |
--fix-tasks | string | Comma-separated glob patterns for tasks to enable AI self-healing. Supports negation with ! prefix | |
--auto-apply-fixes | string | Comma-separated glob patterns for self-healing tasks to auto-apply to PRs without manual review | |
--force | boolean | Bypass CI environment check. Run nx-cloud cleanup if accidentally ran locally. |
Detailed option usage
Section titled “Detailed option usage”--distribute-on
Section titled “--distribute-on”By default, npx nx start-ci-run is intended for use with Nx Agents and expects --distribute-on to be configured. It will output a warning if this flag is not set. If you are running a distributed execution with a legacy setup without Nx Agents, you can pass --distribute-on=manual to disable this warning.
This command tells Nx Cloud how many agents to use (and what launch templates to use) to distribute tasks. E.g., npx nx start-ci-run --distribute-on="8 linux-medium-js" will distribute CI using 8 agents that are initialized using the linux-medium-js launch template.
You can also define the configuration in a file and reference it as follows: npx nx start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml".
distribute-on: small-changeset: 3 linux-medium-js medium-changeset: 6 linux-medium-js large-changeset: 10 linux-medium-js--stop-agents-after
Section titled “--stop-agents-after”You can tell Nx Cloud to terminate agents after it sees a certain target or group of targets: npx nx start-ci-run --stop-agents-after=build,test,e2e.
Whether you are running commands serially or in parallel (through use of the & operand or discrete jobs), you should include one or more targets from each command.
Incorrect example:
Section titled “Incorrect example:”- run: npx nx start-ci-run --stop-agents-after=build- run: nx affected -t build- run: nx affected -t lint- run: nx affected -t testNx Cloud will only look for the presence of a build target before determining your pipeline can be shut down. Since both lint and test will only run after build is complete, your pipeline would end before all intended work is executed.
Corrected example:
Section titled “Corrected example:”- run: npx nx start-ci-run --stop-agents-after=lint,test,build- run: nx affected -t lint- run: nx affected -t test- run: nx affected -t buildIncorrect example:
Section titled “Incorrect example:”- run: npx nx start-ci-run --stop-agents-after=test- run: nx affected -t build & nx affected -t lint & nx affected -t testAt first glance, this example may appear correct. However, since all the commands are executed in parallel, it could be possible that your test command results in full cache hits and finishes faster than the build and lint commands. In this case, Nx Cloud will stop your pipeline, leaving work incomplete for both the build and lint commands.
Corrected example:
Section titled “Corrected example:”- run: npx nx start-ci-run --stop-agents-after=lint,test,build- run: nx affected -t build & nx affected -t lint & nx affected -t testAdvanced shutdown targeting
Section titled “Advanced shutdown targeting”In advanced pipeline setups, it is possible that you want to run multiple commands with the same target, but with distinct configurations. An example of this may be doing static translations for different locales during your builds.
- run: npx nx start-ci-run --stop-agents-after=build- run: nx affected -t build --configuration=locale-en- run: nx affected -t build --configuration=locale-esIn this case, the build target will be executed twice, once with the locale-en configuration and once with the locale-es configuration. However, Nx Cloud is only looking for the build target to assess whether the CI Pipeline Execution can be marked complete.
To address this, you can pass an optional configuration to make your targets more specific.
- run: npx nx start-ci-run --stop-agents-after=build:locale-en,build:locale-es- run: nx affected -t build --configuration=locale-en- run: nx affected -t build --configuration=locale-es--with-env-vars (Nx Agents only)
Section titled “--with-env-vars (Nx Agents only)”By default, invoking npx nx start-ci-run will take all environment variables prefixed with NX_ and send them over to Nx Agents. This means that your access token, verbose logging configuration and other Nx-related environment variables will be the same on your main CI jobs and the Nx Agent machines.
If you want to pass other environment variables from the main job to Nx Agents, you can do it as follows: --with-env-vars="VAR1,VAR2". This will set VAR1 and VAR2 on Nx Agents to the same values set on the main job before any steps run.
Note: none of the values passed to Nx Agents are stored by Nx Cloud.
--fix-tasks
Section titled “--fix-tasks”Enable AI-powered self-healing for specific tasks. When a task fails, Nx Cloud will attempt to analyze the error and generate a fix. By default, all tasks are enabled for self-healing. You can use glob patterns to limit which tasks are eligible.
Examples:
# Enable for lint and format tasks onlynpx nx start-ci-run --fix-tasks="*lint*,*format*" --no-distribution
# Enable for all tasks except deploy and testnpx nx start-ci-run --fix-tasks="!*deploy*,!*test*" --no-distributionThe patterns support:
*wildcard to match any characters!prefix to exclude tasks (negation)- Multiple comma-separated patterns
--auto-apply-fixes
Section titled “--auto-apply-fixes”Automatically apply AI-generated fixes to pull requests for specific tasks without requiring manual review. Fixes are only applied if the verification phase passes.
Examples:
# Auto-apply fixes for linting tasks onlynpx nx start-ci-run --auto-apply-fixes="*lint*" --no-distribution
# Auto-apply fixes for both lint and format tasksnpx nx start-ci-run --auto-apply-fixes="*lint*,*format*" --no-distributionEnabling/Disabling distribution
Section titled “Enabling/Disabling distribution”Invoking npx nx start-ci-run will tell Nx to distribute by default. You can enable/disable distribution for individual commands as follows:
Explicitly enable distribution:
nx affected -t build --agentsExplicitly disable distribution:
nx affected -t build --no-agentsExplicitly enable distribution:
nx affected -t build --dteExplicitly disable distribution:
nx affected -t build --no-dtenx start-agent
Section titled “nx start-agent”Starts an agent process for manual distributed task execution. The agent waits for Nx Cloud to assign tasks that have been distributed by the main CI job via start-ci-run. For automatic agent management, use Nx Agents instead.
Usage:
npx nx start-agentOptions
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--verbose | boolean | Enable verbose logging for debugging | false |
Environment variables
Section titled “Environment variables”Use the NX_AGENT_NAME environment variable to assign a name to the agent for identification in logs and the Nx Cloud UI:
NX_AGENT_NAME=agent-1 npx nx start-agentFor complete examples across different CI providers, see the Manual Distributed Task Execution guide.
nx stop-all-agents
Section titled “nx stop-all-agents”Same as npx nx complete-ci-run.
This command tells Nx Cloud to terminate all agents associated with this CI pipeline execution. Invoking this command is not needed anymore. New versions of Nx Cloud can track when the main job terminates and terminate associated agents automatically.
Usage:
npx nx stop-all-agentsnx complete-ci-run
Section titled “nx complete-ci-run”Explicitly complete a CI run when using --require-explicit-completion with start-ci-run.
Usage:
npx nx complete-ci-runnx-cloud cleanup
Section titled “nx-cloud cleanup”Remove temporary marker files created by start-ci-run if accidentally run locally.
Usage:
npx nx-cloud cleanupGetting help
Section titled “Getting help”You can get help for any command by adding the --help flag:
npx nx-cloud <command> --help