This skill should be used when writing, reviewing, or hardening bash/sh shell scripts for CI/CD pipelines, infrastructure automation, build scripts, and utility tools. It covers strict mode, error handling, cleanup traps, argument parsing, safe JSON processing with jq, modern bash features, ShellCheck compliance, and script quality checklists.
set -euo pipefail"$var" formtrap cleanup EXIT with mktemp for temp files>&2| Topic | Reference File |
|---|---|
| Complete script template, JSON, backup patterns | references/bash-patterns-examples.md |
| Anti-patterns and quality checklist |
references/anti-patterns-checklist.md |
set -euo pipefail + trap cleanup EXITreadonly for constants, unset mutable vars at topusage(), log_info(), log_error(), validate_requirements()while [[ $# -gt 0 ]]; do case $1 in ...command -v, params with [[ -z ... ]]main() function calls validated helpersshellcheck script.sh; test missing params and bad inputsbash -x script.sh or inline set -x / set +xset -euo pipefailTEMP_DIR="$(mktemp -d)"command -v jq &>/dev/null || { echo "jq required" >&2; exit 1; }for item in "${arr[@]}"; dojq --raw-output '.key // empty' file.json[[ "$var" == "value" ]] (not [ ])local name="$1" inside functionscd /path || exit 1