agentsclimarketplace

Bash scripting

Skill Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack/plugins/devtools-pack/skills/bash-scripting

When to activate: bash, shell script, sh, set -e, trap, argument parsing, heredoc, parallel, cron script, automationFrom its SKILL.md

Install
npx -y skills add Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack --skill bash-scripting

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.5 KB, 996 tokens by cl100k_base, as published. Nobody here has run it

Bash Scripting Patterns

Script Header (always use)

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_NAME="$(basename "$0")"

Error Handling with trap

cleanup() {
  local exit_code=$?
  echo "[${SCRIPT_NAME}] Cleaning up (exit: ${exit_code})" >&2
  rm -f /tmp/myapp-lock
  exit "${exit_code}"
}
trap cleanup EXIT INT TERM

die() {
  echo "[ERROR] $*" >&2
  exit 1
}

[[ -f config.yaml ]] || die "config.yaml not found"

Argument Parsing

usage() {
  cat <<EOF
Usage: ${SCRIPT_NAME} [OPTIONS]

Options:
  -e, --env ENV       Environment (dev|staging|prod)  [required]
  -t, --tag TAG       Docker image tag                [default: latest]
  -d, --dry-run       Print commands, don't execute
  -h, --help          Show this help
EOF
}

ENV=""
TAG="latest"
DRY_RUN=false

while [[ $# -gt 0 ]]; do
  case $1 in
    -e|--env)    ENV="$2";  shift 2 ;;
    -t|--tag)    TAG="$2";  shift 2 ;;
    -d|--dry-run) DRY_RUN=true; shift ;;
    -h|--help)   usage; exit 0 ;;
    *)           die "Unknown option: $1" ;;
  esac
done

[[ -n "${ENV}" ]] || die "--env is required"
[[ "${ENV}" =~ ^(dev|staging|prod)$ ]] || die "Invalid env: ${ENV}"

Run or Dry-Run Helper

run() {
  echo "+ $*" >&2
  if [[ "${DRY_RUN}" == "false" ]]; then
    "$@"
  fi
}

run kubectl apply -f deployment.yaml
run helm upgrade myapp ./chart --atomic

Retry with Backoff

retry() {
  local max_attempts=$1; shift
  local delay=5
  local attempt=1
  until "$@"; do
    if (( attempt >= max_attempts )); then
      echo "[ERROR] Command failed after ${max_attempts} attempts: $*" >&2
      return 1
    fi
    echo "[WARN] Attempt ${attempt}/${max_attempts} failed. Retrying in ${delay}s..." >&2
    sleep "${delay}"
    (( attempt++ ))
    (( delay = delay * 2 ))
  done
}

retry 5 curl -sf https://api.example.com/health

Parallel Execution

# Run jobs in parallel, wait for all, capture failures
pids=()
for region in us-east-1 eu-west-1 ap-southeast-1; do
  ./deploy.sh --region "${region}" &
  pids+=($!)
done

failed=0
for pid in "${pids[@]}"; do
  if ! wait "${pid}"; then
    echo "[ERROR] Job ${pid} failed" >&2
    (( failed++ ))
  fi
done
(( failed == 0 )) || die "${failed} deployment(s) failed"

Heredoc for Config

cat > /etc/myapp/config.yaml <<EOF
environment: ${ENV}
database:
  host: ${DB_HOST:-localhost}
  port: ${DB_PORT:-5432}
  name: myapp_${ENV}
log_level: ${LOG_LEVEL:-info}
EOF

Logging Functions

info()  { echo "[$(date -u +%T)] [INFO]  $*"; }
warn()  { echo "[$(date -u +%T)] [WARN]  $*" >&2; }
error() { echo "[$(date -u +%T)] [ERROR] $*" >&2; }

info "Starting deployment to ${ENV}"
warn "This will restart the service"

Key Rules

  • set -euo pipefail on every script — e exits on error, u catches unset vars, o pipefail catches pipe failures
  • Quote every variable: "${VAR}" not $VAR — prevents word splitting on spaces
  • Use [[ ]] not [ ] — safer string comparisons, no word splitting
  • Prefer printf over echo for portable output
  • ShellCheck every script: shellcheck myscript.sh

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Gives 0 of the 12 instructions most automation workflows skills give in 996 tokens

Counted across 745 of the 1,008 authors here whose files we hold, read 2026-08-07

  • Write conventional commit messagesin 36 of 745, across 35 files
  • Delete branches after mergein 30 of 745, across 21 files
  • Make atomic commitsin 25 of 745, across 15 files
  • Write minimal code to pass testsin 22 of 745, across 10 files
  • Re-snapshot after navigation or DOM changesin 21 of 745, across 13 files
  • Use try-catch for error handlingin 20 of 745, across 8 files
  • Run tests before committingin 20 of 745, across 12 files
  • Write tests before implementationin 20 of 745, across 8 files
  • Configure branch protection rulesin 19 of 745, across 5 files
  • Explain the why in commit messagesin 19 of 745, across 9 files
  • Refactor code while tests remain greenin 19 of 745, across 6 files
  • Interact with elements using refsin 19 of 745, across 11 files

Said here and by no other author read

  • Use double brackets for tests
  • Use strict mode with pipefail on every script
  • Write scripts using Bash shell
  • Implement cleanup traps on exit
  • Provide command-line usage help
  • Run ShellCheck on every script

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 326,367. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.