or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mddevkit-core.mddevkit-files.mddevkit-tasks.mdgenerators-executors.mdindex.mdplugins.md

cli.mddocs/

0

# Command Line Interface

1

2

Nx provides a comprehensive CLI toolkit with 41 commands for monorepo management, project generation, task execution, workspace maintenance, and cloud integration.

3

4

## Capabilities

5

6

### Workspace Management

7

8

Commands for creating, initializing, and maintaining Nx workspaces.

9

10

```bash { .api }

11

# Create new workspace

12

nx new <workspace-name> [options]

13

14

# Initialize Nx in existing workspace

15

nx init [options]

16

17

# Connect workspace to Nx Cloud

18

nx connect-to-nx-cloud

19

20

# Repair workspace configuration

21

nx repair

22

23

# Reset workspace cache and state

24

nx reset

25

```

26

27

### Project Operations

28

29

Commands for managing projects within the workspace.

30

31

```bash { .api }

32

# Add packages and capabilities to workspace

33

nx add <package> [options]

34

35

# Generate code using generators

36

nx generate <schematic> [options]

37

nx g <schematic> [options]

38

39

# Import external projects into workspace

40

nx import <github-url> [options]

41

42

# List installed plugins and generators

43

nx list [plugin]

44

45

# Show project information and configuration

46

nx show project <project-name> [options]

47

```

48

49

### Task Execution

50

51

Commands for running tasks and managing task execution.

52

53

```bash { .api }

54

# Run target on specific project

55

nx run <project:target[:configuration]> [options]

56

nx <target> <project> [options]

57

58

# Run targets on multiple projects

59

nx run-many --target=<target> [options]

60

61

# Run tasks on affected projects only

62

nx affected --target=<target> [options]

63

64

# Execute command in workspace context

65

nx exec -- <command>

66

67

# Watch files and run commands on changes

68

nx watch --all -- <command>

69

```

70

71

### Analysis and Reporting

72

73

Commands for analyzing workspace structure and generating reports.

74

75

```bash { .api }

76

# View interactive project dependency graph

77

nx graph [options]

78

79

# Generate workspace report

80

nx report

81

82

# Sync workspace dependencies

83

nx sync

84

85

# Check if workspace needs syncing

86

nx sync:check

87

88

# Format files in workspace

89

nx format [options]

90

91

# Check formatting without modifying files

92

nx format:check

93

94

# Write formatting changes to files

95

nx format:write

96

97

# View execution logs

98

nx view-logs

99

```

100

101

### Migration and Maintenance

102

103

Commands for upgrading workspace and migrating code.

104

105

```bash { .api }

106

# Migrate workspace to newer versions

107

nx migrate <package> [options]

108

109

# Register plugin with Nx

110

nx register <plugin>

111

```

112

113

### Release Management

114

115

Commands for versioning and publishing packages.

116

117

```bash { .api }

118

# Release and versioning commands

119

nx release [options]

120

```

121

122

### Daemon Operations

123

124

Commands for managing the Nx daemon process.

125

126

```bash { .api }

127

# Nx daemon operations (start/stop/status)

128

nx daemon [options]

129

```

130

131

### CI and Analysis

132

133

Commands for continuous integration and task analysis.

134

135

```bash { .api }

136

# Fix CI configuration issues

137

nx fix-ci

138

139

# Record task execution for analysis

140

nx record

141

142

# Start CI run processes

143

nx start-ci-run

144

```

145

146

### Cloud Integration

147

148

Commands for Nx Cloud authentication and integration.

149

150

```bash { .api }

151

# Login to Nx Cloud

152

nx login

153

154

# Logout from Nx Cloud

155

nx logout

156

157

# Connect workspace to Nx Cloud (deprecated, use nx connect)

158

nx connect-to-nx-cloud

159

```

160

161

### Development Tools

162

163

Commands for development workflow and compliance.

164

165

```bash { .api }

166

# Model Context Protocol server operations

167

nx mcp [options]

168

169

# Check workspace conformance rules

170

nx conformance [options]

171

172

# Run conformance checks

173

nx conformance:check

174

```

175

176

### Legacy Commands

177

178

Deprecated commands maintained for backward compatibility.

179

180

```bash { .api }

181

# Print affected projects (deprecated, use nx affected)

182

nx print-affected [options]

183

184

# Show affected dependency graph (deprecated, use nx graph)

185

nx affected:graph [options]

186

187

# Build affected projects (deprecated, use nx affected --target=build)

188

nx affected:build [options]

189

190

# Test affected projects (deprecated, use nx affected --target=test)

191

nx affected:test [options]

192

193

# Lint affected projects (deprecated, use nx affected --target=lint)

194

nx affected:lint [options]

195

196

# E2E test affected projects (deprecated, use nx affected --target=e2e)

197

nx affected:e2e [options]

198

```

199

200

## Command Details

201

202

### Core Workspace Commands

203

204

#### new

205

206

Creates a new Nx workspace from scratch.

207

208

```bash { .api }

209

nx new <workspace-name> [options]

210

211

Options:

212

--preset The preset to use for generating the workspace

213

--packageManager Package manager to use (npm, yarn, pnpm)

214

--nxCloud Enable Nx Cloud integration

215

--interactive Enable interactive mode for prompts

216

```

217

218

#### init

219

220

Initializes Nx in an existing workspace with workspace-specific configuration.

221

222

```bash { .api }

223

nx init [options]

224

225

Options:

226

--nxCloud Enable Nx Cloud integration

227

--interactive Enable interactive mode for prompts

228

--cacheable Specify which targets should be cacheable

229

```

