← ClaudeAtlas

bash-stylelisted

Bash script coding conventions and bats testing: shebang (#!/bin/bash), set -euxCo pipefail, cd "$(dirname "$0")", usage function with heredoc, readonly constants, SCREAMING_SNAKE_CASE constants, snake_case variables/functions, _snake_case local variables, bats test structure (test-helper/, setup/teardown lifecycle, run/status/output assertions). Load whenever writing, reviewing, or refactoring any Bash script (.sh files, shell scripts) or bats test (.bats files) — new files, bug fixes, function design, project setup, writing tests. Also load when PLANNING or DISCUSSING Bash/shell script implementation or test design, even before any code is written. Without this skill, you will use wrong conventions (missing set flags, wrong naming, no usage function, no readonly, wrong test directory structure) that this user explicitly does not want.
furedea/agent-harness · ★ 1 · Code & Development · score 67
Install: claude install-skill furedea/agent-harness
# Shell Script Coding Style Guidelines ## File Header (every script) Every shell script must start with these three lines in order: ```sh #!/bin/bash set -euxCo pipefail cd "$(dirname "$0")" ``` - `#!/bin/bash` — run with bash explicitly, not sh - `set -euxCo pipefail`: - `-e`: exit on error - `-u`: exit on undefined variable reference - `-x`: print each command to stderr before execution (debug mode) - `-C`: prohibit overwriting files with `>` (use `>|` to force) - `-o pipefail`: fail if any command in a pipe chain fails - `cd "$(dirname "$0")"` — change to the script's own directory so relative paths work regardless of where the caller invoked the script from To suppress debug output for a section, bracket it: ```sh set +x # ... noisy or sensitive section ... set -x ``` ## usage Function Every script must define a `usage` function that prints documentation to stderr and exits with failure. Use heredoc + redirect inside the function body: ```sh function usage() { cat <<EOF >&2 Description: Description of this script. Usage: $0 [OPTIONS] <FILE> Options: --version, -v: print "$(basename "$0")" version --help, -h: print this EOF exit 1 } ``` Call `usage` for `--help`/`-h` flags and for invalid argument combinations. ## Constants Declare constants with `readonly`. Names use `SCREAMING_SNAKE_CASE`: ```sh readonly INPUT_DIR="../data/input" readonly MAX_RETRY=3 ``` Always quote the right-hand side — values may contain spaces o