# Installation

> Install the official traces CLI and set the environment for adTraces.

adTraces speaks the same API as the official `traces` CLI, so you install the CLI itself. Nothing is built from this repository.

## Install the CLI

Pick one method.

```bash
# npm
npm i -g @traces-sh/traces

# Homebrew (macOS, Linux)
brew install market-dot-dev/tap/traces

# Helper script of this instance: installs via npm or Homebrew and prints the environment
curl -fsSL https://adtraces.adfactory.app/install | bash
```

Check the result with `traces version`.

## Point the CLI at this instance

The CLI reads three URL variables and an optional key. All three URLs must be set, otherwise parts of the CLI keep talking to traces.com.

```bash
export TRACES_HTTP_URL=https://adtraces.adfactory.app
export TRACES_URL=https://adtraces.adfactory.app
export TRACES_API_URL=https://adtraces.adfactory.app
export TRACES_API_KEY=trk_...   # optional, see Authentication
```

Put these lines in your shell profile. Hooks started by an agent only see the agent's environment, see [Agents](/docs/agents).

## Upgrade and remove

```bash
traces upgrade
traces uninstall
traces reset --all --force   # also clears local data and credentials
```

If something does not work, run `traces doctor` and read [Troubleshooting](/docs/cli/troubleshooting).
