bash-patterns
Skill2 starsChanged 7 days agoMITView on GitHub
Bash and shell script patterns for safety flags, quoting, conditionals, traps, functions, ShellCheck discipline, and review-worthy anti-patterns. Use whenever the project contains `.sh`/`.bash`/`.zsh` files, files with a bash/sh shebang, scripts in `bin/`, shell dotfiles, or Makefile recipes, OR the user asks about shell scripting or a shell pipeline, even if "bash" is not mentioned by name.
In this repository37 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- templates/CLAUDE.mdCLAUDE.md
- auditSkill
- backup-patternsSkill
- depsSkill
- django-patternsSkill
- docker-patternsSkill
- drf-patternsSkill
- engineering-fundamentalsSkill
- fastapi-patternsSkill
- git-patternsSkill
- go-patternsSkill
- graphql-patternsSkill
- investigateSkill
- javascript-patternsSkill
- logging-patternsSkill
- referenceSkill
- metaSkill
- monitoring-patternsSkill
- next-app-router-patternsSkill
- nuxt-patternsSkill
- opentofu-patternsSkill
- prSkill
- python-patternsSkill
- react-patternsSkill
- report-formatSkill
- security-patternsSkill
- slop-patternsSkill
- storybook-patternsSkill
- tailwind-patternsSkill
- test-patternsSkill
- typescript-patternsSkill
- unslopSkill
- vps-provisioningSkill
- vue-patternsSkill
- wcag-auditSkill
- writeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Default assumption: bash 5.x targeting macOS (via Homebrew bash) and Linux.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bash patterns
- Default assumption: bash 5.x targeting macOS (via Homebrew bash) and Linux.
- Scripts use
#!/usr/bin/env bash, so the resolved binary is whatever is first on PATH -- on the user's machine that's the Homebrew 5.x build, not the stock macOS/bin/bash3.2. - Anything that requires bash 4.0+ (case modification,
mapfile) or 4.4+ (${parameter@op}) is unsafe under stock macOS bash; flagged here when the version cut matters.
Reference files
| File | Covers |
| reference/safety-flags.md | Script preamble, set -euo pipefail edge cases, inherit_errexit, nullglob, verification before shipping |
| reference/quoting.md | Quoting rules, nested quoting, heredoc indentation, printf over echo, zsh-vs-bash differences |
| reference/conditionals.md | [[ ]] over [ ], glob vs literal, numeric vs string comparison, (( )), case |
| reference/functions-and-traps.md | Functions and locals, trap patterns, BASH_LINENO / BASH_SOURCE / caller debug introspection |
| reference/parameter-expansion.md | ${var:-}, ${var:?}, prefix/suffix removal, pattern substitution, case modification |
| reference/subshells-and-pipes.md | Subshell semantics, | pitfalls, process substitution <(cmd), filesystem operations |
| reference/shellcheck.md | Top SC codes, suppression discipline, POSIX-only contexts (Alpine, BusyBox) |
| reference/anti-patterns.md | Fifteen review-time anti-patterns with severity calls |
References
- GNU Bash manual: https://www.gnu.org/software/bash/manual/bash.html
- POSIX shell command language: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
- ShellCheck wiki: https://www.shellcheck.net/wiki/
- BashFAQ: https://mywiki.wooledge.org/BashFAQ
- BashPitfalls: https://mywiki.wooledge.org/BashPitfalls
- BashGuide: https://mywiki.wooledge.org/BashGuide
- Google Shell Style Guide: https://google.github.io/styleguide/shellguide.html
Version notes
Checked: 2026-09-26 against https://ftp.gnu.org/gnu/bash/, https://tiswww.case.edu/php/chet/bash/NEWS, https://github.com/koalaman/shellcheck/releases
- 5.3 (2025-07-30; Homebrew 5.3.20): no guidance change; no 6.0 release exists. ShellCheck 0.11.0 (2025-08-04) current.
- 4.4:
shopt -s inherit_errexit,${parameter@op}(corrected from 4.0 per NEWS). 4.0: case modification,mapfile.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

