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

# Automate the CLI

> Use explicit scope, machine-readable output, serialized writes, and stable exit behavior.

Automation should make authentication and wiki scope explicit:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
export ALMANAC_TOKEN="waka_..."
export ALMANAC_WIKI="acme/company-handbook"
```

## Request JSON

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
almanac search "customer onboarding" --json
```

`--json` writes one JSON value to standard output and suppresses the human scope
banner. The JSON includes the resolved wiki and scope where relevant.

## Serialize CLI writes

The CLI upload result says whether a job was queued but does not expose its ID.
`last` is therefore safe only when your automation serializes writes to the wiki
and waits immediately:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
almanac upload docs/ --json
almanac jobs wait last --json
```

Duplicate-only uploads return no new job. Handle that branch instead of waiting
for the previous `last` job. When concurrent writers need an exact job ID, use the
[Python SDK](/sdk/sources-and-jobs) or [REST API](/api/overview), whose upload
responses include the nullable job record.

## Exit behavior

| Exit code | Meaning                                  |
| --------- | ---------------------------------------- |
| `0`       | Command completed successfully           |
| `1`       | Almanac reported an error                |
| `2`       | Command syntax or arguments were invalid |
| `130`     | Command was interrupted                  |

Run `almanac COMMAND --help` for command-specific flags. See [CLI reference](/reference/cli)
for the command map and [API keys](/api/authentication) for least-privilege permissions.
