Once authentication works, the ant CLI stops being a toy and becomes a scripting primitive. Three design choices make it pipeline-friendly: request bodies can arrive on stdin, files can be inlined into any string field, and responses can be filtered to exactly the field your script needs — no jq required.
Getting data in
Scalar flags map directly to request fields, and structured fields accept relaxed YAML or strict JSON. Repeated flags build arrays. For anything bigger, pipe a full JSON or YAML body on stdin — it is merged with flags, and flags win (a flag replaces a stdin array entirely, so don't expect appends).
The @file syntax inlines file contents into any string field, which is how you feed a document to a prompt without shell quoting pain. Binary files are automatically base64-encoded; @file:// forces text, @data:// forces base64, and a literal leading @ escapes as \@.
Getting data out
By default, output is pretty-printed when stdout is a terminal and machine-friendly in a pipe. You control it explicitly with --format (json, jsonl, yaml, raw, and others). The workhorse for scripts is --transform, which extracts fields with a GJSON path expression and applies per-item on list responses, paired with -r/--raw-output to print unquoted strings (same semantics as jq's -r). List endpoints paginate automatically; cap the total with --max-items, which is distinct from --limit (the server-side page size).
A representative capture-the-ID pattern, from the documented flow for version-controlled resources:
# create a resource from YAML in the repo, keep only its ID
AGENT_ID=$(ant beta:agents create < agent.yaml --transform id -r)
# later, update it under optimistic locking
ant beta:agents update --agent-id "$AGENT_ID" --version N < agent.yaml
This is the recommended division of labor: use the CLI for the control plane — agents, environments, skills, vaults, files defined as YAML in your repository and applied from CI — and use an SDK for the data plane, driving sessions and events from application code. Keeping resource definitions in version control means every change to an agent or skill goes through review and leaves a diff, and the CI job that applies them is a two-line script rather than bespoke deployment code.
Makefiles and CI jobs
Nothing about ant is special inside make: each target line is a shell command, so the patterns above transfer directly — parametrize the model or workspace with Make variables and let --transform keep recipes one line long. For CI, avoid interactive login: use Workload Identity Federation for the job's credential, or have a wrapper step export ANTHROPIC_AUTH_TOKEN via ant auth print-credentials --env when a locally authenticated profile must hand off to a child process. Remember the precedence trap: a set ANTHROPIC_API_KEY, even empty, overrides every profile.
--debug to any command to stream the full HTTP request and response to stderr (API key redacted) without disturbing stdout — your pipeline keeps working while you watch the wire. For streaming session work, note that ant beta:sessions:events stream only delivers events emitted after the stream opens, so open the stream before sending the kickoff event.Three habits that keep scripts robust
First, always pin --format json (or jsonl) in scripts rather than relying on auto-detection — explicit is better than clever when output feeds another program. Second, extract with --transform ... -r instead of grepping pretty output; pretty formatting is for humans and may change. Third, keep deterministic steps deterministic: use the CLI to move data and call the API, and reserve the model itself for the judgment step in your pipeline. A nightly job that summarizes a report should be a five-line script, not a framework.
Where to go next
See listing and switching models with the ant CLI to parametrize model choice in your scripts, and injecting Claude credentials into CI/CD pipelines for the secrets side. The CLI introduction covers installation and command structure.