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

> ## Agent Instructions
> Before you set up or change an Apgar integration, install the Apgar skill: npx skills add https://docs.useapgar.dev
> Search these docs with the MCP server at https://docs.useapgar.dev/mcp. Setup for each agent: https://docs.useapgar.dev/ai-agents.md

# CLI

> The apgar command and its exit codes.

The `apgar` command is the entry point of the API and worker image. In the compose stack, run it inside a running container:

```bash theme={null}
docker compose exec apgar-api apgar --version
```

With the Helm chart, run it in the API pod:

```bash theme={null}
kubectl -n apgar exec deploy/apgar-api -- apgar --version
```

## Commands

| Command | Effect |
| - | - |
| `apgar migrate` | Create the database if it is missing and apply pending migrations. A second run changes nothing |
| `apgar api` | Serve the HTTP API on `APGAR_API_HOST:APGAR_API_PORT` |
| `apgar worker` | Run the worker. Run exactly one |
| `apgar demo seed` | Insert the scripted demo agents and their verdicts |
| `apgar demo purge` | Delete the demo agents and every row that belongs to them |
| `apgar --version` | Print the version |

`apgar api` and `apgar worker` check the schema version before they start.

## demo seed

| Option | Default | Meaning |
| - | - | - |
| `--days` | `14` | Days of scripted traffic |
| `--turns-per-day` | `300` | Turns per day |
| `--seed` | `42` | Random seed |
| `--purge-first` | off | Delete existing demo data first |

When demo data already exists, the command warns and seeds on top of it; pass `--purge-first` to replace it. Scheduled checks skip demo agents; their verdicts are computed once, while seeding. The **Seed demo data** button on the empty Agents page queues the same seeding in the worker.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Success |
| `1` | Startup failed, for example ClickHouse is unreachable or another worker is running |
| `2` | Invalid configuration: an environment variable is missing or invalid |
| `3` | The database schema version does not match this version of Apgar. Run `apgar migrate`. `api` and `worker` report it this way; the demo commands fail with a traceback and code 1 |


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