Auto-activate for .sh files, #!/bin/bash, #!/usr/bin/env bash. Bash scripting expertise following Google Shell Style Guide. Produces shell scripts following Google Shell Style Guide with proper error handling, quoting, and safety patterns. Use when: writing shell scripts, automating tasks, processing text, or creating CLI tools. Covers error handling, variable quoting, function patterns, and portable scripting. Not for Python/Ruby scripts that happen to call shell commands.
From flownpx claudepluginhub cofin/flow --plugin flowThis skill uses the workspace's default tool permissions.
references/patterns.mdreferences/safety.mdreferences/style.mdSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Bash is the default shell on most Linux distributions. This skill covers idiomatic scripting patterns following the Google Shell Style Guide, with emphasis on safety, readability, and maintainability.
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
| Flag | Effect |
|---|---|
set -e | Exit immediately on non-zero return |
set -u | Error on unset variables |
set -o pipefail | Pipe returns rightmost non-zero exit code |
IFS=$'\n\t' | Safer word splitting (no space splitting) |
| Rule | Good | Bad |
|---|---|---|
| Function declaration | my_func() { ... } | function my_func { ... } |
| Local variables | local file_path="$1" | file_path=$1 |
| Constants | readonly MAX_RETRIES=3 | MAX_RETRIES=3 |
| Variable expansion | "${var}" | $var |
| Command substitution | "$(command)" | `command` |
| Declare + assign | local out; out="$(cmd)" | local out="$(cmd)" |
| File test | [[ -f "${file}" ]] | [ -f $file ] |
| Code | Issue | Fix |
|---|---|---|
| SC2086 | Unquoted variable | Double-quote: "${var}" |
| SC2046 | Unquoted command sub | Quote or use mapfile |
| SC2155 | Declare and assign together | Separate into two statements |
| SC2034 | Unused variable | Add export or # shellcheck disable=SC2034 |
Every script begins with the shebang, strict mode, and a usage comment block describing purpose, usage, and examples.
Organize logic into functions. Use local for all function-scoped variables. Use main() as the entry point, called at the bottom with main "$@".
Use getopts for simple flags, or manual while [[ $# -gt 0 ]] parsing for long options. Always validate required arguments and print usage on error.
Use trap cleanup EXIT for any script that creates temporary files, acquires locks, or needs to restore state on failure.
Validate the script with shellcheck script.sh before committing. Fix all warnings; disable specific rules only with a justifying comment.
"${var}" everywhereshellcheck on every script; it catches the majority of common bash pitfallslocal variables prevent accidental global state leakseval unless absolutely necessary — it is the most common source of injection vulnerabilities in shell scripts[[ ]] not [ ] — double brackets prevent word splitting and support regex matchingmktemp for temporary files — never hardcode /tmp/myscript.tmp; it creates race conditionsls output — use globs (*.txt) or find with -print0 and read -d '' for safe file iterationBefore delivering a script, verify:
#!/usr/bin/env bash and set -euo pipefail"${var}"localtrap cleanup EXIT is set if the script creates temporary resources-h or --helpA safe script template with error handling, argument parsing, and cleanup:
#!/usr/bin/env bash
#
# Deploy an application to the target environment.
#
# Usage:
# deploy.sh [-v] [-e environment] <app_name>
#
set -euo pipefail
IFS=$'\n\t'
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly TMPDIR="$(mktemp -d)"
cleanup() {
rm -rf "${TMPDIR}"
}
trap cleanup EXIT
usage() {
cat <<EOF
Usage: $(basename "$0") [-v] [-e environment] <app_name>
Options:
-v Verbose output
-e ENVIRONMENT Target environment (default: staging)
-h Show this help
EOF
}
main() {
local verbose=false
local environment="staging"
while getopts ":ve:h" opt; do
case "${opt}" in
v) verbose=true ;;
e) environment="${OPTARG}" ;;
h) usage; exit 0 ;;
:) echo "Error: -${OPTARG} requires an argument" >&2; exit 1 ;;
?) echo "Error: Unknown option -${OPTARG}" >&2; exit 1 ;;
esac
done
shift $((OPTIND - 1))
if [[ $# -eq 0 ]]; then
echo "Error: app_name is required" >&2
usage >&2
exit 1
fi
local app_name="$1"
if [[ "${verbose}" == true ]]; then
echo "Deploying ${app_name} to ${environment}..."
fi
# Build and deploy logic here
echo "Deployed ${app_name} to ${environment} successfully."
}
main "$@"
</example>
For detailed guides and code examples, refer to the following documents in references/: