agentleFS
ku5icku5ic/claude-kit/skills/bash-patterns/SKILL.md

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.

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
  1. Distinctive:

    Default assumption: bash 5.x targeting macOS (via Homebrew bash) and Linux.

    line 8

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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/bash 3.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

FileCovers
reference/safety-flags.mdScript preamble, set -euo pipefail edge cases, inherit_errexit, nullglob, verification before shipping
reference/quoting.mdQuoting 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.mdFunctions 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.mdSubshell semantics, | pitfalls, process substitution <(cmd), filesystem operations
reference/shellcheck.mdTop SC codes, suppression discipline, POSIX-only contexts (Alpine, BusyBox)
reference/anti-patterns.mdFifteen review-time anti-patterns with severity calls

References

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.

Download now (ZIP)

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.