# The agent-native standard Source: https://anc.dev/ Canonical-Markdown: https://anc.dev/index.md # The agent-native standard One bar for agent-readiness, measured on two surfaces: your CLI and your website. Scored MUST / SHOULD / MAY, not asserted. CLI tools are how AI agents touch everything else. Compilers, databases, git, the cloud, the shell. An agent asked to ship code, rotate a credential, grep a log, or deploy a branch frequently shells out to a binary. It's the lowest-common-denominator interface where APIs don't exist or don't compose. The agent reads the output, decides what went right or wrong, and picks the next move. There is no human between the request and the process. The CLI either makes that loop tractable or it does not. The same holds for the websites and MCP servers agents reach over HTTP: they either expose a machine-readable, discoverable surface or they force the agent to scrape blind. This site measures agent-readiness on both surfaces, CLI and web, against one set of eight principles. This is the specification for CLIs that make it tractable. Eight principles, each expressing a requirement with [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) tiers: **MUST** for the contract, **SHOULD** for the default, **MAY** for the optional affordance. The companion linter, [`anc`](https://anc.dev/audit), scores any CLI against them and reports results by stable audit ID (`p1-non-interactive`, `p2-json-output`, `p6-sigpipe`, …). Cite a principle by its anchor slug (`#p1-non-interactive-by-default` through `#p8-discoverable-skill-bundle`); those are permanent. Each of the eight principles below has its own page (`/p1` through `/p8`) for deep-linking, and the same text is available as raw markdown at `/p1.md` … `/p8.md` for agent consumption. The entire spec as one file lives at [`/llms-full.txt`](https://anc.dev/llms-full.txt); a curated index for retrieval-heavy agents lives at [`/llms.txt`](https://anc.dev/llms.txt). For the standard applied at scale, see the [**ANC 100 leaderboard**](https://anc.dev/scorecards) (100 widely-used CLI tools, scored against the same eight principles). The scoring methodology and per-field schema for the underlying JSON live at [`/methodology`](https://anc.dev/methodology) and [`/scorecard-schema`](https://anc.dev/scorecard-schema). To audit a CLI, install the linter (`anc`) locally: see [/install](https://anc.dev/install). To audit a website and its MCP server, use [/audit](https://anc.dev/audit) or the `audit_website` MCP tool. To install the agent-native-cli **skill bundle** (the Claude Code / Codex / Cursor / OpenCode skill), see [/skill](https://anc.dev/skill). Agents that speak MCP can connect directly to the streamable-HTTP server at [https://anc.dev/mcp](https://anc.dev/mcp) (`GET` returns 405; clients `POST`). See [/mcp-docs](https://anc.dev/mcp-docs) for the endpoint description and [/mcp-skill](https://anc.dev/mcp-skill) for the wire contract and tool catalog. --- # P1: Non-Interactive by Default Source: https://anc.dev/p1 Canonical-Markdown: https://anc.dev/p1.md # P1: Non-Interactive by Default ## Definition Every automation path MUST run without human input. A CLI tool that blocks on an interactive prompt is invisible to an agent: the agent hangs, the user sees nothing, and the operation times out silently. ## Why Agents Need It An agent calling a CLI cannot type. When the tool prompts for a confirmation or a credential, the agent's process stalls until timeout: no tokens recovered, no structured signal that interaction was requested, and no way to distinguish "waiting for input" from "still processing." Interactive prompts in automation paths are a leading cause of agent-tool deadlock. ## Requirements **MUST:** - Every flag settable via environment variable. Use a falsey-value parser for booleans so that `TOOL_QUIET=0` and `TOOL_QUIET=false` correctly disable the flag rather than being treated as truthy non-empty strings. In Rust / clap: ```rust #[arg(long, env = "TOOL_QUIET", global = true, value_parser = FalseyValueParser::new())] quiet: bool, ``` - When stdin is not a TTY, or when `--no-interactive` is set, every blocking-input surface (prompt libraries, read-line calls, TUI session initialization) resolves from defaults, reads from stdin, or exits non-zero with an actionable error. The tool MUST NOT block waiting for input that cannot arrive. - *(Applies when: CLI authenticates against a remote service.)* A headless authentication path. The canonical flag is `--no-browser`, which triggers the OAuth 2.0 Device Authorization Grant ([RFC 8628](https://www.rfc-editor.org/rfc/rfc8628)): the CLI prints a URL and a code; the user authorizes on another device. Agents cannot open browsers. Non-canonical alternatives (`--device-code`, `--remote`, `--headless`) are acceptable but SHOULD migrate toward `--no-browser`. - *(Applies when: CLI accepts secret material as input.)* At least one input path that does not leak the secret into process listings, shell history, or the parent environment. The two leak-resistant paths are stdin and a `--*-file` flag pointing at a credential file. Flag-value forms (`--token `) and environment variables (`TOOL_TOKEN`) MAY exist as convenience surfaces but MUST NOT be the only programmatic path. Cloud-CLI env-var conventions (`AWS_ACCESS_KEY_ID`, `GH_TOKEN`) count as convenience paths under this rule, not as substitutes for it. A CLI whose only secret-input path is `--password ` leaks the secret into `ps` output on every invocation. **SHOULD:** - Auto-detect non-interactive context via TTY detection on stdin (and stderr, where prompts target it) and suppress prompts when no terminal is present, even without an explicit `--no-interactive` flag. Language-specific entry points: `std::io::IsTerminal` in Rust 1.70+, `process.stdin.isTTY` in Node, `sys.stdin.isatty()` in Python. - Document default values for prompted inputs in `--help` output so agents can pass them explicitly instead of accepting whatever default ships. **MAY:** - Offer rich interactive experiences (spinners, progress bars, multi-select menus) when a TTY is detected and `--no-interactive` is not set, provided the non-interactive path remains fully functional. ## Scope "Agent" in this specification means a process invoking the CLI as a subprocess. This spec's automated audits verify behavior under non-TTY stdin. TTY-driving agents (tmux panes, `ssh -t` sandbox shells, `expect` automation, computer-use desktop agents) are affected by the same MUSTs, but `anc` currently does not allocate a PTY during verification. Pass verdicts for TTY-driving-agent scenarios are probable-but-not-verified; see [/coverage](https://anc.dev/coverage) for the gap. ## Evidence - `--no-interactive` flag in the CLI struct with an env-var binding. - Boolean env vars parsed with a falsey-value parser (not the default string parser). - TTY guard wrapping every `dialoguer`, `inquire`, or equivalent prompt call. - `--no-browser` flag present on authenticated CLIs. - `env = "TOOL_..."` attribute on every flag that takes user input. - A stdin or `--*-file` path for every secret-accepting flag, present alongside (not instead of) any convenience flag-value or env-var alternative. ## Anti-Patterns - Bare `dialoguer::Confirm::new().interact()` with no TTY check and no `--no-interactive` override — agents hang indefinitely. - Boolean environment variables parsed as plain strings, so `TOOL_QUIET=false` is truthy because the string is non-empty. - `stdin().read_line()` in a code path reached during normal operation without a TTY check first. - Hard-coded credentials prompts with no env-var or config-file alternative. - OAuth flow that unconditionally opens a browser with no headless escape hatch. - A `--password ` flag with no stdin or file alternative — every invocation leaks the secret into process listings. Measured by audit IDs `p1-env-hints`, `p1-env-flags-source`, `p1-non-interactive`, `p1-flag-existence`, `p1-non-interactive-source`, `p1-headless-auth`, `p1-secret-non-leaky-path`, `p1-tty-detection-source`, `p1-defaults-in-help`, `p1-rich-tui`. Run `anc audit --principle 1 .` against the CLI under test to see each. --- # P2: Structured, Parseable Output Source: https://anc.dev/p2 Canonical-Markdown: https://anc.dev/p2.md # P2: Structured, Parseable Output ## Definition CLI tools MUST separate data from diagnostics and offer machine-readable output formats. Mixing status messages with data forces agents into fragile regex extraction that breaks on any format change. ## Why Agents Need It An agent calling a CLI needs three things from each invocation: the data, the error (if any), and the exit code. When data goes to stdout, diagnostics go to stderr, and errors carry machine-readable fields, the agent parses the result reliably without heuristics. Mix these channels or ship human-formatted output only, and the agent falls back to best-effort text parsing that fails unpredictably across versions, locales, and edge cases: silently at first, catastrophically later. ## Requirements **MUST:** - Structured-output CLIs offer at least one machine-readable format selectable via `--output`, with `json` and `jsonl` as canonical values; `text` is the default human-facing form. The format selection threads through every output path, so a single invocation never mixes formats. - Data goes to stdout. Diagnostics, progress indicators, and warnings go to stderr. An agent consuming JSON from stdout must never encounter an interleaved progress message. - Exit codes are structured and documented. Codes 77 and 78 follow BSD `sysexits.h` (`EX_NOPERM`, `EX_CONFIG`); the broader sysexits range is intentionally not mandated to keep the surface small: | Code | Meaning | | ---: | --------------------------------- | | 0 | Success | | 1 | General command error | | 2 | Usage error (bad arguments) | | 77 | Authentication / permission error | | 78 | Configuration error | - When `--output json` is active, errors are emitted as JSON (to stderr) with at least `error`, `kind`, and `message` fields. A plain-text error in a JSON run breaks the consumer's parser on the only shape it was told to expect. - *(Applies when: CLI emits structured output.)* The output schema is exposed at runtime. A `schema` subcommand (or a `--schema` flag on each data-emitting subcommand) is the recommended surface; an introspection command under another name satisfies the requirement when the tool's `--help` documents it as the command that describes the output's structure (`kubectl explain`, which prints the fields of the resources `kubectl get -o json` returns). The schema identifies its format (canonical recommendation: JSON Schema 2020-12, the same dialect OpenAPI 3.1 uses), so an agent reading the schema loads the right validator without parsing prose. A consumer asking "what shape am I about to receive?" gets a machine-readable answer in one call. **SHOULD:** - JSON output uses a consistent envelope (a top-level object with predictable keys) across every command so agents can rely on the same shape. - *(Applies when: CLI emits structured output.)* The same schema is also exported to a stable file path in the source repo (e.g., `schema/.json`), so consumers pin against it at install or CI time without invoking the tool. The runtime schema is the runtime contract; the file is the build-time contract. - `--json` and `--jsonl` are accepted as aliases for `--output json` and `--output jsonl`. The `--output` enum remains the canonical surface for the format MUST above; a CLI shipping only the short forms still satisfies that MUST through the alias path. **MAY:** - Additional output formats (CSV, TSV, YAML) beyond the core three. The core three remain mandatory. - A `--raw` flag for unformatted output suitable for piping to other tools. ## Evidence Rust reference implementation: - `OutputFormat` enum with `Text`, `Json`, `Jsonl` variants deriving `ValueEnum`. - `OutputConfig` struct with `format`, `use_color`, and `quiet` fields threaded through every output-producing function. - `serde_json` in `Cargo.toml`. - No `println!` in `src/` outside the output module: every print goes through `OutputConfig`. - Exit-code constants or match arms mapping error variants to distinct numeric codes. - `eprintln!` (or an equivalent diagnostic macro) for every diagnostic line. ## Anti-Patterns - `println!` scattered across handlers instead of routing through the output config. - A single exit code (1) for everything: agents cannot distinguish auth failures from config errors. - Status lines ("Fetching data…") printed to stdout where they contaminate JSON output. - `process::exit()` in library code, bypassing structured error propagation. - Human-formatted tables as the only output mode with no JSON alternative. Measured by audit IDs `p2-json-output`, `p2-structured-output`, `p2-output-module`, `p2-structured-exit-codes`, `p2-json-errors`, `p2-schema-print`, `p2-consistent-envelope`, `p2-schema-file`, `p2-json-aliases`, `p2-more-formats`, `p2-raw-flag`. Run `anc audit --principle 2 .` against the CLI under test to see each. --- # P3: Progressive Help Discovery Source: https://anc.dev/p3 Canonical-Markdown: https://anc.dev/p3.md # P3: Progressive Help Discovery ## Definition Help text MUST be layered so agents (and humans) can drill from a short summary to concrete usage examples without reading the entire manual. The critical layer is the one that appears **after** the flags list, because that is where readers look for invocation patterns. ## Why Agents Need It Agents discover how to use a tool by calling `--help` and scanning the output. They skip past flag definitions (which describe what is *possible*) and hunt for examples (which describe what to *do*). A flags list alone is enough rope to produce a failed invocation; examples are what turn discovery into action. Without examples in the help output, an agent trial-and-errors its way into a working call, burning tokens and sometimes landing on a wrong-but-silent success. ## Requirements The principle is framework-agnostic. `clap`'s `after_help` is the worked example below; analogs include `cobra`'s `Example` (Go), `argparse`'s `epilog` (Python), `docopt`'s usage block, and the `Examples:` convention in `gh` / `kubectl`. **MUST:** - Every subcommand that takes its own arguments or options ships at least one concrete invocation example showing the command with realistic arguments, rendered in the section that appears after the flags list. In clap this is the `after_help` attribute. A subcommand whose `--help` shows no positional argument (a nested command list counts as one) and no option beyond `-h`/`--help` and the global flags every subcommand inherits is exempt: its usage line (`tool version`, `tool logout`) is its whole call shape, so an example would repeat it. - The top-level command ships 2–3 concrete examples covering the primary use cases. - The top-level command responds to `--version` with a non-empty version line on stdout and exits 0. Agents pin against tool versions to detect breaking changes; a `--version` that errors, exits non-zero, or prints nothing forces every consumer to scrape the binary path or manifest for a clue. **SHOULD:** - Examples show human and agent invocations side by side: a text-output example followed by its `--output json` equivalent (see [P2](https://anc.dev/p2)). Readers see the pair; agents see the JSON form. - Short `about` for command-list summaries; `long_about` reserved for detailed descriptions visible with `--help` but not `-h`. - A short alias for `--version` works: `-V` (clap default; `curl`, `wget`, `gzip`), `-v` (`npm`, `node`, `bun`, `yarn`, `make`), or `-version` (Go's `flag` package). Any of the three is sufficient. Agents probing tool versions across many CLIs save token cost when they can pin against a one- or two-character flag; the long-only path forces an extra parse step. - *(Applies when: CLI uses subcommands.)* Command-list entries name the command directly (`status`, `server stop`) rather than repeat the binary name on every line (`tool status`, `tool server stop`). An agent scanning the block takes the command token straight from the left column instead of reconstructing it from a prefix it already knows from the `Usage:` line. A hand-written list that repeats the binary name leaves every command second on its line: ```text Usage: tool [options] Commands: tool status Show server status tool start Start the server tool stop Stop the server ``` The clap-shaped list leads each entry with the command itself: ```text Usage: tool Commands: status Show server status start Start the server stop Stop the server ``` The bare invocation line, which documents what the tool does with no arguments, is the one entry that legitimately carries the binary name alone. **MAY:** - A dedicated `examples` subcommand or `--examples` flag that outputs a curated set of usage patterns for agent consumption. ## Evidence - `after_help` (or `after_long_help`) attribute on the top-level parser struct. - `after_help` attribute on every subcommand variant that takes its own arguments or options. - Example invocations in `after_help` text that include realistic arguments, not placeholder `` tokens. - `about` (short) present on each subcommand, and `after_help` (examples) on each subcommand that takes its own arguments or options. - The command list's left column holds bare command tokens; the binary name appears in the `Usage:` line and in examples, not at the head of each command entry. ## Anti-Patterns - Relying solely on `///` doc comments: those populate `about` / `long_about`, not `after_help`, so no examples render after the flags list. - A single `about` string serving as both summary and usage documentation. - Examples buried in a README or man page but absent from `--help` output. - `after_help` text that describes the flags in prose instead of demonstrating them in code. - A hand-written command list that prefixes every entry with the binary name, so the command token sits second on each line and a scanner has to strip the prefix before it can read the command. Measured by audit IDs `p3-subcommand-examples`, `p3-help`, `p3-version`, `p3-paired-examples`, `p3-about-long-about`, `p3-unprefixed-command-list`, `p3-examples-subcommand`. Run `anc audit --principle 3 .` against the CLI under test to see each. --- # P4: Fail Fast with Actionable Errors Source: https://anc.dev/p4 Canonical-Markdown: https://anc.dev/p4.md # P4: Fail Fast with Actionable Errors ## Definition CLI tools MUST detect invalid state early, exit with a structured error, and tell the caller three things: what failed, why, and what to do next. An error that says "operation failed" gives an agent nothing to act on. ## Why Agents Need It Agents operate in a retry loop: attempt, observe, decide. When an error is vague or unstructured (a bare stack trace, a one-word failure, a mixed-channel splurge), the agent cannot tell whether to retry, re-authenticate, fix configuration, or escalate to the user. Distinct exit codes paired with this standard's published mapping let the agent act correctly on the first read. The difference between exit code 77 (re-authenticate) and exit code 78 (fix config) determines whether the agent retries OAuth or asks the user to check their config file. Getting that wrong wastes entire conversation turns. Codes 77 and 78 follow BSD `sysexits.h` (`EX_NOPERM`, `EX_CONFIG`). Most CLIs today do not distinguish auth from config errors at the exit-code layer; this standard adopts `sysexits.h` numbering so agents can disambiguate. ## Requirements **MUST:** - Parse arguments with `try_parse()` instead of `parse()`. Clap's `parse()` calls `process::exit()` directly, bypassing custom error handlers, which means `--output json` cannot emit JSON parse errors. `try_parse()` returns a `Result` the tool can format: ```rust let cli = Cli::try_parse()?; ``` - Error types map to distinct exit codes. Use 77 when the CLI has an auth surface and 78 when it has a config surface; 0 (success), 1 (general command error), and 2 (usage / argument error) are universal. - Every error message names **the failure**, **the cause**, and **a concrete remediation**: a command to run or a value to set, not a hint to consult documentation. Example: ```text Authentication failed: token expired (expires_at: 2026-03-25T00:00:00Z). Run `tool auth refresh` or set TOOL_TOKEN. ``` **SHOULD:** - Error types use a structured enum (via `thiserror` in Rust) with variant-to-kind mapping for JSON serialization. Agents match on error kinds programmatically rather than parsing message text. - *(Applies when: CLI makes network calls.)* Config and auth validation happen before any network call, failing at the earliest possible point. The three-tier structure (meta-commands, local-only commands, network commands) is defined in [P6](https://anc.dev/p6); this requirement covers the network-call ordering it implies. - Error output respects `--output json`: JSON-formatted errors go to stderr when JSON output is selected, consistent with [P2](https://anc.dev/p2)'s stream discipline (stdout for data, stderr for diagnostics). - *(Applies when: rejecting input against an enum or a fixed-allowed-values set.)* The error message includes the valid set. `unknown command 'lst' (valid: list, get, create, update, delete)` is more useful than `unknown command 'lst'`: the agent learns the surface from the failure instead of going back to `--help`. ## Evidence - `Cli::try_parse()` in `main()`, not `Cli::parse()`. - Error enum with `#[derive(Error)]` and distinct variants for config, auth, and command errors. - `exit_code()` method on the error type returning variant-specific codes. - `kind()` method returning a machine-readable string for JSON serialization. - `run()` function returning `Result<(), AppError>`, not calling `process::exit()` internally. - Error messages containing remediation steps ("run X" or "set Y") alongside the cause. ## Anti-Patterns - `Cli::parse()` anywhere in the codebase, because it silently prevents JSON error output. - `process::exit()` in library code or command handlers. Only `main()` MAY call it, after all error handling. - A single catch-all error variant that maps everything to exit code 1. - Error messages that state the symptom without the cause or fix ("Error: request failed"). - Panics (`unwrap()`, `expect()`) on recoverable errors in production code paths. Measured by audit IDs `p4-try-parse`, `p4-bad-args`, `p4-exit-codes`, `p4-actionable-errors`, `p4-error-module`, `p4-error-types`, `p4-json-error-output`, `p4-enumerate-valid-set`, `p4-process-exit`, `p4-sys-exit`, `code-unwrap`, `code-bare-except`. Run `anc audit --principle 4 .` against the CLI under test to see each. --- # P5: Safe Retries and Explicit Mutation Boundaries Source: https://anc.dev/p5 Canonical-Markdown: https://anc.dev/p5.md # P5: Safe Retries and Explicit Mutation Boundaries ## Definition Every CLI with write operations MUST support `--dry-run` so agents can preview a mutation before committing it. Commands MUST make the read-vs-write distinction visible from name and `--help` alone, and destructive writes MUST require explicit confirmation. An agent that cannot distinguish a safe read from a dangerous write will either avoid the tool or execute mutations blindly. Both are failure modes. ## Why Agents Need It Agent harnesses commonly retry failed operations. If a write operation is not idempotent, a retry creates duplicates, corrupts data, or trips rate limits. When destructive operations require explicit confirmation (`--force`, `--yes`) and support preview (`--dry-run`), an agent can safely explore what a command would do before committing to it. Read-only tools are inherently safe for retries, but they still benefit from help text that names the mutation contract: "this does not modify state" is a better sentence to put in `--help` than to assume. ## Requirements **MUST:** - *(Applies when: CLI has destructive operations.)* Destructive operations (delete, overwrite, bulk modify) require an explicit confirmation flag. `--yes` and `--force` are the recommended names; a flag under another name satisfies the requirement when the command's `--help` documents it as the flag that confirms the operation without a prompt (`terraform destroy -auto-approve`). Without the flag, the tool refuses the operation or enters dry-run mode. It MUST NOT mutate silently. - *(Applies when: CLI has both read and write operations.)* The distinction between read and write commands is clear from the command name and help text alone. An agent reading `--help` immediately knows whether a command mutates state. - *(Applies when: CLI has write operations.)* A `--dry-run` flag is present on every write command. When set, the command validates inputs and reports what it would do without executing. Dry-run output respects `--output json` so agents can parse the preview programmatically. **SHOULD:** - Write operations are idempotent where the domain allows it. Running the same command twice produces the same end state, not a doubled effect. ## Evidence - `--dry-run` flag on commands that create, update, or delete resources. - A confirmation flag on destructive commands: `--yes` or `--force`, or a documented equivalent such as `-auto-approve` on `terraform destroy`. - Command names that signal intent: `add`, `remove`, `delete`, `create` for writes; `list`, `show`, `get`, `search` for reads. - Dry-run output that shows what *would* change without executing. ## Anti-Patterns - A `delete` command that executes immediately without `--force` or confirmation. - Write commands sharing a name pattern with read commands (e.g., a `sync` that silently overwrites local state). - No `--dry-run` option on bulk operations, where a preview prevents costly mistakes. - Operations that fail on retry because the first attempt partially succeeded: non-idempotent writes without rollback. Measured by audit IDs `p5-force-yes`, `p5-read-write-distinction`, `p5-dry-run`. Run `anc audit --principle 5 .` against the CLI under test to see each. --- # P6: Composable and Predictable Command Structure Source: https://anc.dev/p6 Canonical-Markdown: https://anc.dev/p6.md # P6: Composable and Predictable Command Structure ## Definition CLI tools MUST integrate cleanly with pipes, scripts, and other tools. That means handling SIGPIPE, detecting TTY for color and formatting decisions, supporting stdin for piped input, and maintaining a consistent, predictable subcommand structure. ## Why Agents Need It Agents compose CLI tools into pipelines: ```bash tool list --output json | jaq '.[] | .id' | xargs tool get ``` Every link in that chain has to behave predictably. A tool that panics on SIGPIPE when piped to `head` breaks the pipeline. A tool that emits ANSI color codes into a pipe pollutes downstream JSON parsing. A tool with inconsistent subcommand naming forces the agent to memorize exceptions rather than apply patterns. Composability is what makes a CLI tool a building block rather than a dead end. ## Requirements **MUST:** - SIGPIPE is handled so that piping to `head`, `tail`, or any tool that closes the pipe early does not crash the process. In Rust, restore the default SIGPIPE handler as the first executable statement in `main()`: ```rust unsafe { libc::signal(libc::SIGPIPE, libc::SIG_DFL); } ``` Equivalents in other languages: in Python, restore the default `SIGPIPE` handler at startup (`signal.signal(signal.SIGPIPE, signal.SIG_DFL)`); in Go, the runtime's default handling already exits cleanly on EPIPE writes; in Node.js, handle `EPIPE` on `process.stdout`. - TTY detection, plus support for `NO_COLOR` and `TERM=dumb`. When stdout or stderr is not a terminal, color codes are suppressed automatically. - Shell completions available via a `completions` subcommand (clap_complete in Rust; equivalents elsewhere). This is a Tier 1 meta-command: it works without config, auth, or network. - *(Applies when: CLI makes network calls.)* A `--timeout` flag with a sensible default (30 seconds). Agents operating under their own time budgets need to fail fast rather than block on a slow upstream. - *(Applies when: CLI invokes a pager for output.)* Support `--no-pager` or respect `PAGER=""`. Pagers block headless execution indefinitely. - *(Applies when: CLI uses subcommands.)* Agentic flags (`--output`, `--quiet`, `--no-interactive`, `--timeout`) propagate to every subcommand automatically (e.g., `global = true` in clap). - *(Applies when: CLI runs long-running operations.)* SIGTERM is handled gracefully: in-flight writes flush or roll back, locks release, and the process exits non-zero within a bounded shutdown window. The next invocation succeeds without manual cleanup. Agents commonly cancel a long-running call when their own deadline expires; a tool that leaves half-written state behind on SIGTERM forces the agent to clean up before retrying. **SHOULD:** - Commands that accept input read from stdin when no file argument is provided. Pipeline composition depends on it. - *(Applies when: CLI uses subcommands.)* Subcommand naming follows one consistent grammar (`noun verb` or `verb noun`) throughout the tool. Mixed patterns (`list-users` alongside `user show`) force agents to memorize exceptions instead of applying a rule. - Three-tier dependency gating: Tier 1 (meta-commands like `completions`, `version`) needs nothing; Tier 2 (local commands) needs config; Tier 3 (network commands) needs config + auth. `completions` and `version` always work, even in broken environments. - When a CLI exposes multiple distinct operations, model them as subcommands rather than mutually-exclusive flags. `tool search "query"` is preferable to `tool --search "query" --get "id"`. Single-operation tools (`grep`, `curl`, `jq`) are exempt: flags are their operation surface. **MAY:** - A `--color auto|always|never` flag for explicit color control beyond TTY auto-detection. - *(Applies when: CLI uses subcommands.)* Subcommand verbs follow community-standard names (`get`, `list`, `create`, `update`, `delete`); flag spellings follow widely-used canonical forms (`--force` for confirmation bypass, `--yes` for prompt bypass, `--limit` for pagination, `--quiet` / `--verbose` for volume control). Convergence reduces an agent's per-tool relearning cost: an agent that has seen `kubectl get` and `gh repo list` recognizes `tool list` immediately, without re-reading `--help`. ## Evidence - `libc::signal(libc::SIGPIPE, libc::SIG_DFL)` (or the equivalent in the target language) as the first statement of `main()`. - `IsTerminal` trait usage (`std::io::IsTerminal` or the `is-terminal` crate). - `NO_COLOR` and `TERM=dumb` checks. - `clap_complete` in `Cargo.toml`. - A `completions` subcommand in the CLI enum. - Tiered match arms in `main()` separating meta-commands from config-dependent commands. ## Anti-Patterns - Missing SIGPIPE handler: `cargo run -- list | head` panics with "broken pipe". - Hard-coded ANSI escape codes without TTY detection. - Color output in JSON mode: ANSI codes inside JSON string values break downstream parsing. - A `completions` command that requires auth or config to run. - No stdin support on commands where piped input is a natural use case. Measured by audit IDs `p6-sigpipe`, `p6-sigterm`, `p6-no-color-behavioral`, `p6-no-color`, `p6-completions`, `p6-timeout`, `p6-no-pager-behavioral`, `p6-no-pager`, `p6-global-flags`, `p6-stdin-input`, `p6-consistent-naming`, `p6-subcommand-operations`, `p6-color-flag`, `p6-standard-names`, `p6-dependencies`. Run `anc audit --principle 6 .` against the CLI under test to see each. --- # P7: Bounded, High-Signal Responses Source: https://anc.dev/p7 Canonical-Markdown: https://anc.dev/p7.md # P7: Bounded, High-Signal Responses ## Definition CLI tools MUST provide mechanisms to control output volume. Agent context windows are finite and expensive: a tool that dumps tens of thousands of lines of unfiltered output wastes tokens on every request and can exceed smaller context windows entirely, breaking the conversation that invoked it. "High-signal" here means the bytes that survive `--quiet` are the ones the caller asked for (data and errors), not progress, decoration, or chatter. ## Why Agents Need It Unbounded CLI output is expensive for any agent: token cost and context-window capacity for LLM agents, parse cost and memory pressure for scripts, schedulers, and other automation. Either way, the agent ends up truncating (losing potentially important data) or consuming the full response (wasting cycles on noise). Bounded output with `--quiet`, `--verbose`, and `--limit` flags gives the agent precise control over how much data arrives, keeping responses high-signal and inside budget. ## Requirements **MUST:** - A `--quiet` flag suppresses non-essential output: progress indicators, informational messages, decorative formatting. When `--quiet` is set, only requested data and errors appear. Implementations route diagnostics through a macro that short-circuits when quiet is on: ```rust macro_rules! diag { ($cfg:expr, $($arg:tt)*) => { if !$cfg.quiet { eprintln!($($arg)*); } } } ``` - *(Applies when: CLI has list-style commands.)* List operations clamp to a documented default maximum. A `list` without `--limit` does not return more than a configurable ceiling (e.g., 100 items). If more items exist, the output indicates truncation: `"truncated": true` in JSON, a stderr note in text mode. **SHOULD:** - A `--verbose` flag (or `-v` / `-vv`) escalates diagnostic detail when agents need to debug failures. - *(Applies when: CLI has list-style commands.)* A `--limit` or `--max-results` flag lets callers request exactly the number of items they want. - A `--timeout` flag bounds execution time. An agent waiting indefinitely on a hung network call cannot proceed. **MAY:** - *(Applies when: CLI returns paginated results.)* Cursor-based pagination flags (`--after`, `--before`) for efficient traversal of large result sets. - Automatic verbosity reduction in non-TTY contexts (the same behavior `--quiet` explicitly requests). ## Evidence - A `--quiet` flag with a falsey-value parser and an env-var binding. - A diagnostic macro (or equivalent gate) that short-circuits when `quiet` is true. - `--limit` or `--max-results` on every list / search command. - Pagination clamping logic (e.g., `min(requested, MAX_RESULTS)`). - `--timeout` flag with a sensible default. - `--verbose` flag for diagnostic escalation. - A `suppress_diag()` method that returns true when quiet is set or when the output format is JSON / JSONL. ## Anti-Patterns - List commands that return all results with no default limit: an agent listing 50,000 items floods its context window. - No `--quiet` flag: agents consuming JSON output still receive interleaved diagnostic text on stderr. - `--verbose` as the only output control. If there is no way to reduce output, bounded responses do not exist. - Progress bars or spinners that write to stderr in non-TTY contexts, adding noise to agent logs. - No `--timeout` on network operations. A stalled request blocks the agent indefinitely. Measured by audit IDs `p7-quiet`, `p7-output-clamping`, `p7-verbose`, `p7-limit`, `p7-timeout-behavioral`, `p7-cursor-pagination`, `p7-auto-verbosity`, `p7-naked-println`. Run `anc audit --principle 7 .` against the CLI under test to see each. --- # P8: Discoverable Through Agent Skill Bundles Source: https://anc.dev/p8 Canonical-Markdown: https://anc.dev/p8.md # P8: Discoverable Through Agent Skill Bundles ## Definition Without a skill bundle, every fresh agent invocation begins the same way: pull `--help`, infer the idioms, try a command, parse the error, try again. A skill bundle (canonical names `AGENTS.md` or `SKILL.md`) collapses that loop: agent-discoverable through filesystem convention rather than through `--help`, loaded once, recognized thereafter. ## Why Agents Need It `--help` describes what is *possible* (the flag and subcommand surface); a skill bundle describes what to *do* (workflow knowledge, common compositions, recovery patterns). Workflow knowledge does not fit in `after_help` examples. The bundle is also where conventions that span multiple subcommands live (exit-code tables, output-channel discipline, retry semantics): context that `--help` for a single subcommand cannot carry on its own. Without one, the agent has nowhere to durably register what it learned, and re-pays the discovery cost on every fresh session. ## Requirements **MUST:** - *(Applies when: CLI ships a skill bundle.)* An install path that registers the bundle with installed agent runtimes. The canonical form is a `tool skill install []` subcommand that writes into the runtime's filesystem cascade (`~/.claude/skills/`, `~/.cursor/skills/`, `~/.codex/skills/`, etc.). Non-canonical alternatives (`tool init --skill`, `tool skills add`, `tool agents add`) are acceptable but should migrate toward `tool skill install`. A bundle without an install path sits unread until a human manually copies it; the install path is what turns the bundle from documentation into discoverable runtime knowledge. **SHOULD:** - A top-level agent-discoverable markdown bundle. Canonical filenames are `AGENTS.md` or `SKILL.md`, both recognized by major agent runtimes. The bundle's first job is to be findable by filesystem convention; its second is to teach the agent how to invoke the tool well. YAML frontmatter at minimum names the tool and a one-line capability summary so agents can scan and route without reading the full body. **MAY:** - *(Applies when: CLI ships a skill bundle.)* An `--all` mode auto-detects installed agent runtimes (Claude Code, Cursor, Codex, OpenCode, and others as the ecosystem evolves) and installs the bundle across each. A user setting up a new machine with multiple coding agents installs once and gets coverage everywhere. - *(Applies when: CLI ships a skill bundle.)* An `update` (or `upgrade`) subcommand under `tool skill` pulls the latest bundle version, so agents stay current with the CLI's evolving surface without a full reinstall. ## Evidence - A top-level `AGENTS.md` or `SKILL.md` in the CLI's source tree, shipped in the release artifact, with YAML frontmatter declaring at least the tool name and a one-line capability summary. - A `skill` subcommand group in the CLI (e.g., `tool skill install`, `tool skill update`, `tool skill list`). - An installer that writes directly to the runtime cascade (`~/.claude/skills//`, `~/.cursor/skills//`) rather than requiring the runtime to be running. - Bundle content versioned alongside the CLI's release: the bundle ships from the same commit as the binary, not from a separate documentation tree that drifts. ## Anti-Patterns - A CLI shipping a skill bundle with no install path. The bundle sits unread until a human copies it manually. - An install path that requires the agent runtime to be running. The runtime cascade is filesystem-resident; writing to it should not need an active session. - A bundle whose contents drift from the CLI's actual surface: a skill bundle in a docs subtree maintained by a different cadence than the binary itself, naming flags or subcommands that no longer exist. Measured by audit IDs `p8-bundle-install`, `p8-bundle-exists`, `p8-install-all`, `p8-bundle-update`. Run `anc audit --principle 8 .` against the CLI under test to see each. --- # Audit a CLI tool or a website Source: https://anc.dev/audit Canonical-Markdown: https://anc.dev/audit.md # Audit a CLI tool or a website anc.dev audits the two surfaces an agent works through: the command-line tools it runs and the websites it reads. Pick CLI or Website, enter a target, and the audit runs live and lands on a shareable scorecard. The audit runs live from this page in a browser. From an agent, use the MCP tools named below. ## Audit a CLI tool `anc` is the reference linter for this standard. It scores any CLI tool against the eight principles and tells you, by audit ID, where it passes and where it falls short. The live audit above installs a tool in a sandbox and runs its binary and behavioral audits; for source and project depth, run `anc` locally. ## Install See [/install](https://anc.dev/install) for `brew`, `cargo`, and platform-archive instructions. Once `anc` is on `$PATH`, the rest of this page is what to do with it. ## Run it ```bash # Against the current project (cargo workspace, binary, or source tree) anc audit . # Against a compiled binary directly anc audit ./target/release/mycli # Agent-friendly output anc audit . --output json # Narrow to one principle anc audit . --principle 3 ``` ## Read the output ```text P1 — Non-Interactive by Default [PASS] Non-interactive by default (p1-non-interactive) [PASS] Has --no-interactive flag (p1-flag-existence) P3 — Progressive Help [PASS] Help flag produces useful output (p3-help) [PASS] Version flag produces version output (p3-version) P4 — Fail Fast with Actionable Errors [PASS] Rejects invalid arguments (p4-bad-args) P6 — Composable Command Structure [PASS] Handles SIGPIPE cleanly (p6-sigpipe) [PASS] Respects NO_COLOR (p6-no-color-behavioral) P7 — Bounded, High-Signal Responses [PASS] Has --quiet flag (p7-quiet) ``` Each line ends with a stable audit ID (`p1-non-interactive`, `p2-json-output`, `p6-sigpipe`, etc.). Cite those IDs in issues, commits, and agent output; they do not change between versions. ## Three audit layers - **Behavioral**: runs your compiled binary and inspects `--help`, `--version`, `--output json`, SIGPIPE, NO_COLOR, and exit codes. Language-agnostic. - **Source**: ast-grep pattern matching on source code. Catches `.unwrap()`, missing error types, naked `println!`. Rust and Python today; more languages as they land. - **Project**: file and manifest inspection. Looks for `AGENTS.md`, recommended dependencies, dedicated error and output modules. Pass `--binary` for behavioral-only (skip source). Pass `--source` for source-only (skip behavioral). Most projects want the default, which is "run everything." ## What a score means A `[PASS]` is a requirement met, not a compliment. A `[WARN]` is a SHOULD the tool doesn't satisfy; ignoring it is a choice, not a bug. A `[FAIL]` is a MUST the tool doesn't satisfy; agents will hit the edge it describes, and the tool will surprise them. Nothing here is a vanity metric because the audits map one-to-one to the requirements on the [principles page](https://anc.dev/). ## From an agent: CLI tools An MCP client can score a CLI without the form. The [anc.dev MCP server](https://anc.dev/mcp-docs) exposes `score_cli`, which installs and audits a tool live under its own per-source rate limits, and `get_scorecard`, which reads a curated or cached scorecard. Both take a tool name, an install command, or a GitHub URL, and `score_cli` returns the scorecard's URL. ## See how widely-used CLIs score The [**ANC 100 leaderboard**](https://anc.dev/scorecards) is what running `anc audit` produces at scale: every popular CLI tool, scored against the same eight principles, with full per-audit evidence under `/score/`. The scoring rules are documented on the [methodology page](https://anc.dev/methodology); the underlying JSON schema is enumerated at [/scorecard-schema](https://anc.dev/scorecard-schema). Source: [github.com/brettdavies/agentnative-cli](https://github.com/brettdavies/agentnative-cli). ## Audit a website The website audit probes the agent-facing surface of any public site: its MCP server, its MCP and agent discovery surfaces, its machine-readable content (`llms.txt`, OpenAPI, JSON Schemas), its root-HTML affordances, and its crawl policy. The result is a web scorecard with per-check evidence and copy-paste fixes, at a shareable `/score/` page. ## What a website audit checks The audit runs entirely as network probes: HTTP requests, a JSON-RPC handshake over streamable-HTTP, a CORS preflight, and DNS-over-HTTPS lookups. There is no crawler and nothing is installed. anc sends no plaintext request: an http URL, declared or linked, and any redirect to http, is never requested. Every check carries a MUST, SHOULD, or MAY keyword and belongs to one of six categories: - **Discoverability**: `robots.txt`, `sitemap.xml`, `Link` headers, `` pointers, DNS-AID records under `_agents`, and an agent-friendly 404: a nonsense path MUST return HTTP 404 or 410 (a soft-200 SPA shell is broken), and the markdown 404 twin SHOULD carry at least one recovery link (`sitemap.xml`, `llms.txt`, or docs). - **Content for agents**: `llms.txt` (root and per-section), `llms-full.txt`, and markdown content negotiation: `Accept: text/markdown`, the markdown twin served to bare CLI and library User-Agents and to AI user-fetchers that state no content-type preference, `Accept: text/plain` treated as a markdown request, and `Vary: Accept, User-Agent` on the negotiated response. Root HTML MUST carry an H1 and enough visible text for a non-JS agent; a discoverable `llms.txt` twin can mark that floor not-applicable rather than crediting a JS shell. When `llms.txt` is present, three quality rows score format (H1, summary, link index), whether those links resolve, and a when-to-use or programmatic-access heading. Plus the other root-HTML affordances (meta description, `