Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

agent-cli

БесплатноБез исполняемых скриптовНе проверен

Design and review CLIs for AI agent consumption. Covers machine-readable output, input hardening against hallucinations, schema introspection, context window…

Roasbeefот Roasbeef★ 33 звезды на GitHub

Об этом скилле

Agent-First CLI Design

Design CLIs where AI agents are first-class consumers alongside humans. Human DX optimizes for discoverability and forgiveness. Agent DX optimizes for predictability and defense-in-depth. Both can coexist in the same binary, but agent ergonomics must be intentionally designed — they do not emerge from human-first defaults.

When to Use

  • Building a new CLI that agents will invoke
  • Adding agent support to an existing human-first CLI
  • Reviewing CLI designs for agent compatibility
  • Wrapping REST/gRPC APIs as CLI tools
  • Writing CONTEXT.md, AGENTS.md, or skill files for a CLI

When NOT to Use

  • Pure library/SDK design (no CLI surface)
  • GUI or TUI-only applications
  • Internal scripts not exposed to agents

Core Principle

The agent is not a trusted operator. Treat agent-generated CLI input with the same suspicion as untrusted user input to a web API. Agents hallucinate with high confidence — they generate plausible but wrong paths, IDs, and parameters. The CLI must be the last line of defense.

Multi-Surface Architecture

A well-designed agent-first CLI serves multiple interfaces from a single binary and source of truth (e.g., a Discovery Document or OpenAPI spec).

graph TD
    Source[Discovery Document / OpenAPI] --> Core[Core Binary Logic]
    Core --> Human[Human CLI (Terminal)]
    Core --> MCP[MCP Server (stdio)]
    Core --> Ext[Agent Extension (Native)]
    Core --> Env[Env Vars (Headless)]
  • Human CLI: Interactive, colorful, lenient flags (--title "Doc").
  • MCP Server: Typed JSON-RPC over stdio, auto-generated tools from schema.
  • Agent Extension: Native capability installation (e.g., Gemini Extensions).
  • Env Vars: Headless auth and config injection (MYCLI_TOKEN).

Design Checklist

When building or reviewing an agent-facing CLI, verify each of the following areas. Address them in priority order — earlier items have higher impact per effort.

1. Machine-Readable Output

Machine-readable output is table stakes. Without it, agents must parse human-formatted tables and colored text, which is fragile and lossy.

Requirements:

  • Support --output json (or -o json) on every command that produces output
  • Set JSON as default when stdout is not a TTY (if ! [ -t 1 ]; then output=json; fi)
  • Alternatively, respect OUTPUT_FORMAT=json environment variable
  • Emit structured error objects on stderr, not prose messages

Go implementation pattern:

type OutputFormat string

const (
    OutputHuman OutputFormat = "human"
    OutputJSON  OutputFormat = "json"
)

func detectFormat(cmd *cobra.Command) OutputFormat {
    if f, _ := cmd.Flags().GetString("output"); f == "json" {
        return OutputJSON
    }
    if os.Getenv("OUTPUT_FORMAT") == "json" {
        return OutputJSON
    }
    if !term.IsTerminal(int(os.Stdout.Fd())) {
        return OutputJSON
    }
    return OutputHuman
}

Error output pattern:

{"error": {"code": "INVALID_RESOURCE_ID", "message": "resource ID contains query parameters", "field": "file-id", "value": "abc123?fields=name"}}

Avoid mixing human-readable and machine-readable output in the same stream. Diagnostics, progress bars, and warnings go to stderr. Structured results go to stdout.

2. Input Hardening Against Hallucinations

Agents hallucinate differently than humans typo. These are the failure modes to defend against, ranked by frequency:

Input Type Human Failure Agent Failure Defense
File paths Misspelling Path traversal (../../.ssh/id_rsa) Canonicalize, sandbox to CWD
Resource IDs Typos Embedded query params (id?fields=name) Reject ?, #, %
Strings Copy-paste garbage Invisible control characters Reject bytes below ASCII 0x20
URLs/paths Spaces in names Pre-encoded strings (%2e%2e) Reject % in IDs, encode at HTTP layer
JSON payloads Syntax errors Structurally valid but semantically wrong Validate against schema

Go validation functions:

// validateResourceID rejects IDs that contain query parameters or encoding.
func validateResourceID(id string) error {
    for _, c := range id {
        switch {
        case c == '?' || c == '#':
            return fmt.Errorf("resource ID contains query character %q", c)
        case c == '%':
            return fmt.Errorf("resource ID contains percent-encoding")
        case c < 0x20:
            return fmt.Errorf("resource ID contains control character 0x%02x", c)
        }
    }
    return nil
}

// validateSafeOutputDir ensures the path resolves within the working directory.
func validateSafeOutputDir(path string) (string, error) {
    abs, err := filepath.Abs(path)
    if err != nil {
        return "", err
    }
    cwd, err := os.Getwd()
    if err != nil {
        return "", err
    }
    if !strings.HasPrefix(abs, cwd) {
        return "", fmt.Errorf("path %q escapes worki
Полный SKILL.md на GitHub

Установить agent-cli в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл agent-cli?

Design and review CLIs for AI agent consumption. Covers machine-readable output, input hardening against hallucinations, schema introspection, context window discipline, dry-run safety rails, and skill file packaging. Use when building new CLIs, adding agent support to existing CLIs, reviewing CLI designs for agent compatibility, or wrapping APIs as CLI tools. Triggers: agent CLI, CLI for agents, machine-readable CLI, agent-first CLI, CLI agent DX.

Как установить скилл agent-cli?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл agent-cli запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить agent-cli с