Skip to content

S001: CLI Commands & Interface

FieldValue
SpecS001
FeatureCLI Commands & Interface
Date2026-04-23
StatusDraft
Authorspec-writer-agent

Overview

Parity exposes two CLI commands -- parity check and parity init -- that form the entire user-facing interface of the tool. The check command is the core analysis command: it loads configuration, discovers source files, evaluates pluggable rules against each file, and produces either a human-readable table or machine-readable JSON report. The init command is a one-time setup helper that writes a default parity.yaml configuration file.

This specification defines the complete contract for both commands: their signatures, flags, exit codes, output formats, error messages, and behavioral edge cases. It serves as the source of truth for implementation (S001-FR), acceptance testing (S001-AS), QA edge-case coverage (S001-EC), interface contracts (S001-IF), and measurable success criteria (S001-SC).

The CLI is built on Laravel Zero (Symfony Console underneath). It reads configuration from parity.yaml (specified by S006), evaluates rules from the rule registry (S002), loads coverage data via readers (S003), resolves file paths via namespace mapping (S007), and formats output per S008.

User Scenarios

S001-US-001 [P1] As a developer, I want to run parity check from my project root so that I can see which source files are missing tests, lack coverage attribution, or fall below coverage thresholds.

S001-US-002 [P1] As a CI pipeline, I want parity check to return exit code 0 on success and 1 on failure so that I can gate merges on structural parity.

S001-US-003 [P1] As a CI pipeline, I want parity check --format=json to produce structured JSON output so that I can parse results programmatically.

S001-US-004 [P2] As a developer, I want parity check --show-tests to list the specific test methods covering each file so that I can verify coverage attribution at a glance.

S001-US-005 [P1] As a new user, I want parity init to create a sensible default parity.yaml so that I can get started without reading documentation first.

S001-US-006 [P2] As a developer working in a monorepo, I want parity check --config=path/to/parity.yaml so that I can point Parity at a config file outside my current working directory.

Requirements Summary

IDTypePriorityTitleStatus
S001-FR-001FunctionalP1check command signatureDraft
S001-FR-002FunctionalP1Config file resolutionDraft
S001-FR-003FunctionalP1--config flag behaviorDraft
S001-FR-004FunctionalP1--format flag behaviorDraft
S001-FR-005FunctionalP2--show-tests flag behaviorDraft
S001-FR-006FunctionalP1Exit code semanticsDraft
S001-FR-007FunctionalP1Table output formatDraft
S001-FR-008FunctionalP1JSON output formatDraft
S001-FR-009FunctionalP1Structure iteration and rule evaluationDraft
S001-FR-010FunctionalP1Global coverage reportingDraft
S001-FR-011FunctionalP1Coverage summary tableDraft
S001-FR-012FunctionalP2Unmatched test warningDraft
S001-FR-013FunctionalP1init command signatureDraft
S001-FR-014FunctionalP1init creates default configDraft
S001-FR-015FunctionalP1init idempotency guardDraft
S001-FR-016FunctionalP1Plugin loading and warningsDraft
S001-FR-017FunctionalP1Coverage data loadingDraft
S001-FR-018FunctionalP2Legacy config format supportDraft
S001-IF-001InterfaceP1check command flag contractDraft
S001-IF-002InterfaceP1Exit code contractDraft
S001-IF-003InterfaceP1JSON output schemaDraft
S001-IF-004InterfaceP1Table output structureDraft
S001-IF-005InterfaceP1init command contractDraft
S001-AS-001AcceptanceP1Happy path: all checks passDraft
S001-AS-002AcceptanceP1Violations found: exit code 1Draft
S001-AS-003AcceptanceP1JSON output modeDraft
S001-AS-004AcceptanceP2Show tests flagDraft
S001-AS-005AcceptanceP1Custom config pathDraft
S001-AS-006AcceptanceP1Init creates configDraft
S001-AS-007AcceptanceP1Init with existing configDraft
S001-AS-008AcceptanceP1Missing config fileDraft
S001-AS-009AcceptanceP1Missing coverage fileDraft
S001-AS-010AcceptanceP1Empty structure listDraft
S001-AS-011AcceptanceP2Global coverage below thresholdDraft
S001-AS-012AcceptanceP1Multiple structures in one runDraft
S001-EC-001Edge CaseP1Config file not foundDraft
S001-EC-002Edge CaseP1Config file unreadableDraft
S001-EC-003Edge CaseP1Invalid YAML syntaxDraft
S001-EC-004Edge CaseP1No coverage file foundDraft
S001-EC-005Edge CaseP1Empty structure arrayDraft
S001-EC-006Edge CaseP2Source directory does not existDraft
S001-EC-007Edge CaseP2No PHP files in source directoryDraft
S001-EC-008Edge CaseP1--config points to nonexistent fileDraft
S001-EC-009Edge CaseP2getcwd() returns falseDraft
S001-EC-010Edge CaseP2--format with invalid valueDraft
S001-EC-011Edge CaseP1init when getcwd() failsDraft
S001-EC-012Edge CaseP2init write permission deniedDraft
S001-EC-013Edge CaseP2Plugin warnings suppressed in JSON modeDraft
S001-EC-014Edge CaseP2Symfony/Yaml not installedDraft
S001-SC-001SuccessP1Exit codes are deterministicDraft
S001-SC-002SuccessP1JSON output is valid JSONDraft
S001-SC-003SuccessP1Table output grouped by directoryDraft
S001-SC-004SuccessP1Zero violations = exit 0Draft
S001-SC-005SuccessP1Any enforced violation = exit 1Draft

Cross-Spec Dependencies

  • Depends on: S002 (Rules System -- rule evaluation and registry), S003 (Coverage Readers -- coverage data loading), S006 (Configuration & Settings -- parity.yaml parsing and Settings object), S007 (Path & Namespace Mapping -- source-to-test path resolution)
  • Required by: S005 (Plugin System -- plugin warnings rendered by CLI), S008 (Output Formats -- CLI produces table and JSON output)