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

# Automate with the CLI

> Use structured output, stable exit codes, API-key auth, and the Gateway API escape hatch.

The CLI separates human-readable tables from machine-readable output and keeps
data on stdout while diagnostics go to stderr.

<Note>
  **Preview.** Start automation with read-only calls and validate its behavior
  in a disposable workspace before it publishes or archives Registry content.
</Note>

## Select structured fields

Commands that expose structured output require the field list:

```bash theme={null}
atlanai skill list --json id,name,artifact_status
atlanai skill list --json id,name --jq '.[] | select(.name | contains("review"))'
atlanai workspace list --template '{{range .}}{{.id}}\t{{.display_name}}{{"\n"}}{{end}}'
```

Run the command with `--help` to see its valid JSON fields.

## Use stable exit codes

| Code | Meaning                                      |
| ---- | -------------------------------------------- |
| `0`  | Success, including an empty result.          |
| `1`  | Usage or execution error.                    |
| `2`  | The user cancelled or declined confirmation. |
| `4`  | Authentication is required or failed.        |

Treat exit code `0` as a completed command, not as proof that a later
asynchronous review or trace delivery completed. Read the returned state before
your workflow takes a follow-up action.

## Run non-interactively with an approved credential

Your CI environment must provide `ATLANAI_TOKEN` from its secret store. Do not
put the credential in a workflow file, command argument, or log.

```bash theme={null}
atlanai auth status
atlanai skill publish --ci
```

`--ci` removes prompts and enforces the configured branch guard. It is for a
repository and workspace that the job is already authorized to publish to. Use
`skill publish --changed-since <commit>` when the job has an explicit trusted
base commit; keep `--prune` opt-in because it archives Registry content.

## Discover commands programmatically

```bash theme={null}
atlanai --map compact
atlanai --map json
```

The JSON map returns command paths, summaries, child commands, and local flag
names in one call.

## Call any Gateway endpoint

```bash theme={null}
atlanai api get registry:/auth/whoami
atlanai api get registry:/artifacts/skill --paginate --slurp
atlanai api post registry:/search -F limit=10 -F is_system_included=false
```

Use `--list-ops` to inspect available operations. `--field` sends strings;
`--raw-field` handles numbers, booleans, `null`, and `@file`. `--input -` reads a
body from stdin.

Preview destructive requests before sending them:

```bash theme={null}
atlanai api delete registry:/artifacts/skill/skill_123 --dry-run
```

Destructive methods require confirmation unless `--confirm` is supplied.

Use `--confirm`, `--auto-approve`, `--force`, and `--prune` only when the
automation has resolved the exact target and its approval covers that action.
Send response data to stdout, keep diagnostics on stderr, and select fields
before parsing output in another program.
