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

# CLI

> Read and publish prompts from your terminal

The CLI ships in the same package as the SDK.

<CodeGroup>
  ```bash npx theme={null}
  npx anpord list
  ```

  ```bash global theme={null}
  npm install -g anpord
  anpord list
  ```
</CodeGroup>

Authentication comes from the environment:

```bash theme={null}
export ANPORD_API_KEY="anp_..."
```

## Commands

### get

```bash theme={null}
anpord get <id> [--json] [--channel <name>] [--at <version>]
```

Prints the prompt's content to stdout, which makes it pipeable:

```bash theme={null}
anpord get support-reply > prompt.txt
anpord get support-reply | pbcopy
```

`--json` prints the whole prompt instead, including its version and channel.
`--channel` and `--at` select which version to resolve, following the same rules
as the API.

### list

```bash theme={null}
anpord list [--json]
```

One prompt per line as `id`, latest version, and name.

### versions

```bash theme={null}
anpord versions <id>
```

The prompt's history as JSON.

### push

```bash theme={null}
anpord push <id> <content> [-m <message>]
```

Appends a version. Pass `-` to read the content from stdin:

```bash theme={null}
cat prompts/support-reply.md | anpord push support-reply - -m "Rewrite"
```

Pushing does not change what production serves. Promote when you are ready.

### promote

```bash theme={null}
anpord promote <id> --to <channel> --at <version>
```

Points a channel at a version.

```bash theme={null}
anpord promote support-reply --to production --at 5
```

## Scripting

Content goes to stdout and everything else to stderr, so redirecting a prompt to
a file captures the prompt and nothing else. A failure exits non-zero:

```bash theme={null}
if ! anpord get support-reply > prompt.txt; then
  echo "could not resolve the prompt" >&2
  exit 1
fi
```

## Completions

```bash theme={null}
anpord --completions zsh
```

Also available for `bash`, `fish`, and `sh`.

## Configuration

| Variable          | Purpose                                         |
| ----------------- | ----------------------------------------------- |
| `ANPORD_API_KEY`  | Required. The key the CLI authenticates with.   |
| `ANPORD_BASE_URL` | Optional. Defaults to `https://api.anpord.com`. |
