Expert Bash scripting: robust, safe, portable shell scripts. Trigger keywords: bash, shell script, sh, quoting, word splitting, set -euo pipefail, trap, IFS, getopts, mktemp, shellcheck, POSIX, CLI, automation. Use for writing/debugging shell scripts and automation, or fixing quoting, exit-code, and portability bugs.
How this skill is triggered — by the user, by Claude, or both
Slash command
/bash-scripting-expert:bash-scripting-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Scripts fail in production on the input you didn't quote. Start strict, quote everything, clean up on exit, and run ShellCheck. When logic gets complex (JSON, data structures), switch to a real language.
Scripts fail in production on the input you didn't quote. Start strict, quote everything, clean up on exit, and run ShellCheck. When logic gets complex (JSON, data structures), switch to a real language.
python-expert (shell is the wrong tool).github-master.#!/usr/bin/env bash + set -euo pipefail: exit on error, error on unset vars, fail on any pipeline stage. Set IFS=$'\n\t' to stop surprise word-splitting on spaces.set -e's gotchas: it's suppressed inside if/||/&& conditions and command substitutions — check critical commands explicitly when needed."$var", "${arr[@]}", "$@" (not $*). Unquoted expansions split on IFS and glob — the #1 source of bugs.[[ … ]] for tests (not [ … ]), $(…) not backticks, (( … )) for arithmetic, and local for all function variables.trap 'cleanup' EXIT to remove temp files even on failure/interrupt. Create temps with mktemp.exit non-zero on misuse. Exit codes are meaningful — 0 success, non-zero failure.stderr (>&2); keep stdout for real output so the script composes in pipes.printf over echo for anything with escapes/variables. Use -- before paths, and find … -print0 | while IFS= read -r -d '' for filenames with spaces/newlines.sh, avoid bashisms ([[, arrays, local); if you use them, declare bash in the shebang. Lint with ShellCheck and format with shfmt.$var → breaks on spaces/globs/empties.ls or for f in $(ls) → use globs or find -print0.set -e assumed to catch everything → it won't inside conditions/substitutions; check explicitly.cd somewhere without ||exit → subsequent commands run in the wrong directory.echo with -e/escapes → non-portable; use printf.Defensive script skeleton
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
usage() { printf 'usage: %s <input-dir> <out-file>\n' "$0" >&2; exit 2; }
[[ $# -eq 2 ]] || usage
input_dir=$1
out_file=$2
[[ -d $input_dir ]] || { printf 'no such dir: %s\n' "$input_dir" >&2; exit 1; }
command -v jq >/dev/null || { printf 'jq required\n' >&2; exit 1; }
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
# safe iteration (handles spaces/newlines in names)
find "$input_dir" -type f -name '*.log' -print0 |
while IFS= read -r -d '' f; do
wc -l -- "$f" >> "$tmp"
done
mv -- "$tmp" "$out_file"
trap - EXIT
printf 'wrote %s\n' "$out_file"
github-master — running scripts safely in GitHub Actions.docker-expert — robust container entrypoint scripts.python-expert — when a script outgrows the shell.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub miaoge-ge/coding-agent-skills --plugin bash-scripting-expert