Top CLI tools for AI agents

The top CLI tools for AI agents: coding runtimes like Claude Code, Codex, Gemini, and Cursor, plus tools agents use: gh, ripgrep, jq, HTTPie, apidog-cli.

Ashley Innocent

Ashley Innocent

10 July 2026

Top CLI tools for AI agents

Apidog for Enterprise

On-Premises Deploy

SSO & RBAC

SOC 2 Compliant

Explore Apidog Enterprise

An AI agent doesn’t read a GUI. It runs a command, reads what comes back on stdout, checks the exit code, and decides what to do next. That loop only works when the tools it calls behave predictably. A tool that prints a colorful table for humans, prompts “Are you sure? (y/n)”, or exits 0 whether or not the job succeeded will break an agent in ways that are hard to debug.

So the interesting question isn’t “which CLI is most powerful.” It’s “which CLIs are shaped so an agent can act on their output.” That means structured JSON instead of prose, a non-interactive mode that never blocks on a prompt, and exit codes an agent can branch on.

This list splits into two buckets. First, the agent runtimes: the coding CLIs that are the agent, like Claude Code, Codex CLI, Gemini CLI, and Cursor CLI. Second, the tools agents use as hands: gh, ripgrep, jq, HTTPie, and apidog-cli, which was built for machine callers with structured JSON and next-step hints baked in. If you’re wiring an agent into your API workflow, the Apidog CLI complete guide walks the full setup. You’ll get a real install command and a working example for each, plus honest notes on where each one bites.

button

What makes a CLI tool good for AI agents

Three properties separate agent-friendly CLIs from the rest.

Structured output. An agent parses JSON far more reliably than it parses a formatted table. A tool that offers --json or --output-format json lets the agent read fields by name instead of guessing at column positions.

Non-interactive mode. If a command ever stops to ask a question, an agent running headless will hang forever. Agent-fit CLIs have a print or exec mode that takes the full request up front and never blocks.

Deterministic exit codes. Exit 0 on success, non-zero on failure, consistently. That single number is how an agent knows whether to move on or retry. Tools that exit 0 even when the work failed are a trap.

Bonus points for a tool that tells the agent what to do next. That’s rare, and it’s where apidog-cli stands out.

Claude Code

Claude Code is Anthropic’s coding agent that runs in your terminal. Add -p (print mode) to any command and it runs the full agent loop non-interactively, prints a result, and exits; no terminal UI, nothing to click.

npm install -g @anthropic-ai/claude-code
claude -p "summarize the failing tests in this repo" --output-format json

The --output-format json flag returns a structured payload with the result, a session_id, and total_cost_usd, so a scripted caller can track spend per invocation. There’s also stream-json for real-time event streaming (it needs --verbose). You can pipe input in too: cat build-error.txt | claude -p 'explain this error'.

Best at: multi-step coding tasks where one agent plans and executes, then hands you (or another script) machine-readable output.

Honest limits: it’s a paid, closed model behind an API, and cost adds up on long autonomous runs.

Codex CLI

Codex CLI is OpenAI’s open-source terminal agent. The codex exec subcommand (aliased codex e) runs it non-interactively and streams results to stdout.

npm install -g @openai/codex
codex exec --json "add input validation to the signup handler"

The --json flag switches stdout to a JSONL stream where every event (command runs, file changes, agent messages) is a structured object you can pipe through jq. For automation that needs stable fields, --output-schema makes the final response conform to a JSON Schema you supply, which is handy for job summaries or release metadata.

Best at: CI-driven code changes where you need typed, schema-validated output at the end of a run.

Honest limits: the JSONL event stream is verbose; you’ll do real jq work to extract just the parts you care about. Schema-constrained output is newer and worth testing on your actual prompts.

Gemini CLI

Gemini CLI is Google’s open-source terminal agent. It drops into headless mode automatically in a non-TTY environment, or when you pass a prompt with -p / --prompt.

npm install -g @google/gemini-cli
gemini --non-interactive --output-format json -p "list the public endpoints in this service"

The --output-format json flag returns a single JSON object with the response and usage stats; there’s a JSONL variant for streaming events. The --non-interactive flag guarantees it never stops for a prompt, which is exactly what you want inside a pipeline. Pair it with jq to pull the response field cleanly.

