GeezerVison is showing anc.dev — P6: Composable and Predictable Command Structure
P6MUST
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:
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.
Audited live by anc audit <tool> --principle 6: behavioral and source checks.
Requirements
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.