Building CLIs for AI Agents Cheat Sheet

This content was generated with the assistance of AI and should be verified against the official documentation of each tool and framework before being relied on in production.

This section’s bibliography lists the reference material consulted while preparing these pages.

A single-page index of quick back-links to every page in this sub-section, grouped the same way as the sub-section itself — handy for jumping straight to the topic you need instead of paging through the full navigation.

The downloadable PDF is a separate, single A4 page meant for printing. It states the version baseline this sub-section targets — Python 3.12 with Typer 0.27.2, Java 21 with picocli 4.7.7, Node.js 24 with commander 15.0.0, Cobra v1.10.2, clap 4.6.7, swift-argument-parser 1.8.2, System.CommandLine 2.0.12, FastMCP 4.0.10, Spring AI 2.0.1 and the MCP specification revision 2026-07-28, all checked on 2026-09-30 — and covers:

  • the design rules;

  • the exit-code table of the docsctl running example;

  • the streams rule (data on stdout, messages on stderr);

  • the TTY and colour rules;

  • the configuration precedence;

  • the JSON output contract;

  • the agent-ergonomics rules;

  • the safety pattern (dry-run, confirmation, idempotency);

  • CLI versus MCP;

  • the wrapping snippets (Python, TypeScript and Spring AI);

  • the injection-defence rules;

  • the frameworks-per-language table;

  • the packaging table;

  • the testing checklist.