Individual skill
bash-script-hardening
Writes robust, safe, shellcheck-clean Bash scripts using strict mode, defensive quoting, error traps, safe temp files, and signal handling. Use this skill when authoring or reviewing shell/Bash scripts, when asked to "harden a bash script", "add strict mode", "fix shellcheck warnings", "make this script safe", debug silent failures, unquoted-variable bugs, word-splitting/globbing issues, or to add cleanup traps and error handling.
bash-script-hardening/SKILL.md
Source commit f9a456bf34c297bd23fb234f410ec9b239ebed14
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- Yes
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Network or broad shell
- Last checked
- Nov 6, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 12
- Repository last updated
- Oct 14, 2026
- License
- MIT
Observed agent integration: No specific integration evidence. Standard SKILL.md installation does not imply verified compatibility.
- agent-skills Repository topic
- ai-agents Repository topic
- anthropic Repository topic
- awesome Repository topic
- claude Repository topic
- claude-code Repository topic
- codex Repository topic
- cursor Repository topic
- gemini-cli Repository topic
- llm Repository topic
- engineering Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
SKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesSKILL.mdcore · 8,494 bytesexamples/before-after.mddoc · 3,295 bytesreferences/shellcheck-codes.mddoc · 3,726 bytesreferences/strict-mode.mddoc · 4,744 bytesscripts/harden_check.shruns · 3,836 bytestemplates/hardened-script.shruns · 2,902 bytes
Read excerpt
# Bash Script Hardening
## Overview
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.
## Workflow
1. **Set the shebang and strict mode.** Use `#!/usr/bin/env bash` and the canonical strict-mode preamble (see below). Never rely on `/bin/sh` if Bash features are used.
2. **Lock down word splitting.** Set `IFS=$'\n\t'` so unquoted expansions don't split on spaces.