/qa-cli-tools:cli-output-conventionsfrom qa-cli-tools
Defines conventions for CLI output including exit codes, stdout/stderr separation, and machine-readable formats based on the Command Line Interface Guidelines. Use when designing or testing CLI output.
Ships in qa-cli-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Per clig:
"Send output to
stdout. The primary output for your command should go tostdout. Anything that is machine readable should also go tostdout.""Send messaging to
stderr. Log messages, errors, and so on should all be sent tostderr."
Tests can only assert on output that is stable, separated, and
documented. This skill defines those conventions; sister skills
(bats-testing,
tui-snapshot-tester) test
against them.
Per clig:
"Return zero exit code on success, non-zero on failure."
"Map non-zero codes to important failure modes for script integration."
Exit code | Meaning
----------+----------------------------
0 | Success
1 | General error (catch-all)
2 | Misuse (bad flag, bad usage)
3 | Resource not found
4 | Permission denied
5 | Network / external failure
... documented per CLI
Test pattern:
@test "exit 0 on success" {
run mycli list
[ "$status" -eq 0 ]
}
@test "exit 2 on bad flag" {
run mycli --nonexistent
[ "$status" -eq 2 ]
}
Don't test [ "$status" -ne 0 ] - assert the specific code.
Otherwise refactors silently change the contract.
Per clig: "This separation ensures piped commands receive only data, not messages."
# Good: data on stdout, message on stderr
$ mycli list 2>/dev/null
alice
bob
$ mycli list >/dev/null
fetched 2 users in 0.3s
Test pattern (bats):
@test "list emits names on stdout, status on stderr" {
run --separate-stderr mycli list
[ "$status" -eq 0 ]
[ "$output" = $'alice\nbob' ]
[[ "$stderr" == *"fetched 2 users"* ]]
}
run --separate-stderr (Bats 1.5+) splits the streams; without
it, $output mixes both.
Per clig:
"Display output as formatted JSON if
--jsonis passed."
"If human-readable output breaks machine-readable output, use
--plainto display output in plain, tabular text format for integration with tools likegreporawk."
"Encourage your users to use
--plainor--jsonin scripts to keep output stable."
$ mycli list --json | jq '.[] | .name'
"alice"
"bob"
$ mycli list --plain
alice active 2026-04-15
bob active 2026-04-20
Test pattern: assert against --json, never against the
human-formatted default. Human output is allowed to evolve;
JSON is the contract.
@test "list --json contract" {
run mycli list --json
assert_success
echo "$output" | jq -e '.[0] | has("name") and has("status")'
}
Stable output for tests requires:
--verbose or
human-mode banner).--json /
--plain (no thousand separators; ISO 8601 dates).# Bad: randomized order, locale-dependent date
$ mycli list
bob 2026/04/20
alice 2026/04/15
# Good: sorted, ISO 8601
$ mycli list --plain
alice 2026-04-15
bob 2026-04-20
Test pattern: golden-file comparison with sorted output.
--help/--version, documenting the contractThe remaining four conventions and their bats test patterns are in references/conventions-5-8.md.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
Tests assert status -ne 0 | Refactors silently change error code; scripts break. | Assert specific code (Convention 1). |
| Errors on stdout | Pipes carry error text into downstream parsers. | stderr (Convention 2). |
| Tests assert against default human output | Human output evolves; tests churn. | Test against --json (Convention 3). |
| Timestamps in default output | Tests fail on every run. | Verbose-mode only (Convention 4). |
| ANSI codes leak when piped | wc -l, grep, etc. break. | TTY check + NO_COLOR (Convention 5). |
| Progress bars in CI | CI logs flooded; tests can't assert frame counts. | TTY check (Convention 5). |
| Help output requires network / config | --help should always work. | Help is local + static. |
--version mixed with marketing | Tooling can't parse. | Pure version string (Convention 7). |
--json / --plain, NO_COLOR, -q /
--verbose, --help / --version.https://no-color.org/ - NO_COLOR informal standard.--json output.bats-testing - Bash-based
assertion runner that consumes this contract.tui-snapshot-tester -
layout-level snapshots; this skill covers text-level contract.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cli-output, exit-codes, stdout-stderr, clig, command-line-guidelines
npx claudepluginhub testland/qa --plugin qa-cli-tools4 skills in this plugin
/bats-testingUse whenever the code under test is a shell script, a CLI binary or anything run from Bash: argument parsing, flags, exit codes and output. Sets up Bats-core with @test blocks, run, status and output assertions, setup/teardown, shared helpers and TAP output for CI./pester-cli-testingUse when the code under test is a PowerShell script, function, cmdlet or CLI run from pwsh. Sets up Pester v5: Describe/Context/It blocks, Should assertions, Mock, setup hooks, tags, code coverage and NUnit/JUnit XML output for CI./tui-snapshot-testerUse when a terminal UI (TUI) app needs tests that catch layout regressions. Captures rendered terminal frames as SVG or text snapshots and diffs them on each run: pytest-textual-snapshot for Textual, insta for Ratatui, teatest for Bubble Tea, ink-testing-library for Ink.2 plugins ship this exact skill · first indexed Nov 12, 2026
Other plugins' skills for the same job