/sota-skills:sota-shell-scriptingfrom SOTA Engineering Skills
Produces defensive bash/PowerShell scripts and audits existing ones for unquoted expansions, silent error swallowing, injection, secret leakage, and temp-file races. Use when writing, reviewing, or trusting shell code.
Ships in SOTA Engineering Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Produce shell scripts that survive contact with reality — unusual filenames, missing commands, partial failures, hostile input, signals, and concurrent invocation — and audit existing scripts for the defect classes that cause most production shell incidents: unquoted expansions, silent error swallowing, injection, secret leakage, and temp-file races.
Bash-focused (written for bash 5.x; macOS ships bash 3.2 and defaults to zsh — see portability
rules). POSIX sh only when the target demands it (busybox/dash containers, init systems).
Do NOT use shell when any of these hold. Recommend Python/Go (or the project's primary language) instead, and say so explicitly in BUILD and AUDIT output:
jq one-liner, sets).jq/yq.wait".Shell is the right tool for: gluing processes together, CI steps, container entrypoints, small install/deploy wrappers, environment setup — anything that is mostly invoking other programs rather than computing.
When writing or modifying shell scripts:
#!/usr/bin/env bash unless the target is a minimal
container/init context that only guarantees POSIX sh. Never #!/bin/sh with bashisms.set -euo pipefail,
trap-based cleanup, IFS discipline — and know where set -e does NOT fire."$var", "$@", "$(cmd)". Build commands with arrays,
never with string concatenation.--help.mktemp + trap cleanup, atomic writes via
mv, check-before-create, flock if concurrent runs are possible.shellcheck (treat all findings as blockers, suppress only with a justifying
comment) and shfmt -d before declaring done. If they are unavailable locally, ask the
operator to install them (router principle 6); only if they decline, state that and flag CI
must run them.--help always; --version for distributed tools; set -x behind a
DEBUG/TRACE env guard, never unconditionally (secret leakage).Coverage: every rules/ file's Audit checklist applies in AUDIT mode. Mark one not applicable only with its reason in the report — never skip a file because the thing it checks for is absent, since that absence may be the finding.
When reviewing existing shell scripts, hunt the defect classes in rules/ files bottom-up
(each rules file ends with an audit checklist of grep patterns and ShellCheck codes).
Run shellcheck -S style on every script if available; correlate findings with context —
ShellCheck flags symptoms, you judge exploitability and blast radius.
Severity conventions:
| Severity | Meaning | Examples |
|---|---|---|
| CRITICAL | Exploitable or data-destroying now | eval on untrusted input; unquoted var in rm -rf; secrets in argv/set -x; curl|bash of unpinned URL in prod |
| HIGH | Will corrupt/fail on realistic input or failure | unquoted expansions in destructive paths; missing set -e/error checks around critical steps; predictable temp files; non-atomic config writes; missing exec in entrypoint (signals lost) |
| MEDIUM | Latent bug or fragility | parsing ls; which instead of command -v; missing pipefail; no -- separators; no timeouts on network calls; echo for variable data |
| LOW | Style/maintainability with safety implications | missing local; [ ] where [[ ]] intended; missing readonly; inconsistent error messages |
Finding format:
[SEVERITY] file:line — short title (SCxxxx if applicable)
Evidence: the offending line(s), verbatim
Impact: what input/condition triggers it and what breaks
Fix: concrete replacement code
Effort: trivial | small | medium | large
| File | Covers |
|---|---|
| rules/01-safety-baseline.md | Shebang discipline, set -euo pipefail and its real limitations, quoting & word-splitting bug catalog, zsh-vs-bash deviations that bite pasted commands (joining, pipestatus; the full table, NOMATCH included, is rules/06 §1) · a background job's "exit 0" is the launcher's, not the work's (§2a), and a failed push or write may have landed — read it back before retrying, never --force first (§2b) |
| rules/07-powershell.md | PowerShell has no set -euo pipefail, and the line everyone omits is the one that matters: $PSNativeCommandUseErrorActionPreference defaults to $false, so $ErrorActionPreference = 'Stop' silently tolerates a failed git/docker/terraform (§1) · The same failure classes as bash with different mechanisms: three disagreeing status variables and a $? that does not climb out of a function, pwsh -Command letting the last statement decide a CI step's verdict, GitHub Actions' built-in shell being safe while a custom shell: string silently drops its fail-fast and exit propagation, Invoke-Expression as eval, execution policy as the control that is not a security boundary, and PSScriptAnalyzer where ShellCheck cannot reach |
| rules/06-ad-hoc-commands.md | rg -r is --replace, not recursive — the grep -r symlink trap inverted, fabricating false CONTENT instead of a false absence (§2a) · The commands nobody commits — a sweep, a probe, a one-liner from a checklist, a quick container copy: the zsh deviations that bite pasted commands (joining, pipestatus, NOMATCH faking a clean sweep, a pipe into python3 - <<EOF that bash discards and zsh runs as code), what your searcher silently excludes (-r vs symlinked dirs, ripgrep's gitignore defaults, a grep that is really a wrapper) and controlling a sweep in the same invocation, a pattern beginning with - parsed as a flag (clean zero, error on the stderr you suppressed, §2c), **` |
| rules/09-listing-and-selection.md | A lister's default cap answers with exit 0 and an empty stderr, so a page reads as a population (§5) · The tools that enumerate rather than search: gh pr list returning 30 of 330 with no flag and no warning, the --limit you set for a different question and then counted with, server-side counts and --paginate as the fix, reconciling two methods that disagree to a named cause — and the selector that picked a neighbouring population (§5a): newest is not default, apparent size is not blocks freed, a forwarded port is not the VM you started, a path is not the volume it is on, a prefix glob (X_*) also matches X_other_*, an empty %(upstream:track) is a stale local ref (a branch deleted on the remote reads as in sync until git fetch --prune), and the only tell is a value that cannot belong to the thing you asked about — and the filter that drops the file you named (§5b): an --include='*.rb' filter beside a named config.ru means grep never reads config.ru on BSD, ugrep or GNU, so the probe exits 1 like a clean codebase — and selecting processes by command-line substring selects the selector (§5c): `ps |
| rules/08-ad-hoc-side-effects.md | "I am only checking something" bounds nothing — a read-only intent is not a read-only command · The sibling of rules/06: that file is a check returning the wrong answer, this one is a check with side effects. An ad-hoc command that fills a disk or corrupts the runtime it was inspecting (§3), an experiment with no memory ceiling, where macOS accepts no memory rlimit (§3a), and a backgrounded wait loop that exhausts the process table (§4) — which does not degrade, it hits a ceiling where every tool fails at once, including cleanup, since ps, killall and even echo in a fresh shell all need to fork; a command with no input source that blocks on an agent shell's open-socket stdin until the tool's timeout (§5), a crash on purpose leaving the OS's crash reports behind (§3b), and a command handed to a human: copied from the one you ran, never retyped, and with no # lines, which interactive zsh runs as commands (§6) |
| rules/05-constructs-and-cleanup.md | jq in a script (§4a): a regex code point is \x{HHHH} (\uHHHH in a pattern silently matches other text), and x? on a wrong type ends the program at exit 0 · In-place edits (sed -i, perl -pi) replace a symlink and leave a hard link stale · zsh habits that break silently in bash and sh (§5a): ** matches one level, a piped while loses its count, (( j++ )) ends a set -e script on bash 5 but not macOS's 3.2, and a zero-padded 08 fails arithmetic in August · Sourcing a script to test one function relocates it — BASH_SOURCE points at the copy and the script cds itself away, silently (§3a) · The constructs a script is assembled from, once the expansion itself is right: arrays for command building (SC2089/2090), IFS scoping, trap-based cleanup and mktemp (predictable temp paths are a race, not a style point; an ERR trap without set -E is silent inside functions), [[ ]]/printf/local/readonly, and globbing pitfalls including never parsing ls; rewriting a script while it runs changes what it runs (§3d); a heredoc inside a heredoc closes the outer one, and the rest runs as shell (§3e) |
| rules/02-robustness-correctness.md | Argument parsing (getopts/while-case, --help/--version), input validation, POSIX vs bash portability, stderr/exit-code discipline, PIPESTATUS, command -v, network timeouts & retries, flock & background jobs, idempotency & atomic writes, safe filename handling; any $( ) whose producer can find nothing — a grep -c count, a grep -n-then-cut or grep -o extraction, git grep, jq -e — ends a set -e script with no message; close it with || true |
| rules/03-security.md | Why --severity=style catches real defects, and a pointer to who owns local gate reproduction (§7) · eval/injection, secrets discipline (argv/env/set -x), PATH hygiene — including the non-adversarial mirror: a wrapper, shim, alias or function override that invokes a name its own namespace shadows, which fills the process table with no bound at all while the function form merely segfaults — sudo discipline, curl|bash both directions, temp-file races, umask, ShellCheck+shfmt in CI |
| rules/04-ci-and-operational.md | Killing a backgrounded build by pid orphans the compiler, and the next run's contention reads as a defect in your change · GitHub Actions shell pitfalls (${{ }} injection, multiline run, quoting in YAML), container entrypoints (exec, PID 1, privilege drop), Makefile shell gotchas, long-running script logging, gating a push or publish on a check (&&, never ;) |
#!/usr/bin/env bash + set -euo pipefail on every bash script — and explicit error
handling where -e is known not to fire (conditions, &&/||, command substitution
in assignments-with-modifiers, process substitution)."$var", "$@", "${arr[@]}", "$(cmd)". SC2086 is a
bug, not style."${args[@]}". Never accumulate a
command in a string and eval/word-split it.trap cleanup EXIT with an idempotent cleanup function; temp paths only via mktemp.eval, bash -c, or sh -c with interpolated untrusted data; use -- before
positional file/user arguments to every command that supports it.set -x — including sh -x script
run to debug it, which traces even [ -n "$KEY" ]; set +x around sensitive
sections; read secrets from files or fds.script: failed to X: $detail); meaningful exit codes;
never exit 0 on failure paths.--fail, --max-time/timeouts, and bounded retries — never bare
curl url | ....find -print0 | xargs -0 / -exec ... +, while IFS= read -r,
never iterate $(ls) or unquoted globs from variables.${{ }} injection, action pinning → sota-devsecopssota-secrets-managementsota-sandboxing, sota-cloud-infrastructuresota-python / sota-golangrules/01-safety-baseline.md (opens in a new tab)rules/02-robustness-correctness.md (opens in a new tab)rules/03-security.md (opens in a new tab)rules/04-ci-and-operational.md (opens in a new tab)rules/05-constructs-and-cleanup.md (opens in a new tab)rules/06-ad-hoc-commands.md (opens in a new tab)rules/07-powershell.md (opens in a new tab)rules/08-ad-hoc-side-effects.md (opens in a new tab)rules/09-listing-and-selection.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
bash, powershell, shellcheck, defensive-scripting, ci-scripts, entrypoints
npx claudepluginhub martinholovsky/sota-skills --plugin sota-skills2 plugins ship this exact skill · first indexed Nov 26, 2026
43 skills in this plugin
/sotaMaster router for the SOTA engineering skills library. Use this skill whenever the user asks to build, design, implement, refactor, harden, optimize, review, or audit an application, service, or codebase and the request spans more than one domain — or when you are unsure which specific sota-* skill applies. Also use when working on a codebase you do not own: reviewing a pull request or diff, responding to code review, evaluating someone else's patch, or preparing an upstream contribution — including mid-session, once you are already reading source, a diff, or CI config. It maps the task (build or audit mode) to the right domain and language skills (Rust, Go, C/C++, JVM, Python, JS/TS, .NET/C#, PHP, Ruby, Swift). Trigger keywords: SOTA, best practices, audit my code, security review, compliance, hardening, prod readiness, code quality, pull request, PR review, review comment, maintainer feedback, patch, diff, upstream, contribute, merge request./sota-api-designState-of-the-art API design and audit guidance (2026) covering REST/HTTP, GraphQL, gRPC, WebSockets/SSE/realtime, webhooks, versioning/evolution, and API security/operations. Use when designing or building any API surface (endpoints, schemas, protos, realtime channels, webhook senders/receivers) AND when auditing/reviewing existing APIs for correctness, evolvability, security, and operational robustness. Not for browser UI, rendering, or client-framework concerns — use sota-web-frameworks or sota-frontend-design. Trigger keywords: API, REST, GraphQL, gRPC, endpoint, websocket, SSE, realtime, WebRTC, webhook, versioning, OpenAPI, pagination, idempotency, rate limit, problem+json, protobuf, deprecation.Other plugins' skills for the same job