DEV Community

RAXXO Studios
RAXXO Studios

Posted on • Originally published at raxxo.shop

The ant CLI Puts the Full Claude API in Your Terminal

  • ant is Anthropic's official CLI that replaces curl and hand-written JSON for Claude API work

  • Build requests from typed flags or piped YAML, inline files with @path references

  • Version-control agents, environments, and skills as YAML files checked into your repo

  • Claude Code understands ant natively, so you can ask it to manage API resources directly

  • Interactive explorer TUI for browsing responses, auto-pagination, and GJSON transforms

Every developer who has built with the Claude API knows the ritual. Open a terminal. Write a curl command. Manually escape JSON. Forget a comma. Fix the JSON. Run it again. Parse the response with jq. Repeat until the prototype works.

Anthropic just ended that loop. On April 8, they launched the ant CLI, a purpose-built command-line client for the Claude API that replaces curl, hand-written JSON, and the collection of shell scripts most of us have accumulated.

What ant Actually Does

ant is a single binary that exposes every Claude API resource as a subcommand. Messages, models, agents, sessions, files, skills, environments. If the API has an endpoint, ant has a command for it.

The simplest example sends a message to Claude:


ant messages create \
  --model claude-opus-4-6 \
  --max-tokens 1024 \
  --message '{role: user, content: "Hello, Claude"}'

Enter fullscreen mode Exit fullscreen mode

Notice the YAML-like syntax for the message flag. No strict JSON required. Keys do not need quotes. Strings do not need quotes unless they contain special characters. This alone saves significant friction when working from the terminal.

The response comes back as formatted JSON when you are in an interactive terminal, or compact JSON when piped to another command. No extra formatting flags needed for the common cases.

Why This Beats curl

Three things make ant better than curl for Claude API work.

Typed flags replace raw JSON. Instead of constructing a JSON body and praying you did not miss a bracket, you use named flags. Scalar fields map directly to flags. Structured fields accept the relaxed YAML syntax. Repeatable flags build arrays automatically. Each --tool flag appends one tool to the array.


ant beta:agents create \
  --name "Research Agent" \
  --model '{id: claude-opus-4-6}' \
  --tool '{type: agent_toolset_20260401}' \
  --tool '{type: custom, name: search, input_schema: {type: object}}'

Enter fullscreen mode Exit fullscreen mode

File inlining with @path. Want to send a PDF to Claude? Prefix the path with @. The CLI detects the file type and handles encoding automatically. Binary files get base64-encoded. Text files get inlined as strings. No manual base64 piping.


ant messages create \
  --model claude-opus-4-6 \
  --max-tokens 1024 \
  --message '{role: user, content: [
    {type: document, source: {type: base64, media_type: application/pdf, data: "@./report.pdf"}},
    {type: text, text: "Summarize this report."}
  ]}'

Enter fullscreen mode Exit fullscreen mode

Built-in response filtering. The --transform flag uses GJSON paths to extract exactly what you need from responses. No jq dependency. No separate parsing step.


ant beta:agents list \
  --transform "{id,name,model}" \
  --format jsonl

Enter fullscreen mode Exit fullscreen mode

This outputs one JSON object per line with only the fields you asked for. Clean, pipeable, ready for scripts.

The Interactive Explorer

For debugging or exploration, --format explore opens a terminal UI for browsing large responses. Arrow keys expand and collapse nodes. Slash searches within the response. Q exits. It is the kind of feature you did not know you needed until you are staring at a 500-line agent configuration and trying to find one specific field.


ant models list --format explore

Enter fullscreen mode Exit fullscreen mode

Auto-pagination handles list endpoints transparently. You get all results without managing page tokens or cursor parameters. Each item streams individually, so you can pipe into head or grep without waiting for the full response.

Version-Controlling API Resources

This is where ant becomes more than a convenience tool and turns into an infrastructure management layer.

Agents, environments, skills, and deployments can be defined as YAML files in your repository. You create the resource by piping the file to ant, update it the same way, and track changes through git.

Here is a complete workflow:


# summarizer.agent.yaml
name: Summarizer
model: claude-sonnet-4-6
system: |
  You are a helpful assistant that writes concise summaries.
tools:
  - type: agent_toolset_20260401

Enter fullscreen mode Exit fullscreen mode

Create it:


ant beta:agents create < summarizer.agent.yaml

Enter fullscreen mode Exit fullscreen mode

Update it after making changes:


ant beta:agents update \
  --agent-id agent_011CYm1BLqPX... \
  --version 1 \
  < summarizer.agent.yaml

Enter fullscreen mode Exit fullscreen mode

This pattern means your AI infrastructure lives in the same repo as your application code. Same review process. Same CI pipeline. Same git history. No more "who changed the agent prompt last Thursday" mysteries.

Environments work the same way:


# summarizer.environment.yaml
name: summarizer-env
config:
  type: cloud
  networking:
    type: unrestricted