Best at: agents already living in a Google-tooled environment, and read-heavy tasks like summarizing or inspecting a codebase.

Honest limits: structured JSON output arrived later than in some rivals, so pin your version and confirm the flags behave as documented before you depend on them.

Cursor CLI

Cursor’s cursor-agent brings its coding agent to the terminal, fully separate from the editor. Use -p / --print to run it headless with no interactive UI: a prompt in, a result out.

curl https://cursor.com/install -fsS | bash
cursor-agent -p "refactor utils/date.js to use date-fns" --output-format json

The --output-format option takes text, json, or stream-json. The json format emits a single object when the run completes, with tool events collapsed and text aggregated into the final result. In headless contexts you’ll want --trust so the agent can use its write and shell tools without stopping to ask.

Best at: teams standardized on Cursor who want the same agent in CI and git hooks that they use in the editor.

Honest limits: the community has reported the headless -p mode hanging on some builds and platforms, so test it against your target OS and pin a known-good version. Keep it on a least-privilege token and review its changes.

gh (GitHub CLI)

gh is the tool an agent reaches for whenever the task touches a repo, issue, PR, or release. Its --json flag is the reason it’s here.

brew install gh
gh pr list --json number,title,author --jq '.[].author.login'

Pass --json a list of field names and you get exactly those fields as JSON; leave the value off and it prints the available fields, so an agent can discover the schema. The built-in --jq flag filters that output without needing jq installed separately. And when gh detects its output is piped, it drops human formatting for tab-delimited machine output automatically. For anything not covered by a subcommand, gh api runs any REST or GraphQL call and hands back decoded JSON.

Best at: any GitHub operation in an agent workflow, from reading PR state to opening issues.

Honest limits: it’s GitHub-only, and the field names available to --json vary by subcommand, so an agent has to check per command.

ripgrep

ripgrep (rg) is how an agent finds things in a codebase fast. The agent-relevant flag is --json, which emits structured match events instead of the usual grep-style lines.

brew install ripgrep
rg --json "TODO" src/ | jq 'select(.type=="match") | .data.path.text'

Each match, along with begin/end and summary events, comes out as a separate JSON object with the file path, line number, and matched text as typed fields. That’s far safer for an agent than splitting file:line:text strings, which fall apart on paths or code containing colons.

Best at: fast, structured code search across large repos before the agent decides what to edit.

Honest limits: --json output is verbose and needs jq to be useful; for a quick one-off search the plain text mode is simpler.

jq

jq is the glue. Nearly every tool above emits JSON, and jq is how an agent slices, filters, and reshapes it before acting. It’s a small, single-purpose binary that does one thing extremely well.

brew install jq
curl -s https://api.github.com/repos/cli/cli | jq '{name, stars: .stargazers_count}'

Because jq is deterministic and streaming, it fits cleanly into an agent’s shell pipeline: take JSON from one tool, extract the two fields the agent needs, feed them to the next command. It exits non-zero on a parse error, so a broken upstream response surfaces instead of passing silently.

Best at: transforming any tool’s JSON into just the shape the agent’s next step expects.

Honest limits: the query language has a learning curve, and it processes JSON only, so pair it with the tools above rather than pointing it at raw logs.

HTTPie

When an agent needs to call an HTTP API directly, HTTPie (http) is friendlier than raw curl. It speaks JSON by default: fields on the command line become a JSON request body, and responses are parsed for you.

brew install httpie
http --print=b POST httpbin.org/post name=apidog role=cli

The --print flag controls exactly what lands on stdout (b for body only), which matters when an agent wants to parse the response without stripping headers first. Because request fields are key=value pairs, an agent can build a request programmatically without hand-assembling a JSON string. curl is the more universal fallback, but HTTPie’s JSON-first defaults are easier for an agent to drive.

Best at: quick, scriptable one-off API calls where JSON in and JSON out is the norm.

Honest limits: it’s an extra dependency where curl is already everywhere, and for streaming or exotic protocols curl still wins.

apidog-cli

Most tools on this list were built for humans and later grew a --json flag. apidog-cli is different: its output is structured JSON by design, and it goes one step further by including agentHints.nextSteps in responses; the tool literally tells the calling agent what it can do next. That’s the property the other CLIs don’t have.

