agentleFS
AltinityAltinity/clickhouse-sink-connector/.claude/skills/code-quality-bash/SKILL.md

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

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
  1. Very specific:

    Shellcheck-clean: Run shellcheck in CI; treat its warnings as real findings, not noise to suppress.

    line 40
  2. Very specific:

    Run this over every changed .sh file during pr-self-review's per-language pass.

    line 58
  3. Very specific:

    Parsing ls output: instead of globbing or find -print0 / read -d ''.

    line 64
  4. Very specific:

    Hardcoded temp paths: instead of mktemp, risking collisions or leftover state between runs.

    line 72
  5. Very specific:

    Word-splitting on $@ vs "$@": when forwarding arguments to another command.

    line 74

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

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 .sh file in this repo
  • A user asks for "worldclass / robust" Bash
  • Reviewing a build, CI, or operational script for correctness

Core Rules

  1. 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).
  2. Quote every variable expansion: "$var", "${array[@]}". Unquoted expansions are the single most common source of word-splitting and globbing bugs.
  3. Check exit codes explicitly where set -e isn't enough (inside a conditional, inside a pipeline you need to inspect PIPESTATUS for).
  4. Prefer [[ ]] over [ ] for conditionals — safer word-splitting behavior and supports pattern matching.
  5. local for function-scoped variables — avoid leaking state between functions in anything beyond a trivial script.
  6. mktemp for temp files/dirs, cleaned up with a trap ... EXIT, not a hardcoded path that can collide or leak.
  7. Shellcheck-clean. Run shellcheck in 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/
done

Deep Review Checklist (Bash)

Run this over every changed .sh file during pr-self-review's per-language pass.

  1. Missing set -euo pipefail (or a deliberate, commented exception).
  2. Unquoted variable/command-substitution expansions, especially around filenames that might contain spaces.
  3. Parsing ls output instead of globbing or find -print0 / read -d ''.
  4. Unchecked exit codes on commands whose failure should abort the script but currently doesn't (especially inside a pipeline, where pipefail is required to catch it).
  5. Destructive commands (rm -rf, truncation, overwrite-in-place) without a DESTRUCTIVE: comment and the safeguards described in destructive-operation-safety.
  6. Hardcoded temp paths instead of mktemp, risking collisions or leftover state between runs.
  7. 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.

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.

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.