Enter fullscreen mode Exit fullscreen mode

Define once, create via CLI, update through git-tracked YAML files. Infrastructure as code for your AI agents.

Claude Code Integration

Here is the detail that makes ant different from a generic API client: Claude Code understands it natively. You can ask Claude Code to manage API resources, and it will shell out to ant, parse the structured output, and reason over the results.

No custom integration code. No wrapper scripts. No teaching Claude Code how to use your API client. It already knows.

Practical examples of what you can ask Claude Code to do through ant:

  • "List my recent agent sessions and summarize which ones errored."

  • "Upload every PDF in ./reports to the Files API and print the resulting IDs."

  • "Pull the events for this session and tell me where the agent got stuck."

This is automation that composes. ant gives you the building blocks. Claude Code gives you the reasoning layer on top.

Installation

Three options, all straightforward:

Homebrew (macOS):


brew install anthropics/tap/ant
xattr -d com.apple.quarantine "$(brew --prefix)/bin/ant"

Enter fullscreen mode Exit fullscreen mode

curl (Linux/WSL):


VERSION=1.0.0
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
curl -fsSL "https://github.com/anthropics/anthropic-cli/releases/download/v${VERSION}/ant_${VERSION}_${OS}_${ARCH}.tar.gz" \
  | sudo tar -xz -C /usr/local/bin ant

Enter fullscreen mode Exit fullscreen mode

Go (from source):


go install github.com/anthropics/anthropic-cli/cmd/ant@latest

Enter fullscreen mode Exit fullscreen mode

Authentication reads from the ANTHROPIC_API_KEY environment variable. Set it once, use it everywhere.

Shell Completion

ant ships completion scripts for bash, zsh, fish, and PowerShell. For zsh:


ant @completion zsh > "${fpath[1]}/_ant"

Enter fullscreen mode Exit fullscreen mode

Tab completion on API resource names and flags is the kind of quality-of-life improvement that separates a tool you tolerate from a tool you reach for instinctively.

Debugging

The --debug flag prints the full HTTP request and response to stderr, with API keys redacted. When something is not working, you see exactly what went over the wire without adding verbose logging to your code.


ant --debug beta:agents list

Enter fullscreen mode Exit fullscreen mode

This shows headers, body, status codes. Everything you need to diagnose authentication issues, malformed requests, or unexpected responses.

Beta Resources Under the beta: Prefix

Resources still in beta, including agents, sessions, deployments, environments, and skills, live under the beta: prefix. Commands in this namespace automatically send the appropriate anthropic-beta header, so you never need to pass it manually.


ant beta:agents list
ant beta:sessions create --agent agent_011CYm1BLqPX...
ant beta:sessions:events list --session-id session_01JZCh78...

Enter fullscreen mode Exit fullscreen mode

This is a thoughtful design choice. Beta resources are clearly namespaced. When they graduate to stable, the prefix drops and your scripts need a one-line change. No hidden header management, no accidental mixing of stable and beta endpoints.

Scripting Patterns

ant is built to compose with standard shell tools. The --transform id --format yaml pattern on list endpoints emits one bare ID per line, so head, tail, xargs, and while loops work naturally.

Chain commands together:


FIRST_AGENT=$(ant beta:agents list \
  --transform id --format yaml | head -1)

ant beta:agents:versions list \
  --agent-id "$FIRST_AGENT" \
  --transform "{version,created_at}" --format jsonl

Enter fullscreen mode Exit fullscreen mode

Error handling uses --transform-error and --format-error flags that mirror the success-path counterparts:


ant beta:agents retrieve --agent-id bogus \
  --transform-error error.message --format-error yaml 2>&1

Enter fullscreen mode Exit fullscreen mode

This means you can build robust shell scripts that handle both success and failure paths without wrapping everything in try-catch equivalents or parsing stderr manually.

Who Should Use This

If you interact with the Claude API from the terminal more than once a week, install ant. The time saved on JSON construction alone pays for the 30-second installation.

If you manage agents, skills, or environments through the API, the YAML version-control pattern is reason enough. Tracking AI infrastructure in git is not optional for serious production work. When your agent's behavior changes, you should be able to git blame the YAML file and see exactly who changed what and when.

If you use Claude Code as your primary development environment, ant adds capabilities that were previously impossible without custom scripts. The native integration means you can treat the Claude API as a first-class resource in your development workflow.

I have been using ant since it launched and the difference in my daily workflow is noticeable. Checking model availability, listing agent sessions, uploading files to the API. Tasks that used to require opening documentation, copying curl examples, and adjusting JSON now take a single command. That friction reduction compounds fast when you interact with the API multiple times per day.

The CLI is open source on GitHub at anthropics/anthropic-cli. It is written in Go, ships as a single binary, and has no runtime dependencies. Clean, fast, and built for the terminal-first developer.

Top comments (0)