Building CLIs for AI Agents: Design Principles from Google's gws CLI

Why Agent-First CLI Design Matters
Human developer experience (DX) optimizes for discoverability and forgiveness, while agent DX requires predictability and defense-in-depth. The article argues that retrofitting human-first CLIs for agents is ineffective, and demonstrates this through Google's gws CLI for Google Workspace, which was designed from day one with AI agents as the primary consumers.
Key Design Principles
Raw JSON Payloads Over Bespoke Flags: Humans prefer simple flags like --title "My Doc", but agents work better with direct JSON payloads that map to API schemas without translation loss.
Example comparison:
Human-first (10 flags, flat namespace): my-cli spreadsheet create --title "Q1 Budget" --locale "en_US" --timezone "America/Denver" --sheet-title "January" --sheet-type GRID --frozen-rows 1 --frozen-cols 2 --row-count 100 --col-count 10 --hidden falseAgent-first (one JSON flag): gws sheets spreadsheets create --json ' { "properties": {"title": "Q1 Budget", "locale": "en_US", "timeZone": "America/Denver"}, "sheets": [{"properties": {"title": "January", "sheetType": "GRID", "gridProperties": {"frozenRowCount": 1, "frozenColumnCount": 2, "rowCount": 100, "columnCount": 10}, "hidden": false}}] }'
The gws CLI uses --params and --json flags for all inputs, accepting full API payloads directly. The recommended approach is to support both paths in the same binary rather than maintaining separate tools.
Additional Considerations
The article outlines several other design considerations for agent-first CLIs:
- Schema Introspection: Self-describing schemas that agents can introspect at runtime
- Context Window Discipline: Managing output to fit within agent context limits
- Input Hardening: Protection against agent hallucinations
- Agent Skills: Shipping capabilities rather than just commands
- Multi-Surface Support: Working with MCP, extensions, and environment variables
- Safety Rails: Dry-run modes and response sanitization
CLIs are becoming the lowest-friction interface for AI agents to interact with external systems, requiring deterministic, machine-readable output rather than human-oriented interfaces.
📖 Read the full source: HN AI Agents
👀 See Also

Jan Adds One-Click OpenClaw Installation with Jan-v3-Base Model Integration
Jan now supports one-click installation of OpenClaw with direct integration to the Jan-v3-base model, keeping all operations local and private on your computer.

Calmkeep: An External Continuity Layer to Counter LLM Drift in Extended Sessions
Calmkeep is an external continuity layer designed to counteract LLM drift in extended sessions, showing 85% integrity vs 60% for standard Claude in a 25-turn backend build test and 100% vs 50% in a legal session.

Video Editor Builds Free Transcription Tool Treelo Using Claude Code
A video editor created Treelo, a free web tool that transcribes audio/video files into editable timestamp blocks with caption presets and exports to SRT, VTT, ASS, and WAV formats. The tool was built through iterative conversations with Claude Code.

80-line Python script uses Claude to auto-generate internal link suggestions, cuts linking time from 2 hours to 8 minutes
A Reddit user built an 80-line Python script that feeds an article draft and sitemap to Claude, returning relevant internal link targets with suggested anchor text — reducing manual linking time from 2 hours to 8 minutes per article.