skills/bash-best-practices/SKILL.md
Write, review, and debug robust Bash scripts. Make sure to use this skill whenever the user needs help with shell scripts (bash, sh), asks to write a CLI tool in bash, debugs a failing shell script, or needs to ensure predictable behavior in CI/CD or production systems, even if they do not explicitly ask for best practices.
npx skillsauth add hrdtbs/agent-skills bash-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert Systems Administrator and Senior Backend Engineer. Your goal is to write defensive, strict bash scripts that behave predictably in production.
Start scripts with set -euo pipefail.
Why: This makes your script fail fast and loudly on errors (-e), undefined variables (-u), and hidden failures in pipelines (-o pipefail), preventing silent data corruption or unpredictable behavior.
Note: Use command || true or if ! command; then ... if a command is expected to fail.
Double-quote variables (e.g., "${FILE_PATH}"). Use ${VAR} for clean delineation.
Why: Quoting prevents word splitting and globbing issues, especially when file paths or user inputs contain spaces or special characters. It ensures the variable is treated as a single literal string.
Prefer Bash's [[ ]] over POSIX [ ].
Why: [[ ]] is safer and provides more features. It handles empty strings gracefully without quoting tricks, supports regex matching (=~), and allows built-in logical operators (&&, ||) directly inside the brackets.
Use local for variables inside functions.
Why: By default, variables in Bash are global. Using local prevents accidental namespace pollution and weird side-effects when one function modifies a variable that another function is relying on.
Prefer $() over backticks `.
Why: $() is more visually distinct, easier to read, and crucially, it can be nested easily without needing complicated escaping rules.
function keyword or name() but be consistent. Usually my_func() { ... } is preferred for POSIX compatibility, but function my_func() { ... } is fine in Bash. Stick to one style.trap for cleanup. If your script creates temporary files or starts background processes, use trap to ensure they are cleaned up even if the script crashes or is interrupted.
TMP_DIR=$(mktemp -d)
trap 'rm -rf "${TMP_DIR}"' EXIT
stderr (>&2) instead of stdout.
echo "Error: Directory not found" >&2
ls output.
ls output will break on these filenames, causing unintended operations. Use globbing (for file in *.txt) or find instead.echo to print variables that might contain hyphens.
-e or -n, echo interprets it as a flag, swallowing the text and silently altering output. Use printf '%s\n' "${var}" instead.cat to pipe a single file into a command (UUOC).
grep "error" < file.txt) or pass the file as an argument.Example 1: Safe Variable Quoting
Input: echo $USER_INPUT
Output: printf '%s\n' "${USER_INPUT}"
Example 2: Iterating Over Files Input:
for file in $(ls *.txt); do
echo "Processing $file"
done
Output:
for file in *.txt; do
# Avoid error if no match
[[ -e "${file}" ]] || break
printf 'Processing %s\n' "${file}"
done
Example 3: Function Scoping Input:
my_func() {
count=5
echo "Count is $count"
}
Output:
my_func() {
local count=5
printf 'Count is %s\n' "${count}"
}
testing
Evaluate Agent Skill design quality against official specifications and best practices. Use when reviewing, auditing, or improving SKILL.md files and skill packages. Provides multi-dimensional scoring and actionable improvement suggestions.
testing
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
development
Evaluate and score user-written LLM prompts on a 100-point scale across 5 axes (Clarity, Structure, Information Content, Specificity, Context), providing specific improvement suggestions and a revised prompt. Make sure to use this skill whenever the user asks to evaluate, review, score, or improve a prompt, or when they say things like 'このプロンプトどう?', 'プロンプトを評価して', 'rate my prompt', 'review this prompt', or 'is this prompt good enough?'. This skill focuses on scoring existing prompts, not writing new ones from scratch.
testing
Apply prompt engineering best practices to write, refine, and optimize system prompts, user prompts, and agent instructions. Use this skill whenever the user wants to write a prompt, optimize an existing prompt for better results, fix a prompt that is hallucinating or underperforming, or structure prompts for Large Language Models (LLMs). Even if the user just says "help me write instructions for my agent", trigger this skill.