code-quality-bash
Skill345 starsChanged 35 days agoApache-2.0View on GitHub
Use when writing or reviewing shell scripts in this repo (build helpers, CI scripts, anything under scripts/), or when asked for "worldclass"/"robust" Bash. Covers strict-mode, quoting, error handling, and a deep review checklist for the defect classes that make shell scripts silently do the wrong thing.
- Deletes or force-pushes
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- clickhouse-sink-reviewSkill
- code-quality-architectureSkill
- code-quality-goSkill
- code-quality-jvmSkill
- code-quality-pythonSkill
- code-quality-sqlSkill
- code-reuse-firstSkill
- code-reuse-reviewSkill
- design-note-debtSkill
- destructive-operation-safetySkill
- mandatory-code-change-validationSkill
- pr-self-reviewSkill
- repro-harness-negative-proofSkill
- sink-connector-mysql-source-of-truthSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Shellcheck-clean: Run shellcheck in CI; treat its warnings as real findings, not noise to suppress.
- Very specific: line 58
Run this over every changed .sh file during pr-self-review's per-language pass.
- Very specific: line 64
Parsing
lsoutput: instead of globbing or find -print0 / read -d ''. - Very specific: line 72
Hardcoded temp paths: instead of mktemp, risking collisions or leftover state between runs.
- Very specific: line 74
Word-splitting on
$@vs"$@": when forwarding arguments to another command.
≈ “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
Worldclass Bash
Overview
Robust, defensive shell scripting for this project's build and CI helper scripts. Shell is easy to get subtly wrong — unquoted variables, unchecked exit codes, and word-splitting bugs are the dominant defect classes, not style.
When to Use
- Writing or reviewing any
.shfile in this repo - A user asks for "worldclass / robust" Bash
- Reviewing a build, CI, or operational script for correctness
Core Rules
- Strict mode at the top of every script:
set -euo pipefail— exit on error, exit on unset variable, and make a pipeline fail if any stage fails (not just the last one). - Quote every variable expansion:
"$var","${array[@]}". Unquoted expansions are the single most common source of word-splitting and globbing bugs. - Check exit codes explicitly where
set -eisn't enough (inside a conditional, inside a pipeline you need to inspectPIPESTATUSfor). - Prefer
[[ ]]over[ ]for conditionals — safer word-splitting behavior and supports pattern matching. localfor function-scoped variables — avoid leaking state between functions in anything beyond a trivial script.mktempfor temp files/dirs, cleaned up with atrap ... EXIT, not a hardcoded path that can collide or leak.- Shellcheck-clean. Run
shellcheckin CI; treat its warnings as real findings, not noise to suppress.
# BAD
for f in $(ls *.txt); do
cp $f /tmp/backup/
done
# GOOD
set -euo pipefail
for f in *.txt; do
[[ -e "$f" ]] || continue
cp -- "$f" /tmp/backup/
doneDeep Review Checklist (Bash)
Run this over every changed .sh file during pr-self-review's
per-language pass.
- Missing
set -euo pipefail(or a deliberate, commented exception). - Unquoted variable/command-substitution expansions, especially around filenames that might contain spaces.
- Parsing
lsoutput instead of globbing orfind -print0/read -d ''. - Unchecked exit codes on commands whose failure should abort the
script but currently doesn't (especially inside a pipeline, where
pipefailis required to catch it). - Destructive commands (
rm -rf, truncation, overwrite-in-place) without aDESTRUCTIVE:comment and the safeguards described indestructive-operation-safety. - Hardcoded temp paths instead of
mktemp, risking collisions or leftover state between runs. - Word-splitting on
$@vs"$@"when forwarding arguments to another command.
Anti-Patterns
Missing strict mode · unquoted expansions · parsing ls · ignoring
shellcheck warnings · hardcoded /tmp paths without mktemp ·
destructive operations with no dry-run or confirmation path.
Sources
ShellCheck documentation · Google Shell Style Guide
(google.github.io/styleguide/shellguide.html) · bash strict-mode
conventions (set -euo pipefail).
Cross-References
pr-self-review, destructive-operation-safety.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

