bash-stylelisted
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