install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/unix-cli" ~/.claude/skills/comeonoliver-skillshub-unix-cli && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/unix-cli/SKILL.mdsource content
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 librariesargs-use-getopt
- Provide long options for all short optionsargs-provide-long-options
- Support double-dash to terminate optionsargs-support-double-dash
- Implement --help and --version optionsargs-require-help-version
- Prefer flags over positional argumentsargs-prefer-flags-over-positional
- Use standard flag namesargs-use-standard-flag-names
- Never read secrets from command-line flagsargs-never-read-secrets-from-flags
- Support option bundlingargs-support-option-bundling
2. Exit Codes (CRITICAL)
- Return zero for success onlyexit-zero-for-success
- Use standard exit codesexit-use-standard-codes
- Use 128+N for signal terminationexit-signal-codes
- Handle partial success consistentlyexit-partial-success
- Distinguish error types with different exit codesexit-distinguish-error-types
3. Output Streams (CRITICAL)
- Write data to stdout onlyoutput-stdout-for-data
- Write errors and diagnostics to stderroutput-stderr-for-errors
- Detect TTY for human-oriented outputoutput-detect-tty
- Provide machine-readable output formatoutput-provide-machine-format
- Use line-based output for text streamsoutput-line-based-text
- Respect NO_COLOR environment variableoutput-respect-no-color
4. Error Handling (HIGH)
- Include program name in error messageserror-include-program-name
- Make error messages actionableerror-actionable-messages
- Use strerror for system errorserror-use-strerror
- Avoid stack traces in user-facing errorserror-avoid-stack-traces
- Validate input early and fail fasterror-validate-early
5. I/O & Composition (HIGH)
- Support reading from stdinio-support-stdin
- Write output to stdout by defaultio-write-to-stdout
- Design stateless operationsio-be-stateless
- Handle binary data safelyio-handle-binary-safely
- Use atomic file writesio-atomic-writes
- Handle multiple input files consistentlyio-handle-multiple-files
6. Help & Documentation (MEDIUM-HIGH)
- Show brief usage on argument errorshelp-show-usage-on-error
- Structure help output consistentlyhelp-structure-help-output
- Show default values in helphelp-show-defaults
- Include practical examples in helphelp-include-examples
- Format version output correctlyhelp-version-format
7. Signals & Robustness (MEDIUM)
- Handle SIGINT gracefullysignal-handle-sigint
- Handle SIGTERM for clean shutdownsignal-handle-sigterm
- Handle SIGPIPE for broken pipessignal-handle-sigpipe
- Skip cleanup on second interruptsignal-cleanup-on-second-interrupt
8. Configuration & Environment (MEDIUM)
- Follow XDG Base Directory Specificationconfig-follow-xdg
- Apply configuration in correct precedence orderconfig-precedence-order
- Use consistent environment variable namingconfig-env-naming
- Never store secrets in config files or environmentconfig-never-store-secrets
- Respect standard environment variablesconfig-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 |