aboutsummaryrefslogtreecommitdiff
path: root/languages/bash/CLAUDE.md
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-23 21:13:26 -0400
committerCraig Jennings <c@cjennings.net>2026-06-23 21:13:26 -0400
commit36262858461711bcb104896007a513691113fee8 (patch)
tree333cc7ea0998c43c2b6af76aa6eeb1ee3d0b0f2c /languages/bash/CLAUDE.md
parent71db71b9d47ffbeaf1d1c859fa3e3bebb7b2ea29 (diff)
downloadrulesets-36262858461711bcb104896007a513691113fee8.tar.gz
rulesets-36262858461711bcb104896007a513691113fee8.zip
feat(languages): add bash/shell bundle
Shell-heavy projects had no bundle that fit. archangel and archsetup are bash repos, and installing elisp or python gave them the wrong language rules. I added languages/bash on the go bundle's shape. The bundle ships bash.md and bash-testing.md rules, a PostToolUse hook that runs shellcheck on edited shell files and blocks on a violation, a shellcheck pre-commit githook, settings.json wiring, gitignore-add.txt, and a "Bash/shell project" CLAUDE.md. The hook covers .sh, .bash, and extensionless files with a shell shebang, since the CLI tools that fill a shell repo carry no extension. shellcheck is the gate. shfmt stays out of the blocking path because shell has no canonical formatting style, and forcing tabs-vs-spaces would impose a contested choice. Both the hook and the githook are shellcheck-clean against their own rule. I extended the Makefile test target to discover languages/*/tests/*.bats, so the bundle's 8 hook tests run with the rest of the suite. The README bundle table was stale, listing elisp only. I corrected it to the five bundles now shipping.
Diffstat (limited to 'languages/bash/CLAUDE.md')
-rw-r--r--languages/bash/CLAUDE.md71
1 files changed, 71 insertions, 0 deletions
diff --git a/languages/bash/CLAUDE.md b/languages/bash/CLAUDE.md
new file mode 100644
index 0000000..2511c47
--- /dev/null
+++ b/languages/bash/CLAUDE.md
@@ -0,0 +1,71 @@
+# CLAUDE.md
+
+## Project
+
+Bash/shell project. Customize this section with your own description, layout,
+and conventions.
+
+**Typical layout:**
+- `bin/` or top-level `*.sh` — entry-point scripts
+- `lib/*.sh` — sourced function libraries (no `set -e`; the caller owns the shell)
+- `tests/*.bats` — bats-core tests beside the scripts they exercise
+
+## Build & Test Commands
+
+If the project has a Makefile, document targets here. Common pattern:
+
+```bash
+make test # run the bats suite
+make test FILE=tests/x.bats # one file
+make lint # shellcheck across the tree
+make fmt # shfmt -w (if the project adopts shfmt)
+```
+
+Direct equivalents: `bats -r tests/`, `shellcheck script.sh`,
+`shfmt -d script.sh` (diff), `shfmt -w script.sh` (write).
+
+## Language Rules
+
+See rule files in `.claude/rules/`:
+- `bash.md` — code style and patterns (strict mode, quoting, `[[ ]]`, traps)
+- `bash-testing.md` — bats conventions
+- `verification.md` — verify-before-claim-done discipline
+
+## Git Workflow
+
+Commit conventions: see `.claude/rules/commits.md` (author identity,
+no AI attribution, message format).
+
+Pre-commit hook in `githooks/` scans for secrets and runs `shellcheck` on staged
+shell files. Activate on a fresh clone with `git config core.hooksPath githooks`.
+
+## Problem-Solving Approach
+
+Investigate before fixing. When diagnosing a bug:
+1. Read the relevant script and trace what actually happens
+2. Identify the root cause, not a surface symptom
+3. Write a failing bats test that captures the correct behavior
+4. Fix, then re-run tests
+
+## Testing Discipline
+
+TDD is the default: write a failing test before any implementation. If you can't
+write the test, you don't yet understand the change. Details in
+`.claude/rules/bash-testing.md`.
+
+## Editing Discipline
+
+A PostToolUse hook runs `shellcheck` on every shell file after Edit/Write/
+MultiEdit and blocks on a violation — read the SCxxxx code and fix it (each has a
+wiki page). The hook covers `.sh`, `.bash`, and extensionless files with a shell
+shebang. Formatting (`shfmt`) is recommended but not enforced by the hook, since
+shell has no single canonical style; adopt one per project via `.editorconfig`.
+
+## What Not to Do
+
+- Don't add features beyond what was asked
+- Don't refactor surrounding code when fixing a bug
+- Don't leave expansions unquoted or use `[ ]` where `[[ ]]` fits
+- Don't add comments to code you didn't change
+- Don't commit `.env` files, credentials, or API keys — the pre-commit hook
+ catches common patterns but isn't a substitute for care