unix-cli
Original:🇺🇸 English
Translated
UNIX command-line interface guidelines for building tools that follow POSIX conventions, proper exit codes, stream handling, and the UNIX philosophy. This skill should be used when writing, reviewing, or designing CLI tools to ensure they integrate properly with the UNIX tool chain. Triggers on tasks involving CLI tools, command-line arguments, exit codes, stdout/stderr, signals, or shell scripts.
4installs
Sourcepproenca/dot-skills
Added on
NPX Install
npx skill4agent add pproenca/dot-skills unix-cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →UNIX/POSIX Standards CLI Best Practices
Comprehensive guidelines for building command-line tools that follow UNIX conventions, designed for AI agents and LLMs. Contains 44 rules across 8 categories, prioritized by impact from critical (argument handling, exit codes, output streams) to incremental (configuration and environment).
When to Apply
Reference these guidelines when:
- Writing new CLI tools in any language
- Parsing command-line arguments and flags
- Deciding what goes to stdout vs stderr
- Choosing appropriate exit codes
- Handling signals like SIGINT and SIGTERM
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Argument & Flag Design | CRITICAL | |
| 2 | Exit Codes | CRITICAL | |
| 3 | Output Streams | CRITICAL | |
| 4 | Error Handling | HIGH | |
| 5 | I/O & Composition | HIGH | |
| 6 | Help & Documentation | MEDIUM-HIGH | |
| 7 | Signals & Robustness | MEDIUM | |
| 8 | Configuration & Environment | MEDIUM | |
Quick Reference
1. Argument & Flag Design (CRITICAL)
- - Use standard argument parsing libraries
args-use-getopt - - Provide long options for all short options
args-provide-long-options - - Support double-dash to terminate options
args-support-double-dash - - Implement --help and --version options
args-require-help-version - - Prefer flags over positional arguments
args-prefer-flags-over-positional - - Use standard flag names
args-use-standard-flag-names - - Never read secrets from command-line flags
args-never-read-secrets-from-flags - - Support option bundling
args-support-option-bundling
2. Exit Codes (CRITICAL)
- - Return zero for success only
exit-zero-for-success - - Use standard exit codes
exit-use-standard-codes - - Use 128+N for signal termination
exit-signal-codes - - Handle partial success consistently
exit-partial-success - - Distinguish error types with different exit codes
exit-distinguish-error-types
3. Output Streams (CRITICAL)
- - Write data to stdout only
output-stdout-for-data - - Write errors and diagnostics to stderr
output-stderr-for-errors - - Detect TTY for human-oriented output
output-detect-tty - - Provide machine-readable output format
output-provide-machine-format - - Use line-based output for text streams
output-line-based-text - - Respect NO_COLOR environment variable
output-respect-no-color
4. Error Handling (HIGH)
- - Include program name in error messages
error-include-program-name - - Make error messages actionable
error-actionable-messages - - Use strerror for system errors
error-use-strerror - - Avoid stack traces in user-facing errors
error-avoid-stack-traces - - Validate input early and fail fast
error-validate-early
5. I/O & Composition (HIGH)
- - Support reading from stdin
io-support-stdin - - Write output to stdout by default
io-write-to-stdout - - Design stateless operations
io-be-stateless - - Handle binary data safely
io-handle-binary-safely - - Use atomic file writes
io-atomic-writes - - Handle multiple input files consistently
io-handle-multiple-files
6. Help & Documentation (MEDIUM-HIGH)
- - Show brief usage on argument errors
help-show-usage-on-error - - Structure help output consistently
help-structure-help-output - - Show default values in help
help-show-defaults - - Include practical examples in help
help-include-examples - - Format version output correctly
help-version-format
7. Signals & Robustness (MEDIUM)
- - Handle SIGINT gracefully
signal-handle-sigint - - Handle SIGTERM for clean shutdown
signal-handle-sigterm - - Handle SIGPIPE for broken pipes
signal-handle-sigpipe - - Skip cleanup on second interrupt
signal-cleanup-on-second-interrupt
8. Configuration & Environment (MEDIUM)
- - Follow XDG Base Directory Specification
config-follow-xdg - - Apply configuration in correct precedence order
config-precedence-order - - Use consistent environment variable naming
config-env-naming - - Never store secrets in config files or environment
config-never-store-secrets - - Respect standard environment variables
config-respect-standard-vars
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |