本文へ移動
cccskills
無料GitHub で公開

cli-output-conventions

Conventions for designing AND testing CLI output so it stays parseable and assertable - exit-code policy (0 success, non-zero failure with stable codes per failure mode), `stdout` for primary data / `stderr` for messages, `--json` / `--plain` for machine-readable output, deterministic ordering and timestamps, `NO_COLOR` / TTY-aware color, `-q` / `--verbose` discipline, and stable `--help` / `--version`. Built on the [Command Line Interface Guidelines][clig]. Use when designing or testing a CLI's output - a new flag, command, or error message, writing CLI assertions, or fixing flaky tests caused by non-deterministic output; it is the assertion contract for `bats-testing` and tells `tui-snapshot-tester` what does NOT need a snapshot.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qaスター 13(GitHub 13 + cccskills 0)

実行スコア 未検証

インストール方法を見る

含まれるファイル(3)

  • SKILL.md7.3 KB
  • .tessl-plugin/plugin.json879 B
  • references/conventions-5-8.md2.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

cli-output-conventions

Overview

Per clig:

"Send output to stdout. The primary output for your command should go to stdout. Anything that is machine readable should also go to stdout."

"Send messaging to stderr. Log messages, errors, and so on should all be sent to stderr."

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.

When to use

  • Authoring or reviewing a CLI's output (any new flag, command, or error message).
  • Writing tests for a CLI: this skill tells you WHAT to assert on; bats / pytest etc. tell you HOW.
  • A CLI's tests are flaky / brittle - usually the underlying output isn't deterministic. Fix the output, not the assertion.

Convention 1 - Exit codes

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.

Convention 2 - stdout vs stderr

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.

Convention 3 - Machine-readable mode

Per clig:

"Display output as formatted JSON if --json is passed."

"If human-readable output breaks machine-readable output, use --plain to display output in plain, tabular text format for integration with tools like grep or awk."

"Encourage your users to use --plain or --json in 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")'
}

Convention 4 - Determinism

Stable output for tests requires:

  • No timestamps in default output (only with --verbose or human-mode banner).
  • Stable ordering - sort lists by a canonical key, not insertion order.
  • No random IDs in output unless documented.
  • Locale-independent number formatting in --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.

Conventions 5-8 - color/TTY, verbosity, --help/--version, documenting the contract

The remaining four conventions and their bats test patterns are in references/conventions-5-8.md.

Anti-patterns

Anti-patternWhy it failsFix
Tests assert status -ne 0Refactors silently change error code; scripts break.Assert specific code (Convention 1).
Errors on stdoutPipes carry error text into downstream parsers.stderr (Convention 2).
Tests assert against default human outputHuman output evolves; tests churn.Test against --json (Convention 3).
Timestamps in default outputTests fail on every run.Verbose-mode only (Convention 4).
ANSI codes leak when pipedwc -l, grep, etc. break.TTY check + NO_COLOR (Convention 5).
Progress bars in CICI 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 marketingTooling can't parse.Pure version string (Convention 7).

Limitations

  • Legacy CLIs. Adopting this skill against an existing CLI requires a deprecation cycle for output changes.
  • Verbose / debug modes are inherently non-deterministic. Don't snapshot them; assert presence of key markers.
  • Cross-shell quoting. Bats runs in Bash; PowerShell tests via Pester need their own assertions.
  • Color contract is OS-dependent. Windows terminal emulators have different ANSI support; test on the target platforms.

References

  • clig - Command Line Interface Guidelines: exit codes, stdout / stderr, --json / --plain, NO_COLOR, -q / --verbose, --help / --version.
  • https://no-color.org/ - NO_COLOR informal standard.
  • ISO 8601 - date / time format for --json output.
  • bats-testing - Bash-based assertion runner that consumes this contract.
  • tui-snapshot-tester - layout-level snapshots; this skill covers text-level contract.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

testland のスキルをすべて見る

このスキルの問題を報告する