It’s a full API-project CLI, not just a test runner. One binary manages endpoints, schemas (data models), mocks, environments, imports and exports, docs, test scenarios, and branches. Install it and authenticate:

npm install -g apidog-cli
apidog login --with-token <YOUR_TOKEN>
apidog run --help

For the agent-fit properties that matter here: apidog run exits 0 when every test passes and non-zero on any failure, so an agent branches on the exit code with no output parsing at all. The JSON responses carry those next-step hints, so an agent orchestrating a workflow can chain commands without a human mapping the sequence. This is why the tool shows up across the agent series: Apidog CLI in Claude Code, Apidog CLI in Codex, and Apidog CLI in Cursor all lean on the same structured output.

There’s one more agent-safety feature worth calling out. An agent with write access to a live API project can overwrite or delete real endpoints and schemas. Apidog’s AI Branch (apidog branch --type ai) gives the agent an isolated branch to edit; the source branch stays untouched, and nothing lands until you approve a merge request. See AI Branch for AI agents for the full pattern, and building an AI-agent test harness plus Apidog CLI in AI-agent workflows for how it fits a pipeline.

Best at: giving an agent a single, JSON-native tool for the whole API lifecycle, with hints and a safe editing sandbox built in.

Honest limits: Apidog isn’t open source; it’s a commercial product with a free tier, so it’s a different kind of choice than a single-purpose MIT binary like jq or ripgrep. And it has no OpenAPI linter, so pair it with Spectral or Redocly if style enforcement is part of your flow.

How to choose

There’s no single winner. The runtimes are the agent; the tools are what it holds. Match the tool to the job.

Tool Best for Install Open source? Agent-fit note
Claude Code Multi-step coding, planning npm i -g @anthropic-ai/claude-code No -p + --output-format json, cost in output
Codex CLI Schema-typed CI code changes npm i -g @openai/codex Yes codex exec --json, --output-schema
Gemini CLI Google-stack, read-heavy tasks npm i -g @google/gemini-cli Yes --non-interactive --output-format json
Cursor CLI Cursor teams, editor-to-CI parity curl cursor.com/install | bash No -p --output-format json, test headless
gh Any GitHub operation brew install gh Yes --json fields + built-in --jq
ripgrep Fast structured code search brew install ripgrep Yes --json typed match events
jq Reshaping any tool’s JSON brew install jq Yes Deterministic, pipeline glue
HTTPie Scriptable JSON API calls brew install httpie Yes JSON-first, --print control
apidog-cli Full API lifecycle for agents npm i -g apidog-cli No (free tier) Native JSON + agentHints.nextSteps

Pick one runtime to drive the work, then give it a small kit of the tool CLIs. For anything that touches your APIs, the honest pitch is that stitching curl, a mock server, and a test runner together works, but a JSON-native CLI that already knows the next step removes a lot of glue code.

Wrapping up

Agent-fit isn’t a marketing word; it’s three concrete properties. Structured output the agent can parse, a non-interactive mode that never hangs, and exit codes it can branch on. The runtimes (Claude Code, Codex CLI, Gemini CLI, Cursor CLI) bring the reasoning; the tool CLIs (gh, ripgrep, jq, HTTPie, apidog-cli) do the work.

apidog-cli earns its spot by starting where the others end up: JSON by default, exit codes you can trust, and next-step hints the agent reads directly. If your agent’s job touches APIs, download Apidog and try the CLI, or start with the Apidog CLI complete guide. Wire it into your CI next; that’s where agent-native output pays for itself.

Explore more

Free Open-Source CLI Tools for API Management

Free Open-Source CLI Tools for API Management

Five free, open-source API management gateways you can run from the terminal: Kong OSS with decK, Tyk, KrakenD, Apache APISIX, and Gravitee, with real commands.

10 July 2026

How to Document APIs From the CLI

How to Document APIs From the CLI

Learn how to document APIs from the command line: build HTML with Redocly CLI, Markdown with Widdershins, then export live docs with the Apidog CLI in CI.

10 July 2026

How to Design APIs From the CLI

How to Design APIs From the CLI

Design APIs from the terminal: author OpenAPI, lint with Spectral, bundle with Redocly, generate stubs, then use the Apidog CLI for schemas and auth.

10 July 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs

Top CLI tools for AI agents