diff --git a/.claude/rules/bash-style.md b/.claude/rules/bash-style.md index 3227323..36c50b3 100644 --- a/.claude/rules/bash-style.md +++ b/.claude/rules/bash-style.md @@ -20,7 +20,7 @@ Complements CLAUDE.md. Does not repeat rules already defined there. ## Naming -- `UPPER_CASE` — exported env vars and constants +- `UPPER_CASE` — exported env vars and constants; use `readonly` for true constants - `snake_case` — local variables and function names - `verb_noun` pattern for functions: `set_ps1_prompt`, `docker_aws_login` - Meaningful names, no single letters except loop counters (`i`, `f`) @@ -51,6 +51,15 @@ function do_thing() { - Single quotes for literals that must not expand - `printf` over `echo` when output contains escapes or format strings +## Resource Cleanup + +- Consider `trap cleanup EXIT` with `mktemp` when scripts create temporary files/dirs or acquire resources; skip when it would add unnecessary complexity (short scripts, no temp state) + +## Structured Data + +- Prefer `jq` for JSON and `yq` for YAML over ad-hoc `grep`/`awk`/string splitting +- Treat parser errors as fatal; check exit status before using results + ## Commands - Long options for clarity: `--recursive` not `-r` (common test flags `-f`, `-d`, `-e` are fine)