# Command line (/docs/go/cli)

The Go module has a `tracepanel` command for what a Go project has no pip
or npm to run with. It runs the agent the SDK runs, the one in the user's
cache, and downloads it the first time. See
[The agent](/docs/go/installation#the-agent) for where the cache is. Install
it:

```bash
go install github.com/tracepanel/tracepanel-go/cmd/tracepanel@v0.10.0
```

Then run it from your project's directory, so it finds the project's store:

```bash
tracepanel mcp
```

Without installing it, `go run` runs it the same way:

```bash
go run github.com/tracepanel/tracepanel-go/cmd/tracepanel@v0.10.0 mcp
```

| Command | What it does |
| --- | --- |
| `tracepanel run` | Runs your app with Tracepanel recording. |
| `tracepanel mcp` | Runs an MCP server for AI coding agents. |
| `tracepanel dev` | Runs the agent in the foreground and serves the console, and your app beside it. |
| `tracepanel agent` | Runs the agent with its own arguments. |
| `tracepanel version` | Prints the SDK's version and the agent's. |

The project's store is in `TRACEPANEL_DIR`, else `.tracepanel`, as the SDK
keeps it. `TRACEPANEL_AGENT_BIN` runs another build of the agent.

## tracepanel run [#tracepanel-run]

```bash
go build -o shop . && tracepanel run ./shop
```

`tracepanel run` starts a command with Tracepanel recording. The command can
follow `--` too, as in `tracepanel run -- ./shop`, the same as
`tracepanel run ./shop`. The SDK records
in development only, under `go run`, so a binary built with `go build`
records nothing on its own. `tracepanel run` sets `TRACEPANEL_ENABLED=1` for
the command, and passes its input and output through. An app run
with `go run` records anyway.

It exits with the app's exit code. When the app fails, it says how the app
ended on stderr:

```text
tracepanel: ./shop exited with status 3
```

Run through `go run`, the command exits 1 whatever the app's code, so that
line is where the app's status is.

## tracepanel mcp [#tracepanel-mcp]

```bash
tracepanel mcp [--values]
```

`tracepanel mcp` runs the agent's MCP server on stdin and stdout, for Claude
Code, Cursor, Codex and other coding agents. `--values` adds SQL parameters
and local variables to its answers. Add it to Claude Code like this:

```bash
claude mcp add --scope project tracepanel -- tracepanel mcp
```

In a JSON config, that is `"command": "tracepanel"` with `"args": ["mcp"]`.
See [AI coding agents](/docs/ai-agents).

## tracepanel dev [#tracepanel-dev]

```bash
tracepanel dev [--port 8765] [-- COMMAND...]
```

`tracepanel dev` runs the agent in the foreground, with the console on
http://127.0.0.1:8765/. Use it to watch the agent's output, to open the
console on a fixed address, or to read the traces after your app has
stopped. `--port` moves the console.

A command after `--` runs beside the console with Tracepanel recording, as
`tracepanel run` runs it, until the console stops. `--port` goes before the
`--`:

```bash
tracepanel dev -- ./shop
tracepanel dev --port 9100 -- ./shop
```

When the console stops, such as on Ctrl+C, it stops the app too, and the
command exits with the console's exit code. An app that fails on its own
says how it ended on stderr, as under `tracepanel run`, and the console
keeps running. An app the console stopped says nothing.

## tracepanel agent [#tracepanel-agent]

```bash
tracepanel agent --help
```

`tracepanel agent` runs the agent with the arguments you give it.
