Compare a command's captured exit status, stdout, and stderr against a known expectation. Use when reproducing an output regression or preparing a CLI smoke test.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Check Cli Contract?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vxxqv-check-cli-contract)
---
name: check-cli-contract
description: Compare a command's captured exit status, stdout, and stderr against a known expectation. Use when reproducing an output regression or preparing a CLI smoke test.
---
# Check CLI Contract
Use the local checker with Python 3.11 or newer to identify the first difference
in each captured output stream.
1. Pick the expected behavior from the documented interface or a previously
accepted run. Use a small fixture with stable outputs. See
[the sample expectation](assets/expected.json) for the JSON fields.
2. Capture the exact command, exit status, stdout, and stderr from one run.
Capture the exit status immediately after the command. Save both streams as
UTF-8 files, including a zero-byte file for an empty stream.
3. Run `python <skill-dir>/scripts/cli_contract.py <expected.json> --exit-code <status> --stdout <stdout-file> --stderr <stderr-file>`.
Exit 0 means the contract matches. Exit 2 reports a mismatch and identifies
its stream and line or JSON Pointer. Exit 1 means the expectation or a
capture needs attention.
4. Report the failing contract, command, and relevant output excerpt. Include
the tool version when sharing a reproduction. Retest with the same fixture
after an authorized fix.
Use `mode: "json"` for JSON output and `mode: "text"` for text. JSON object
key order is ignored, while arrays and value types are compared exactly.
Text comparison treats CRLF and LF line endings alike. The checker reads saved
captures. Remove sensitive data before putting a reproduction in a public issue.