# Command line

`tailcove` is Tailcove in your terminal. You can follow a source's logs as they arrive, search them, record a deploy
from CI and fail the build when it made things worse, upload source maps, send a script's output to a source
without changing the script, and watch your local dev server's logs in Tailcove. It's a single binary and talks to the same [API](https://tailcove.dev/docs/api/authentication) as everything
else, with a token it gets by signing you in through the browser.

## Install

Every release of the [Tailcove agent](https://tailcove.dev/docs/sending-logs/agent) ships the `tailcove` command next to `tailcove-agent`,
as one static binary for Linux and macOS (amd64 and arm64). Pick your system:

```bash@macOS
# Apple silicon (M1 and later). On an Intel Mac use tailcove_darwin_amd64.tar.gz.
curl -fsSL https://github.com/tailcove/agent/releases/latest/download/tailcove_darwin_arm64.tar.gz | tar -xz tailcove
sudo install -m 0755 tailcove /usr/local/bin/tailcove
tailcove version
```

```bash@Linux
# x86_64. On an ARM server use tailcove_linux_arm64.tar.gz.
curl -fsSL https://github.com/tailcove/agent/releases/latest/download/tailcove_linux_amd64.tar.gz | tar -xz tailcove
sudo install -m 0755 tailcove /usr/local/bin/tailcove
tailcove version
```

```powershell@Windows
# There's no Windows build yet. Install WSL once (it needs a restart), then
# run the Linux commands inside the Ubuntu terminal it adds.
wsl --install
```

Not sure which Mac you have? `uname -m` prints `arm64` on Apple silicon and `x86_64` on Intel. If macOS says the
binary "can't be opened because Apple cannot check it", it came through a browser download: run
`xattr -d com.apple.quarantine tailcove` once, or use the `curl` line above, which doesn't set that flag.

Each release lists the archives' SHA-256 sums in `checksums.txt`. The release's `.deb` and `.rpm` packages install it as
`/usr/bin/tailcove` too. With Go 1.24 or newer you can build it yourself:

```sh
go install github.com/tailcove/agent/cmd/tailcove@latest
```

## Sign in

```sh
tailcove login
```

It prints a short code such as `BCDF-GHJK` and a link to `https://tailcove.dev/cli/activate`, and opens the link in
your browser. Check that the page shows the same code, look at what it says about the request (the name your machine
gave itself, the address it came from and how long ago), then press **Approve**. The terminal picks up its token a few
seconds later and saves it. On a server you reached over SSH no browser opens (or pass `--no-browser`): open the link on
your laptop instead and type the code there. The page then points out that the code came from another address, which is expected here.

A code lasts 10 minutes and works once. Only approve a code you started yourself: anyone can start a sign-in and send
you its link, and approving it hands them a token for your account. Tailcove never asks you for a code. If the page shows
an address you don't recognise, press **Deny**.

The token acts as you in the team you're working in. The page names that team and lists other teams you're in, so you can
switch before you approve. It can do this, and no more:

| Ability            | What the CLI uses it for                     |
| ------------------ | -------------------------------------------- |
| `sources:read`     | `tailcove sources`, finding a source by name |
| `sources:write`    | `tailcove init` creating a source            |
| `logs:read`        | `tailcove tail` and `tailcove search`        |
| `deploys:read`     | `tailcove deploy --wait` reading the check   |
| `deploys:write`    | `tailcove deploy` recording a deploy         |
| `sourcemaps:write` | `tailcove sourcemaps upload`                 |

If your role in the team is Viewer, the token only gets the three read abilities. A Billing member can't sign the CLI in
to that team at all. If the team has an [IP allow-list](https://tailcove.dev/docs/team-security), approve from an address on it, and run the
CLI from one too: requests from anywhere else are refused.

The token shows up in **Settings → API tokens** as "Tailcove CLI on" and your machine's name. Revoke it there to sign that
machine out for good. Signing in again makes a new token, and a team holds at most 25, so revoke the ones you no longer use.

```sh
tailcove whoami    # the team and the person the saved token belongs to
tailcove logout    # forgets the saved token on this machine
```

`tailcove logout` only deletes the copy on your machine. The token itself keeps working until you revoke it in Settings.

## Sources

```sh
tailcove sources
```

Lists the team's sources with their id, name and platform. `tail` and `search` take a source by either. In scripts and
CI the id is the safer choice: it doesn't change when someone renames the source.

## Follow logs live

```sh
tailcove tail api 'level:error OR status>=500'
```

Prints the last 10 lines from the source `api`, then new ones as they arrive, coloured by level, until you press
Ctrl+C. Everything after the source is a query in the [query language](https://tailcove.dev/docs/query-language); leave it out to see every
line. The CLI asks the API for new lines every 2 seconds, and waits longer when the API asks it to, so one token can run a
couple of tails at once. `-n 0` skips the history, `--utc` shows times in UTC, and `--json` prints one JSON object per line
(NDJSON) instead, for `jq`:

```sh
tailcove tail api --json | jq -r 'select(.context.user_id == 42) | .message'
```

## Search

```sh
tailcove search api '"connection refused"' --since 1h --limit 50
```

Newest lines first. `--since` takes a duration such as `15m`, `6h` or `2d` (1 hour by default). For a window in the past,
`--from` and `--to` take a time such as `2026-11-30T09:00` (local time unless it names a zone) or a duration ago (`2h`).
`--limit` defaults to 100. `--json` works here too.

## Record a deploy, and wait for its check

```sh
tailcove deploy --source src_01jbx5q8k7m3n2p4r6s8t0v1w3 --version v1.8.0 --env production --wait
```

Records a [deploy](https://tailcove.dev/docs/api/deploys) on the source, so it shows on the dashboard next to the errors. The commit comes from
`--sha`, or from `GITHUB_SHA`, GitLab's, Bitbucket's, CircleCI's or Vercel's variables, or `git rev-parse HEAD` when you
leave it out, and the version defaults to the short commit. `--rollback` records a rollback instead. With `--wait` the
command stays until Tailcove has run the [deploy check](https://tailcove.dev/docs/deploy-checks), comparing the source's errors before and
after the deploy and looking for new error patterns and new issues, then exits with `1` if the check says the deploy made
things worse and `0` if it looks healthy, had too little traffic to judge, or was skipped. `--timeout` (20 minutes by
default) bounds the wait.

For a preview of a pull request, add `--env preview`. `--pull-request` and `--branch` name the pull request; leave them
out in GitHub Actions, GitLab, Bitbucket, CircleCI or Vercel and they're read from the CI's variables. In a pull request
run the commit is the pull request's head, not `GITHUB_SHA` (a merge commit GitHub makes, which a pull request never
shows a status for). The preview check looks for error patterns your production source hasn't logged instead of
comparing error rates: see [previews and pull requests](https://tailcove.dev/docs/deploy-checks#previews-and-pull-requests).

## Upload source maps

```sh
tailcove sourcemaps upload dist/assets --source src_01jbx5q8k7m3n2p4r6s8t0v1w3 \
  --url-prefix https://app.example.com/assets --release v1.8.0
```

Uploads every `.js.map`, `.mjs.map` and `.cjs.map` file under the folder. Each one is filed under the URL its script is
served from: the prefix plus the file's path inside the folder, so `dist/assets/app-3f9a1c.js.map` belongs to
`https://app.example.com/assets/app-3f9a1c.js`. Errors from the browser then point at your own files and lines instead of
the minified bundle. [Code links and source maps](https://tailcove.dev/docs/code-links) has the details and the limits.

## Set up a project

```sh
cd my-app
tailcove init
```

Looks at the project to see what it's built with (Laravel, Node, a browser or React Native app, Python or Flutter, and the
agent for anything else), lets you pick a source or create one, installs the matching client package once you say yes,
and sends a test line so you can watch it arrive. For an app that runs on a server it adds `TAILCOVE_TOKEN` to `.env`,
never replacing one that's already there; a browser or mobile app uses a public key instead, and `init` says where to make
one. It ends by printing what to do next. `--yes` answers every question with the default, and `--source`, `--name` and
`--platform` skip the questions they answer.

## In CI

CI can't open a browser, so it doesn't use `tailcove login`. Make a token in **Settings → API tokens** with the **For CI**
preset (`sources:read`, `deploys:read`, `deploys:write` and `sourcemaps:write`), store it as a secret, and hand it to the
CLI as `TAILCOVE_API_TOKEN`. In GitHub Actions, after the build and around the deploy step:

```yaml
jobs:
    deploy:
        runs-on: ubuntu-latest
        env:
            TAILCOVE_API_TOKEN: ${{ secrets.TAILCOVE_API_TOKEN }}
        steps:
            - uses: actions/checkout@v4
            - name: Install tailcove
              run: |
                  curl -fsSL https://github.com/tailcove/agent/releases/latest/download/tailcove_linux_amd64.tar.gz | tar -xz tailcove
                  sudo install -m 0755 tailcove /usr/local/bin/tailcove

            - run: npm ci && npm run build
            - name: Upload source maps
              run: tailcove sourcemaps upload dist/assets --source src_01jbx5q8k7m3n2p4r6s8t0v1w3 --url-prefix https://app.example.com/assets --release ${{ github.sha }}

            - name: Deploy
              run: ./scripts/deploy.sh

            - name: Fail the job if the deploy made things worse
              run: tailcove deploy --source src_01jbx5q8k7m3n2p4r6s8t0v1w3 --version ${{ github.sha }} --env production --wait --timeout 15m
```

The source id comes from `tailcove sources`. Upload the maps before the deploy goes live, so the first errors after it
are already readable. `tailcove deploy` picks the commit up from `GITHUB_SHA` by itself.

## Scripts and cron

`tailcove pipe` reads standard input, writes it straight back out, and sends each line to a source. It uses the source's
ingest token (the one your apps use, not an API token), from `TAILCOVE_SOURCE_TOKEN` or `--token`:

```sh
TAILCOVE_SOURCE_TOKEN=your-source-token ./backup.sh 2>&1 | tailcove pipe --level info
```

Lines go out in batches, with [secrets masked](https://tailcove.dev/docs/transform-rules#recommended-masking) first, and a line that is a JSON
object keeps its fields. If Tailcove can't be reached, the output still passes through and the command still exits `0`,
so it never breaks the script it's attached to. That also means a pipeline's exit status is `tailcove pipe`'s, not your
script's: put `set -o pipefail` at the top of a bash script, or the cron line, when a failing script should still count as
a failure.

```crontab
SHELL=/bin/bash
TAILCOVE_SOURCE_TOKEN=your-source-token
15 3 * * * set -o pipefail; /usr/local/bin/backup.sh 2>&1 | tailcove pipe --level info >> /var/log/backup.log
```

Without `--level`, each line's level is read from the line itself (`ERROR`, `warn`, `[info]` and the like); `--level` sets
one level for every line instead. `--host` names the machine the lines come from (this one by default).
`TAILCOVE_MASK_SECRETS=false` turns the masking off and `TAILCOVE_SECRET_KEYS` (comma separated) adds field names to mask.

## Local development

```sh
tailcove dev -- npm run dev
```

Runs your dev server as usual and sends everything it prints to a temporary source of your own, so you get search and
Live tail on your local logs. It signs in like the other commands (`tailcove login`, or `TAILCOVE_API_TOKEN`), asks
Tailcove for your temporary source for this machine and project, prints the Live tail link and opens it in your browser.
Then it runs the command. The output still goes straight to your terminal, and every line is also sent to the source in
batches, with [secrets masked](https://tailcove.dev/docs/transform-rules#recommended-masking) and the level read from each line, like
`tailcove pipe`.

```
tailcove dev [--project NAME] [--level L] [--no-open] -- <command> [args…]
```

The project is the current folder's name unless you pass `--project`. `--level` sets one level for every line, and
`--no-open` prints the link without opening the browser. Ctrl+C goes to your command, and `tailcove dev` exits with your
command's exit code. If Tailcove can't be reached, your command runs anyway and you get a one-line warning.

The source is named after the machine and project, `dev · ranas-mac · my-app`, and running the same project again on the
same machine reuses it. A few things set it apart from a regular source:

- It's deleted 24 hours after the last `tailcove dev` for that project, with its logs, and keeps at most a day of them.
- Only you, and your team's owners and admins, can see it. It's in no client group.
- It doesn't count toward your plan's source limit, but what it sends counts toward your monthly GB like any source.
- You can have 3 at a time in a team. A fourth project is refused until one expires or you delete one from the Sources page.
- It can't have alerts, and it isn't offered for dashboards, SLOs, Compare or Correlate.

Every run gets a new ingest token and the previous one stops working. So if you run the same project twice at once (two
terminals, same folder), the first one's lines stop arriving; pass a different `--project` to the second.

## Configuration

`tailcove login` saves the token in `~/.config/tailcove/config.json` (or `$XDG_CONFIG_HOME/tailcove/config.json`),
readable by you only (mode `0600`), with the team it belongs to. You never need to edit it. Flags and environment
variables win over the file:

| Setting                        | Flag      | Environment             |
| ------------------------------ | --------- | ----------------------- |
| API token                      | `--token` | `TAILCOVE_API_TOKEN`    |
| Tailcove address               | `--api`   | `TAILCOVE_API_URL`      |
| Ingest token (`tailcove pipe`) | `--token` | `TAILCOVE_SOURCE_TOKEN` |

The address only matters for a local or self-hosted copy of Tailcove; everyone else leaves it alone.

## Exit codes

| Code | Meaning                                                               |
| ---- | --------------------------------------------------------------------- |
| `0`  | it worked (for `deploy --wait`: healthy, too little data, or skipped) |
| `1`  | it failed, or `deploy --wait` found the deploy made things worse      |
| `2`  | the command line was wrong: an unknown flag or a missing argument     |
