Building CLIs for AI Agents
- Source
- x.com
- Author
- eric zakariasson
- Date

Context
A command-line tool used by an should make missing information recoverable without requiring an interactive menu. Eric Zakariasson's design guide recommends accepting inputs as command options or piped data, and returning an actionable error when required information is absent.
That lets the agent correct the command and try again. Retries introduce another requirement: repeating a successful operation should not accidentally create a duplicate. Zakariasson recommends repeat-safe behavior and returning concrete results, such as an operation identifier and destination URL. Together, these choices make the tool's state easier for an automated caller to understand.
- Do not dump the full manual up front. Let the top-level command list subcommands and make the agent drill into the one it picked, so it spends no reading about commands it will never run.
- Examples do most of the work in a help page. An agent pattern-matches off a full sample invocation faster than it reads a prose description of each flag.
- Pick one naming pattern — resource then verb — and apply it everywhere. An agent that learns one command can then guess the ones it has never seen instead of hunting through help output.
- Return usable data on success, like the deploy ID and the URL. Agents chain commands, so the output of one is the input of the next. Emoji and celebration text are noise in that pipeline.
- AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
- context window — The maximum amount of text a model can consider at once — its working memory for the current conversation or task.
“Most CLIs were built assuming a human is at the keyboard.”
“An agent pattern-matches off mycli deploy --env staging --tag v1.2.3 faster than it reads a description.”
“Most of the work is just making explicit what humans figured out implicitly!”
Checking sign-in…
Loading comments…


