# Install the CLI

> Install the Rehearsal CLI from npm and check that it works.

Source: https://rehearsal.dev/docs/cli/install

The Rehearsal CLI runs your saved tests, reads their results and connects an app on your computer to Rehearsal. You create tests in the app, with Re:agent.

The CLI needs Node.js 24 or newer. Check your version with `node --version`.

## Install

```sh
npm install -g @rehearsal-labs/cli
```

This installs two commands, `rehearsal` and `rhl`. They are the same program, and `rhl` is shorter to type. Help, examples and JSON output always say `rehearsal`.

### Other package managers

| Package manager | Command |
| --- | --- |
| pnpm | `pnpm add -g @rehearsal-labs/cli` |
| Yarn 1 | `yarn global add @rehearsal-labs/cli` |
| Bun | `bun add -g @rehearsal-labs/cli` |

The CLI runs on Node.js whichever one installs it, so it still needs Node.js 24 or newer.

## Check that it works

```sh
rehearsal --version
```

This prints the version you installed. To see every command, run `rehearsal help`. Help works offline and without signing in.

```sh
rehearsal help
rehearsal help runs
rehearsal help agent-workflow
```

`rehearsal help agent-workflow` is a page written for coding agents. It tells an agent how to find your tests, run them and read the results.

## Log in

```sh
rehearsal login
```

Your browser opens. Approve the request there, and the CLI is signed in. On a machine without a browser, run `rehearsal login --no-browser`. It prints a link that you open somewhere else.

## Update

Run the install command again. npm replaces the version you have with the newest one.

```sh
npm install -g @rehearsal-labs/cli
rehearsal --version
```

## Remove

Log out first. That ends the sign-in and deletes the file that holds it. Then remove the package.

```sh
rehearsal logout
npm uninstall -g @rehearsal-labs/cli
```

> [!NOTE]
> The CLI keeps your sign-in in `~/.config/rehearsal/credentials.json`, or under `$XDG_CONFIG_HOME` when that is set. Only your user account can read the file.

## Next steps

- [Log in](https://rehearsal.dev/docs/cli/log-in.md) with only the access a task needs.
- [Connect a local app](https://rehearsal.dev/docs/cli/connect-a-local-app.md) so Rehearsal can test it.
- [Run tests from the terminal](https://rehearsal.dev/docs/cli/run-tests.md) and read their results.
