Install any skill in seconds. Free to start, no credit card required.
Get Started Free →jayrha/bash-script-hardening
Writes robust, safe, shellcheck-clean Bash scripts using strict mode, defensive quoting, error traps, safe temp files, and signal handling.
Passed 22 of 22 test cases with the skill, and 18 of 22 without it.
and 3 more in the full report
4 fixed18 passed either way0 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
The instructions your model reads when the skill loads.
Most Bash bugs are silent: an unset variable expands to nothing, a failed command is ignored, an unquoted path word-splits, and the script marches on corrupting state. This skill makes Bash scripts fail loudly, fail early, and clean up after themselves.
Keywords: bash, shell, strict mode, set -euo pipefail, IFS, quoting, word splitting, globbing, ShellCheck, trap, ERR, EXIT, cleanup, mktemp, signal handling, defensive scripting, POSIX, exit codes, here-doc, arrays.
Use this skill to author a new script from a hardened template, retrofit an existing script, or review a script for safety defects.
#!/usr/bin/env bash and the canonical strict-mode preamble (see below). Never rely on /bin/sh if Bash features are used.IFS=$'\n\t' so unquoted expansions don't split on spaces.EXIT trap that removes temp files and restores state, plus an ERR trap for diagnostics.mktemp, and reference them through the cleanup trap.command -v), required env vars.# shellcheck disable=SCxxxx comment.Reference files:
references/strict-mode.md — deep dive on set -euo pipefail, IFS, and the gotchas/escape hatches.references/shellcheck-codes.md — the most common ShellCheck codes, what they mean, and the correct fix.templates/hardened-script.sh — drop-in starting template with strict mode, traps, arg parsing, logging.scripts/harden_check.sh — static auditor that flags missing strict mode, unquoted vars, and other red flags.examples/before-after.md — a real fragile script transformed into a hardened one, line by line.#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'
What each flag buys you:
test cases passed, vs 18 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.