plugins/bash-development/skills/bash-development/SKILL.md
This skill should be used when the user asks to "write a bash script", "create a shell script", "implement bash function", "parse arguments in bash", "handle errors in bash", or mentions bash development, shell scripting, script templates, or modern bash patterns.
npx skillsauth add jamie-bitflight/claude_skills bash-developmentInstall 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.
Core patterns and best practices for Bash 5.1+ script development. Provides modern bash idioms, error handling, argument parsing, and pure-bash alternatives to external commands.
Every script starts with the essential header:
#!/usr/bin/env bash
set -euo pipefail
set options explained:
-e - Exit immediately on command failure-u - Treat unset variables as errors-o pipefail - Pipeline fails if any command failsSCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
readonly SCRIPT_VERSION="1.0.0"
readonly SCRIPT_NAME SCRIPT_DIR
Implement trap-based error handling for robust scripts.
Code examples
Standard argument parsing template.
Code examples
Always use curly braces and quote variables:
# Correct
"${variable}"
"${array[@]}"
# Incorrect
$variable
${array[*]} # Use [@] for proper iteration
Use readonly for constants:
readonly CONFIG_FILE="/etc/app/config"
readonly -a VALID_OPTIONS=("opt1" "opt2" "opt3")
Note: Never use readonly in sourced scripts - it causes errors on re-sourcing.
Prefer native bash parameter expansion over external tools:
# Trim whitespace
trimmed="${string#"${string%%[![:space:]]*}"}"
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
# Lowercase/Uppercase (Bash 4+)
lower="${string,,}"
upper="${string^^}"
# Substring extraction
substring="${string:0:10}" # First 10 chars
suffix="${string: -5}" # Last 5 chars
# Replace patterns
replaced="${string//old/new}" # Replace all
replaced="${string/old/new}" # Replace first
# Strip prefix/suffix
no_prefix="${string#prefix}" # Shortest match
no_prefix="${string##*/}" # Longest match (basename)
no_suffix="${string%suffix}" # Shortest match
no_suffix="${string%%/*}" # Longest match
# Declaration
declare -a indexed_array=()
declare -A assoc_array=()
# Safe iteration with nullglob
shopt -s nullglob
for file in *.txt; do
process "${file}"
done
shopt -u nullglob
# Array length
length="${#array[@]}"
# Append element
array+=("new_element")
# Iterate with index
for i in "${!array[@]}"; do
printf '%d: %s\n' "${i}" "${array[i]}"
done
# Read file to string
content="$(<"${file}")"
# Read file to array (Bash 4+)
mapfile -t lines < "${file}"
# Check file conditions
[[ -f "${file}" ]] # Regular file exists
[[ -d "${dir}" ]] # Directory exists
[[ -r "${file}" ]] # Readable
[[ -w "${file}" ]] # Writable
[[ -x "${file}" ]] # Executable
[[ -s "${file}" ]] # Non-empty
# Safe temp file creation
temp_file=$(mktemp)
trap 'rm -f "${temp_file}"' EXIT
Use [[ ]] for conditionals (bash-specific, more powerful):
# String comparisons
[[ "${var}" == "value" ]] # Equality
[[ "${var}" == pattern* ]] # Glob matching
[[ "${var}" =~ ^regex$ ]] # Regex matching
# Numeric comparisons
(( num > 10 )) # Arithmetic comparison
[[ "${num}" -gt 10 ]] # Traditional syntax
# Compound conditions
[[ -f "${file}" && -r "${file}" ]]
[[ "${opt}" == "a" || "${opt}" == "b" ]]
Code examples
printf over echo for portability and control[[ ]] over [ ] for string comparisonsFor detailed patterns and examples:
development
When an application needs to store config, data, cache, or state files. When designing where user-specific files should live. When code writes to ~/.appname or hardcoded home paths. When implementing cross-platform file storage with platformdirs.
testing
Enforce mandatory pre-action verification checkpoints to prevent pattern-matching from overriding explicit reasoning. Use this skill when about to execute implementation actions (Bash, Write, Edit) to verify hypothesis-action alignment. Blocks execution when hypothesis unverified or action targets different system than hypothesis identified. Critical for preventing cognitive dissonance where correct diagnosis leads to wrong implementation.
tools
Reference guide for the Twelve-Factor App methodology — 15 principles (12 original + 3 modern extensions) for building portable, resilient, cloud-native applications. Use when evaluating application architecture, designing cloud-native services, reviewing codebases for methodology compliance, advising on configuration, scaling, observability, security, and deployment patterns. Incorporates the 2025 open-source community evolution and cloud-native reinterpretations of each factor.
tools
Converts user-facing documentation (how-to guides, tutorials, API references, examples) in any format — Markdown, PDF, DOCX, PPTX, XLSX, AsciiDoc, RST, HTML, Jupyter notebooks, man pages, TOML/YAML/JSON configs, and plain text — into Claude Code skill directories with SKILL.md plus thematically grouped references/*.md files. Use when given a docs directory or mixed-format documentation to transform into an AI skill. Uses MCP file-reader server for binary formats.