230

231

#### generate

232

233

Generates code using available generators/schematics.

234

235

```bash { .api }

236

nx generate <schematic> [options]

237

nx generate <plugin>:<schematic> [options]

238

239

Examples:

240

nx generate @nx/react:app my-app

241

nx generate @nx/react:component my-component --project=my-app

242

nx generate workspace-generator my-generator

243

244

Options:

245

--dry-run Preview changes without writing files

246

--interactive Enable interactive mode for prompts

247

```

248

249

### Task Execution Commands

250

251

#### run

252

253

Runs a target on a specific project.

254

255

```bash { .api }

256

nx run <project:target[:configuration]> [options]

257

nx <target> <project> [options]

258

259

Examples:

260

nx run my-app:build

261

nx run my-app:build:production

262

nx build my-app

263

nx test my-lib

264

265

Options:

266

--configuration Configuration to use

267

--skip-nx-cache Skip Nx cache

268

--verbose Print additional error stack trace

269

```

270

271

#### run-many

272

273

Runs a target on multiple projects.

274

275

```bash { .api }

276

nx run-many --target=<target> [options]

277

278

Options:

279

--target Target to run

280

--projects Projects to run target on

281

--all Run target on all projects

282

--parallel Max number of parallel processes

283

--exclude Exclude specific projects

284

--skip-nx-cache Skip Nx cache

285

--configuration Configuration to use

286

```

287

288

#### affected

289

290

Runs tasks only on projects affected by code changes.

291

292

```bash { .api }

293

nx affected --target=<target> [options]

294

295

Options:

296

--target Target to run on affected projects

297

--base Base of the current branch (SHA or branch name)

298

--head Latest commit of the current branch (SHA or branch name)

299

--files Change the way Nx is calculating the affected

300

--parallel Max number of parallel processes

301

--exclude Exclude specific projects

302

--skip-nx-cache Skip Nx cache

303

```

304

305

### Analysis Commands

306

307

#### graph

308

309

Displays an interactive project dependency graph.

310

311

```bash { .api }

312

nx graph [options]

313

314

Options:

315

--file Output file (default: nx-graph.html)

316

--focus Focus on specific project

317

--exclude Exclude projects from graph

318

--groupByFolder Group projects by folder structure

319

--watch Watch for changes and update graph

320

--open Open graph in browser (default: true)

321

```

322

323

#### show

324

325

Shows configuration and information about projects.

326

327

```bash { .api }

328

nx show project <project-name> [options]

329

nx show projects [options]

330

331

Options:

332

--json Output in JSON format

333

--web Show project details in browser

334

```

335

336

#### list

337

338

Lists installed plugins and available generators/executors.

339

340

```bash { .api }

341

nx list [plugin]

342

343

Examples:

344

nx list # List all installed plugins

345

nx list @nx/react # Show generators/executors for @nx/react

346

```

347

348

### Utility Commands

349

350

#### format

351

352

Formats files in the workspace using configured formatters.

353

354

```bash { .api }

355

nx format [options]

356

357

Options:

358

--files Format specific files

359

--all Format all files

360

--uncommitted Format uncommitted files only

361

--untracked Format untracked files only

362

--base Base branch for comparison

363

--head Head branch for comparison

364

```

365

366

#### report

367

368

Generates a report about the workspace configuration and environment.

369

370

```bash { .api }

371

nx report

372

373

# Outputs information about:

374

# - Nx version

375

# - Operating system

376

# - Package manager

377

# - Installed plugins

378

# - Project structure

379

```

380

381

#### sync

382

383

Synchronizes workspace dependencies and configurations.

384

385

```bash { .api }

386

nx sync

387

388

# Analyzes package.json files and updates workspace configuration

389

# to ensure all projects have consistent dependencies

390

```

391

392

#### login

393

394

Authenticates with Nx Cloud for remote caching and distributed execution.

395

396

```bash { .api }

397

nx login

398

399

# Opens browser for authentication with Nx Cloud

400

# Stores authentication token for future operations

401

```

402

403

#### logout

404

405

Removes Nx Cloud authentication.

406

407

```bash { .api }

408

nx logout

409

410

# Removes stored authentication token

411

# Disables remote caching until login again

412

```

413

414

### Advanced Commands

415

416

#### migrate

417

418

Migrates workspace to newer versions and applies code transformations.

419

420

```bash { .api }

421

nx migrate <package> [options]

422

nx migrate --run-migrations

423

424

Options:

425

--from Starting version for migration

426

--to Target version for migration

427

--run-migrations Apply pending migrations

428

--interactive Enable interactive mode

429

```

430

431

#### daemon

432

433

Manages the Nx daemon for improved performance.

434

435

```bash { .api }

436

nx daemon [options]

437

438

Options:

439

--start Start the daemon

440

--stop Stop the daemon

441

--restart Restart the daemon

442

--status Check daemon status

443

```

444

445

## Exit Codes

446

447

All Nx CLI commands return appropriate exit codes:

448

449

- `0`: Success

450

- `1`: General error

451

- `3`: Task execution failure (some tasks failed)

452

453

## Environment Variables

454

455

Key environment variables that affect CLI behavior:

456

457

- `NX_DAEMON`: Enable/disable daemon (`true`/`false`)

458

- `NX_CACHE_DIRECTORY`: Override cache directory location

459

- `NX_DEFAULT_BASE`: Default base branch for affected calculations

460

- `NX_PARALLEL`: Default number of parallel processes

461

- `NX_VERBOSE_LOGGING`: Enable verbose logging

462

- `NX_DRY_RUN`: Enable dry-run mode for all operations