agentleFS
Google CloudKnown publisherGoogleCloudPlatform/vertex-ai-creative-studio/experiments/mcp-genmedia/skills/agent-aware-cli/SKILL.md

agent-aware-cli

Skill1.2k starsChanged 9 days agoApache-2.0View on GitHub

Guide for designing and implementing command-line interfaces (CLIs) that are equally usable by human developers and automated coding agents. Use when the user wants to build a CLI, apply CLI best practices, or use Go with Cobra and Viper.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projectsWeek of Oct 25: 0 new projectsWeek of Nov 1: 0 new projects
Sep 2026Oct 2026Nov 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Most recently taken up by

Who's talking about GoogleCloudPlatform/vertex-ai-creative-studio

The biggest 5 of 51 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 51

Talked about on GitHub and Bluesky (51 times).

On GitHub · 50

45 more on GitHub

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 11 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When tasked with building or improving a Command Line Interface (CLI), follow these architectural and design best practices to ensure it …

    line 8
  2. Very specific:

    Never dump unpaginated or unfiltered lists to stdout.

    line 22
  3. Distinctive:

    Don't just report failures.

    line 32
  4. Distinctive:

    Avoid maintaining long-running state loops within the CLI if orchestrating complex workflows.

    line 36
  5. Very specific:

    Use a stateless task identifier pattern (--task <ID>, --ref <ID>).

    line 37
  6. Distinctive:

    Add an AGENTS.md or GEMINI.md file at the repository root explaining the tool's usage, workflows, and standards for AI developers.

    line 40
  7. Distinctive:

    When building a CLI against a large Google/REST API, analyze its Discovery Document (e.g.

    line 44
  8. Distinctive:

    Consider auto-generating the base commands directly from the Discovery Document to guarantee 100% API coverage.

    line 45
  9. Distinctive:

    When implementing a CLI in Go, use Cobra for command routing and Viper for configuration management.

    line 50
  10. Very specific:

    XDG Compliance: Follow the XDG Base Directory Specification for configuration files (e.g., ~/.config/app/config.yaml).

    line 61
  11. Very specific:

    Smart Fallbacks Priority: Use Viper to ensure values resolve in this consistent order: Command Line Flag > Environment Variable > Config …

    line 62
  12. Distinctive:

    Secrets Management: Never allow API keys to leak into shell history.

    line 64
  13. Distinctive:

    When optimizing the CLI for human readability, draw on Tufte-inspired principles to minimize cognitive load:

    line 68
  14. Very specific:

    Resilient UI Formatting: Always apply padding and width enforcement to raw strings *before* applying terminal styling (e.g., with lipgloss).

    line 70
  15. Distinctive:

    Semantic Color Tokens: Use specific functional colors rather than aesthetic ones:

    line 72
  16. Very specific:

    Color Degradation: Ensure colors degrade gracefully when piped to a file, when --json is invoked, or when NO_COLOR is present.

    line 80
  17. Distinctive:

    When generating or updating a CLI command, you MUST ensure all of the following are implemented on your first pass.

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Agent-Aware CLI Design Guidelines

When tasked with building or improving a Command Line Interface (CLI), follow these architectural and design best practices to ensure it serves both human operators (with rich TUIs) and AI agents (with deterministic, machine-readable output).

Core Principles

  1. The Dual-Experience Paradigm (DX & AX) This CLI must be designed as a "Dual-Mode" interface, treating both humans and AI agents as first-class users.
    • DX (Developer Experience): Ergonomics for human operators. Emphasizes discoverability, rich TUIs (e.g., Bubbletea, Lipgloss), semantic coloring, and intuitive aliases.
    • AX (Agent Experience): Ergonomics for autonomous AI agents. Emphasizes determinism, strict machine-readable output modes (e.g., --json), headless authentication, aggressive data scoping (limits/filtering), and mutative safety (--dry-run).
    • Environment Overrides: Respect NO_COLOR and [APP]_NO_TUI environment variables to automatically fall back to non-interactive, unstyled modes.
  2. Headless-Friendly Authentication
    • Agents cannot complete interactive, browser-based OAuth flows. CLIs must either support headless auth methods (Service Accounts, API Keys via ENV vars, --token flags) OR immediately fail with a clear, machine-readable error instructing the human operator to authenticate manually first.
  3. Sane Defaults & Aggressive Filtering
    • Never dump unpaginated or unfiltered lists to stdout. Default to sensible limits (e.g., top 10 items). Provide rich filtering flags (e.g., --status, --mine, --limit) so agents can surgically query exactly what they need without blowing out their token context.
  4. Mutative Safety (--dry-run)
    • For commands that create, update, or delete external state, implement a --dry-run flag. This allows an autonomous agent to test its parameter mapping and validate the resulting payload locally before executing the destructive action.
  5. Context Window Protection
    • Agents have limited context windows. Actively truncate massive text blobs, sort critical action items to the top, and mask raw credentials by default to prevent credential leakage.
    • Provide opt-in verbosity (e.g., --full or --verbose) for agents or humans who explicitly request unfiltered data.
  6. Executable Proactive Error Hints
    • Don't just report failures; provide the exact steps to fix them.
    • Inject copy-pasteable terminal commands into stderr (e.g., Hint: run 'app init' to create a database). This enables autonomous agents to parse the error and self-correct seamlessly.
  7. Delegated State Management
    • Avoid maintaining long-running state loops within the CLI if orchestrating complex workflows.
    • Use a stateless task identifier pattern (--task <ID>, --ref <ID>). Pass the ID back to the backend service, which maintains the token context window and conversation history.
  8. Externalized Agent Instructions
    • Add an AGENTS.md or GEMINI.md file at the repository root explaining the tool's usage, workflows, and standards for AI developers.
    • Provide an agentskills.io compliant skills/ directory with SKILL.md files for complex subcommands.
  9. API Discovery & Progressive Convenience
    • When building a CLI against a large Google/REST API, analyze its Discovery Document (e.g. https://youtube.googleapis.com/$discovery/rest?version=v3) to understand the exact, strict mappings of resources, methods, query parameters, and required OAuth scopes.
    • Consider auto-generating the base commands directly from the Discovery Document to guarantee 100% API coverage.
    • However, raw REST mappings are often un-ergonomic for humans. You must layer "Convenience Wrappers" or "Hints" on top of the raw generated commands. For example, if a user asks to "list videos for a user", the CLI should intelligently abstract away the fact that it takes two API calls (one to resolve the handle to a Channel ID, and another to fetch the playlist) under a single channel videos @user command.

Implementation with Go (Cobra & Viper)

When implementing a CLI in Go, use Cobra for command routing and Viper for configuration management.

Cobra Practices

  • Structured Discoverability: Prevent a "wall of text" in the root help output by using Cobra's GroupID to categorize commands (e.g., Task Management, Information).
  • The Three Pillars of Documentation: Populate these fields for every command:
    • Short: A 5-10 word summary starting with an action verb for quick scanning.
    • Long: Detailed explanation of what it does, why, and its differentiation.
    • Example: 3-5 concrete, copy-pasteable examples showing common flag combinations.
  • Fail Fast Hooks: Validate configuration and connectivity in PersistentPreRun hooks before executing heavy logic.

Viper & Configuration Practices

  • XDG Compliance: Follow the XDG Base Directory Specification for configuration files (e.g., ~/.config/app/config.yaml).
  • Smart Fallbacks Priority: Use Viper to ensure values resolve in this consistent order: Command Line Flag > Environment Variable > Config File > Default Value
  • Secrets Management: Never allow API keys to leak into shell history. Prefer environment variables over CLI flags for secrets.

Visual Information Design (Human Mode)

When optimizing the CLI for human readability, draw on Tufte-inspired principles to minimize cognitive load:

  • Maximize Data-Ink Ratio: Minimize non-essential "ink" like decorative borders. Use whitespace and positioning as the primary tools for conveying hierarchy.
  • Resilient UI Formatting: Always apply padding and width enforcement to raw strings before applying terminal styling (e.g., with lipgloss). Invisible ANSI escape codes can otherwise corrupt fmt.Printf table alignments.
  • The ANSI Alignment Gotcha: When building TUI tables in Go, native tools like text/tabwriter or fmt.Printf will break alignment if you pass strings containing invisible ANSI color codes. You MUST pad strings to their fixed widths before applying color wrappers, or use a robust layout engine like lipgloss.Table.
  • Semantic Color Tokens: Use specific functional colors rather than aesthetic ones:
    • Accent (Blue): Navigation landmarks, headers, group titles.
    • Command (Grey/Light Grey): Scan targets like command names and flags.
    • Pass (Green): Success states and completed tasks.
    • Warn (Orange/Yellow): Transient or pending states, warnings.
    • Fail (Red): Errors and rejected states.
    • Muted (Dark Grey): De-emphasis for metadata, types, or defaults.
    • ID (Teal/Mint): Unique identifiers.
  • Color Degradation: Ensure colors degrade gracefully when piped to a file, when --json is invoked, or when NO_COLOR is present.

Mandatory Implementation Checklist for Agents

When generating or updating a CLI command, you MUST ensure all of the following are implemented on your first pass. Do not treat UI/UX as an afterthought:

  • Dual-Experience (DX/AX): Does the command support a --json flag or respect NO_COLOR/[APP]_NO_TUI?
  • Headless Auth: Can an agent run this command autonomously without hanging on a browser-based OAuth prompt?
  • Data Scoping: If returning a list, are there sane default limits and filtering flags (e.g., --limit, --status)?
  • Mutative Safety: If the command mutates state, does it include a --dry-run flag for agent safety?
  • Error Hints: Do errors print actionable, copy-pasteable terminal commands to stderr?
  • XDG Compliance: Is configuration handled via the XDG Base Directory specification (e.g. ~/.config/app/config.yaml) instead of local .env files?
  • The Three Pillars: Are Short, Long, and Example fields fully populated in the Cobra command definition?
  • Discoverability: Is the command assigned to a logical GroupID?
  • Semantic Colors: Is the human-readable output formatted using the semantic color tokens (e.g., Lipgloss)?
  • Alignment Safety: If using raw ANSI colors in tables, is string padding applied before the color codes to prevent alignment breaking?
  • Help Formatting: Have you overridden Cobra's default SetUsageTemplate to apply semantic colors to the help output itself (e.g., coloring headers blue)?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.