> ## Documentation Index
> Fetch the complete documentation index at: https://traceroot.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up traceroot in a repository, follow the setup prompt in https://traceroot.ai/docs/getting-started/coding-agents.md.

# Get started with the traceroot CLI

> Set up traceroot in your repository and work with your project from the terminal

The traceroot CLI sets up tracing in your repository with one command, then lets you work with your project from the terminal: traces, detector findings, alerts, dashboards, evaluations, and SQL. Pipe the JSON into whatever comes next. It is built for AI coding agents and power users who prefer the command line.

The source is in the [`traceroot-cli`](https://github.com/traceroot-ai/traceroot-cli) repo.

## Set up a repository

Run this from the root of the repository you want to trace:

```bash theme={null}
npx -y traceroot-cli@latest setup
```

Setup signs you in, has your coding agent add the traceroot SDK, and waits for your first trace; no install or sign-in needed first. [Tracing](https://traceroot.ai/docs/tracing/get-started.md) covers each step, self-hosting, and troubleshooting.

### Run without prompts

Setup never prompts when it isn't attached to a terminal, when `CI` is set to anything but empty or `false`, or with `--no-input` or `--json`. Pass what it would otherwise ask for:

```bash theme={null}
npx -y traceroot-cli@latest setup --no-input --api-key "$TRACEROOT_API_KEY"
```

A project API key also sets the project. Without a key, run `npx -y traceroot-cli@latest login` first, then run setup without `--api-key`. Login prints a URL and a code for a person to confirm in a browser, and waits, so a coding agent has to show them to you. If setup exits 10, it can't choose for you, usually because you have several projects or none: follow the remedy it prints. With several projects, you can pass `--project`.

Without prompts, setup notes uncommitted changes instead of asking, and writes the instrumentation task to `.traceroot/prompts/setup-instrument.md` rather than running a coding agent. Pass `--agent claude` or `--agent codex` to run one. After the task is done and the application has run, rerun the same setup command with `--resume`, such as `npx -y traceroot-cli@latest setup --no-input --resume`, to get a link to the first trace. [Exit codes](https://traceroot.ai/docs/cli/scripting.md#exit-codes) lists what each code means, and [Coding agents](https://traceroot.ai/docs/getting-started/coding-agents.md#set-up-tracing) has these steps as a prompt.

### Setup flags

| Flag | Meaning |
| :- | :- |
| `--agent <agent>` | Coding agent to run: `claude` or `codex`. For another agent, use `--no-instrument` |
| `--language <language>` | Language to instrument: `python` or `typescript` |
| `--service <path>` | The service to instrument, in a monorepo |
| `--project <name-or-id>` | Project to send traces to |
| `--no-browser` | Sign in by pasting an API key instead of using a browser |
| `--no-instrument` | Write the instrumentation task instead of running an agent |
| `--manual` | Print instructions instead of running or writing a task |
| `--resume` | Continue from the saved checkpoint |
| `--no-input` | Never prompt. A missing answer exits with the flag to pass |
| `--trace-timeout <seconds>` | How long to wait for the first trace. Default: 120 |

## Install

Every command also runs through `npx`, as above. To keep the `traceroot` command, install the CLI globally:

```bash theme={null}
npm install -g traceroot-cli
```

The examples below use `traceroot`. Without a global install, replace it with `npx -y traceroot-cli@latest`.

The CLI needs Node.js 20.3 or later, and `setup` needs 20.12 or later. `traceroot --version` prints the version you have.

## Authenticate

The CLI authenticates with either a **browser login** (the default interactive device flow) or a **project API key** (for CI environments and scripts).

### Browser login (default)

Run `traceroot login` to sign in through your browser:

```bash theme={null}
traceroot login
```

It prints a URL and a code, tries to open your browser, and saves a session to `~/.config/traceroot/credentials.json`. If no browser opens, open the URL yourself. A key or saved credential [changes what `login` does](https://traceroot.ai/docs/cli/authentication#what-login-does).

### API key login (CI & scripts)

For CI pipelines, automated scripts, or headless environments, use a project API key (`tr-...`):

```bash theme={null}
traceroot login --api-key tr-...
```

This validates the key against the API and saves it to `./.traceroot/config.json`.

Or set `TRACEROOT_API_KEY`, which a saved browser login [outranks](https://traceroot.ai/docs/cli/authentication.md#which-credential-is-used). A project API key [can't create or change resources](https://traceroot.ai/docs/cli/authentication.md#browser-login-and-api-keys).

Create API keys in [traceroot Cloud](https://app.traceroot.ai) or your [self-hosted](https://traceroot.ai/docs/developer/self-hosting.md) dashboard.

### Verify credentials

Confirm your active identity:

```bash theme={null}
traceroot status
```

* **Browser login**: Displays your authenticated email address, host URL, active project (or a hint to select one), and accessible workspaces.
* **API key login**: Displays your workspace, project, host URL, and a masked key hint (e.g. `tr-d0a3-57e3`).

## Scope to a project

A browser login identifies you across your workspaces rather than binding to one project, and commands such as `traces` and `evals` are project-scoped, so pick a project first. An API key is already scoped to its project, so a key login can skip this step.

List the projects you can access to find your project ID:

```bash theme={null}
traceroot projects list
```

Set `TRACEROOT_PROJECT_ID` so later commands need no extra flags, or pass `--project <id>` to individual commands:

```bash theme={null}
export TRACEROOT_PROJECT_ID=<project-id>
```

[Choose a project](https://traceroot.ai/docs/cli/authentication.md#choose-a-project) has the full order.

## Inspect and export traces

Once authenticated and scoped to a project, list, inspect, and export traces:

```bash theme={null}
# Recent traces
traceroot traces list --limit 10

# One trace as JSON, with span I/O
traceroot traces get <trace-id> --fields full --json

# A trace bundle on disk
traceroot traces export <trace-id> --output ./my-trace
```

[Traces](https://traceroot.ai/docs/cli/traces.md) covers time filters, field groups, and the exported files.

## Diagnose and add skills

```bash theme={null}
traceroot doctor
traceroot setup doctor --service ./api
traceroot instrument --agent claude --print
traceroot skills install traceroot-instrument-repo --agent claude --dry-run
```

`doctor` checks credentials, traceroot files, the repository, the environment, and the installed skills. `setup doctor` diagnoses a setup that didn't complete. Both take `--service <path>` in a monorepo, and exit 1 when a check fails.

`instrument` writes a prompt for a coding agent to add traceroot, without editing your code. It takes `--agent` (`claude`, `codex`, or `generic`), `--print` to write the prompt to stdout, `--output <path>`, and `--force` to overwrite an existing prompt. `setup` is the usual route.

`skills list` shows the skills bundled with the CLI and where they're installed. `skills install` copies one into an agent's skill directory, and takes `--agent`, `--force`, and `--dry-run` to show what it would write. [Coding agents](https://traceroot.ai/docs/getting-started/coding-agents.md#skills) lists the skills to use.

## Command reference

Add `--json` to any command for machine-readable output, or run `traceroot <command> --help` for the full flag list.

The `sql` commands are documented in [Read-only SQL](https://traceroot.ai/docs/cli/sql.md).

| Command | Description |
| :- | :- |
| `setup` | Connect this repository to traceroot and see your first trace. See [Tracing](https://traceroot.ai/docs/tracing/get-started.md). |
| `setup doctor` | Diagnose a setup that did not complete. Flag: `--service <path>`. |
| `login` | Sign in with the browser (device flow), or persist an explicit --api-key. |
| `logout` | Revoke the session server-side (best-effort) and remove the local credential. |
| `status` | Show the identity your credentials resolve to (email or key hint, workspace, project, and host). |
| `doctor` | Check local environment, credentials, configuration, repository, and agent skills. |
| `instrument` | Generate an agent prompt to instrument this repo with traceroot. |
| `skills list` | List available AI agent skills and their capabilities. |
| `skills install` | Install skills into your coding agent workspace. |
| `traces list` | List recent traces for the caller's project (newest first). |
| `traces get <id>` | Get a single trace for the caller's project. |
| `traces export <id>` | Export the trace bundle (trace + spans + git\_context + manifest) for the caller's project. |
| `detectors list` | List the detectors in the caller's project (newest first). |
| `detectors get <id>` | Get one detector's full configuration for the key's project. |
| `findings list` | List recent detector findings for the caller's project (newest first). |
| `findings get <finding-id>` | Get a single finding by id for the key's project. |
| `alerts list` | List the alerts in the caller's project (oldest first) with its capacity. |
| `alerts get <id>` | Get one alert with its full rule for the caller's project. |
| `alerts create` | Create a threshold alert in a project the authenticated user can write to. |
| `alerts update <id>` | Edit an alert's rule in a project the authenticated user can write to. |
| `alerts status <id>` | Pause or resume an alert without touching its rule. |
| `alerts delete <id>` | Hard-delete an alert. |
| `dashboards list` | List the dashboards in the caller's project (default first). |
| `dashboards get <id>` | Get one dashboard with its widgets for the caller's project. |
| `dashboards create` | Create a dashboard in a project the authenticated user can write to. |
| `dashboards update <id>` | Edit a dashboard's name or description. |
| `dashboards delete <id>` | Hard-delete a dashboard together with its widgets. |
| `workspaces list` | List the workspaces the authenticated user belongs to. |
| `projects list` | List the projects the authenticated user can access, across workspaces. |
| `workspaces create` | Create a workspace administered by the authenticated user. |
| `workspaces update <workspace-id>` | Rename a workspace the authenticated user administers. |
| `workspaces delete <workspace-id>` | Hard-delete a workspace and everything in it. |
| `projects create` | Create a project in a workspace the authenticated user can write to. |
| `projects update <project-id>` | Edit a project's name or trace retention. |
| `projects delete <project-id>` | Soft-delete a project. |
| `detectors create` | Create a detector in a project the authenticated user can write to. |
| `detectors update <id>` | Edit a detector in a project the authenticated user can write to. |
| `detectors delete <id>` | Hard-delete a detector; its existing findings stay readable. |
| `widgets get <id>` | Get one saved widget's definition, with its dashboard, for the caller's project. |
| `widgets data <id>` | Answer one saved widget for a window, with a status instead of an exception. |
| `widgets create` | Create a widget on a dashboard the authenticated user can write to. |
| `widgets update <id>` | Edit a widget's title, spec, or display config. |
| `widgets delete <id>` | Hard-delete a widget and its entry in the dashboard's layout. |
| `sql` | Run one read-only SQL query scoped to the caller's project. |
| `sql schema` | Return the curated tables and columns available to public SQL. |
| `datasets list` | List datasets, newest first. |
| `datasets get <dataset-id>` | Read one dataset. |
| `datasets versions list <dataset-id>` | List versions newest-first, each with its case count and whether it is current. |
| `datasets versions get <version-id>` | Read an immutable snapshot: the version plus its cases, whole or a page at a time. |
| `evals list` | List evaluations, newest first, each with its run count and latest run. |
| `evals runs list` | List evaluation runs, newest first, optionally one evaluation's or one status's. |
| `evals runs get <id>` | Read a run's own summary: status, result counts, and per-score and per-metric means over the run's results. |

## Output and exit codes

[Scripting and CI](https://traceroot.ai/docs/cli/scripting.md) covers [JSON output](https://traceroot.ai/docs/cli/scripting.md#json-output), [exit codes](https://traceroot.ai/docs/cli/scripting.md#exit-codes), and the [flags most commands share](https://traceroot.ai/docs/cli/scripting.md#shared-flags).

## Next steps

Each command group has its own page under **Commands**, starting with [Traces](https://traceroot.ai/docs/cli/traces.md).

> [card] [Authentication and Configuration](https://traceroot.ai/docs/cli/authentication.md)
>
> Which credential, project, and host the CLI uses.

> [card] [Scripting and CI](https://traceroot.ai/docs/cli/scripting.md)
>
> JSON output, exit codes, and JSON request bodies.

> [card] [Evaluations from the Terminal](https://traceroot.ai/docs/evals/cli.md)
>
> Read datasets, evaluations, and past runs.

> [card] [Troubleshoot setup](https://traceroot.ai/docs/tracing/get-started.md#troubleshoot)
>
> Fix a setup that stopped before the first trace.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.