shell-guide
Installation
SKILL.md
Shell/Bash Guide
Applies to: Bash 4+, POSIX sh, Automation Scripts, CI/CD Pipelines, Makefiles
Core Principles
- Strict Mode Always: Every script starts with
set -euo pipefailto fail fast on errors - Quote Everything: All variable expansions must be double-quoted to prevent word splitting and globbing
- Explicit Over Implicit: Use
[[ ]]for conditionals,localfor function variables, named constants for magic values - Fail Loudly: Never swallow errors silently; use
trapfor cleanup and meaningful exit codes - ShellCheck Clean: All scripts pass
shellcheckwith zero warnings before commit
Guardrails
Shebang and Strict Mode
- Every script:
#!/usr/bin/env bash(or#!/bin/shfor POSIX) - Immediately follow with
set -euo pipefail - Use
set -xonly for debugging, never in production scripts
Related skills