# CLI Reference

The `docs-hub` binary runs one-shot administrative commands without starting the HTTP server. This page lists every command and flag.

The commands use the same `.env`, `DOCS_HUB_CONFIG` and `DOCS_HUB_DATA_DIR` loading as normal startup. Missing runtime directories are created before the command runs. With Docker, run them through `docker compose exec docs-hub docs-hub ...`.

## Commands

| Command | Description |
|---------|-------------|
| `--init-data` | Create the data directories and seed files, then exit. Safe to repeat. |
| `--create-user` | Create a user in the database and exit. |
| `--register-service` | Register a service and print its upload token once. |
| `--recalculate-changelog` | Recalculate the Change Log for one service, or for every service if `--service-slug` is omitted. Overwrites existing logs. Does not publish, promote or rebuild. |
| `--backfill-spec-format` | Fill in `spec_format` for services where it is empty. Never overwrites an existing format. |
| `--print-device-id` | Print the installation's device ID (generating and persisting one on first call) and exit. |
| `--help`, `-h` | Show help. |

## User flags

| Flag | Description |
|------|-------------|
| `--user-login LOGIN` | Login of the user. |
| `--user-password PASSWORD` | Plain password. |
| `--user-password-hash HASH` | A bcrypt hash, as an alternative for non-interactive provisioning. |
| `--user-role admin\|editor\|reader` | Role of the user. |
| `--user-disabled` | Create the account disabled. |

```bash
docker compose exec docs-hub docs-hub --create-user \
  --user-login admin --user-password change-me --user-role admin
```

## Service flags

| Flag | Description |
|------|-------------|
| `--service-slug SLUG` | Lowercase letters, digits and single dashes. |
| `--service-name NAME` | Display name. |
| `--service-description TEXT` | Description. |
| `--service-main-branch NAME` | Main branch, default `main`. |
| `--service-token TOKEN` | Use this upload token instead of generating one. |
| `--service-token-hash HASH` | Provide a token hash instead of a raw token. |

```bash
docker compose exec docs-hub docs-hub --register-service \
  --service-slug billing-api --service-name "Billing API"
```

The raw token is printed once and only its hash is stored.

## Maintenance

```bash
docker compose exec docs-hub docs-hub --recalculate-changelog --service-slug billing-api
docker compose exec docs-hub docs-hub --backfill-spec-format
docker compose exec docs-hub docs-hub --print-device-id
```

Use `--recalculate-changelog` to backfill a Change Log for versions published before the feature existed, or to re-apply a changed comparison algorithm to old history.

## Next steps

- [Installation](/documentation/installation)
- [Publishing a Specification](/documentation/publishing-specifications)

---
Source: https://selfdochub.com/documentation/cli-reference
