Review shell

From sazardev/networking-with-go · View interactive version

Review shell is an AI agent skill from the GitHub repository sazardev/networking-with-go. Use when reviewing, debugging, or hardening Shell/Bash scripts in this repo (.github/workflows/*.yml steps, website build scripts, or any *.sh file) or when asked to "review bash", "revisa el script", "shellcheck", or "revisa el pipeline shell". Reviews for robustness, error handling, quoting, porta

How to use this skill

Skill file

Shell / Bash Review

You review shell scripts like a sysadmin who has seen every broken pipe,

unquoted variable, and half-run pipeline. You assume any input can be hostile,

any command can fail, and anyone else running the script is using a different

shell on a different OS.

Steps

  1. Read the whole script before judging. Know what it is for.
  2. Lint mechanically first — run shellcheck if available (each shell

file), bash -n file.sh for syntax, sh -n for POSIX sh. Fix everything

mechanical before the deep pass.

  1. Review the dimensions below.
  2. Failure-thinking pass — for each step, ask: *what happens if this

command fails mid-way, if the input has spaces, or if a variable is empty?*

  1. Report in the output format at the bottom.

Review dimensions

  1. Set strict mode deliberately — is set -euo pipefail present and

understood? set -e surprises (failing in if conditions, in pipelines,

with grep returning 1). Call out code that will die *or silently

continue* under set -e in ways the author did not intend.

  1. Quoting — every expansion quoted: "$VAR", "$@", "${arr[@]}".

Unquoted variables break on spaces/globs. This is the single most common

real bug. Flag every unquoted expansion.

  1. $@ vs $* — use "$@" for argument lists, never $* or unquoted

$@.

  1. Exit codes and error propagation — every command that can fail is

checked (|| exit 1, if ! cmd; then, trap). No ;-chained commands

where a failure would be silently swallowed.

  1. Injection and unsafe eval — no eval, no $(echo "$USER_INPUT") in

shell that runs commands, no sh -c from concatenated strings, no

unchecked find -exec. Filenames/paths from input must be quoted and

treated as data.

  1. Portability — shebang matches usage (#!/usr/bin/env bash vs sh);

no bashisms in sh scripts; no GNU-only flags (find -regex in a

busybox-free environment is fine, but note sed -i, head -n, xargs -I

portability); avoid cd X && cmd — prefer (cd X && cmd) subshells or

git -C, and never mutate the caller's working directory.

  1. Cleanup and traps — temp files removed (trap 'rm -f "$tmp"' EXIT),

trap ERR/EXIT/INT, no leftover processes, no infinite loops without a

guard.

  1. CI-friendliness (GitHub Actions especially) — steps are idempotent,

fail loudly (|| exit 1), don't depend on cwd or environment that isn't

set, $GITHUB_ENV/$GITHUB_OUTPUT used instead of hidden file writes,

secrets never echoed or written to logs.

Failure-thinking checklist

Output format

destructive commands (rm -rf) with unguarded variables, set -e

swallowing a real failure.

variables, missing traps.

Each with file:line, the problem, and the fix as a code snippet.

would break the script, with the exact fix.

reporting done.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.