Agent skill

Bash Scripting

by ericrisco in ericrisco/rsc-harness

A skill your agent uses when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks…

MITAuto-check passedDevelopment

Install Bash Scripting

skills CLI
$ npx skills add ericrisco/rsc-harness --skill bash-scripting -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ericrisco/rsc-harness bash-scripting --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ericrisco/rsc-harness.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/bash-scripting .claude/skills/bash-scripting && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
bash-scripting
GitHub stars
167
Token cost
~2.5k tokens
SKILL.md length
1,071 words
Files
5 (incl. scripts, references)
Skills in repo
227
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks…

  • Works in 3 steps: In an assignment with command… → In a condition. Anything in if, while,… → Inside functions called in a condition:…
  • Hardening a shell script that must survive another machine — a CI step
  • SKILL.md covers The header you start every…, Pick your shell first, Strict mode, honestly and Quoting — the highest-value…, plus 5 more sections
  • Runs Shell scripts from its folder; calls shellcheck, bash and curl

What it does

Bash Scripting is an agent skill from ericrisco/rsc-harness. Use when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks, quoting/word-splitting, arrays, trap cleanup, bash-vs-POSIX portability, ShellCheck findings. NOT CI workflow structure, runners, caching or matrix (that is github-actions).

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts and reference files (for example `evals/README.md`, `evals/cases.yaml` and `references/portability.md`).

It sits in Development, covering Shell scripting and Scheduled and recurring tasks. It works with Bash, Git and GitHub Actions. The repository describes itself as: Your agent invents things because it has no memory, and can't touch your database because it has no arms. rsc is the meta-harness that gives it both, plus the trade to know the… The licence is MIT.

When your agent uses it

  • Hardening a shell script that must survive another machine — a CI step
  • Devcontainer entrypoint: strict-mode leaks
  • Quoting/word-splitting
  • Bash-vs-POSIX portability

Example prompts

  • “/bash-scripting”

Requirements

  • A Bash shell
  • Docker

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. In an assignment with command substitution. local x=$(failing) — the
  2. In a condition. Anything in if, while, &&, ||, or after ! is
  3. Inside functions called in a condition: a failing line won't abort.

What it can do on your machine

Read from SKILL.md and the folder at commit e3d5b33. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • shellcheck
    • bash
    • curl
    • docker

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use curl and docker, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Bash Scripting loads about 2.5k tokens when it runs, and up to ~3.5k if it reads all its reference files. Until then it costs about 91 tokens; SKILL.md has 1,071 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~91
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from ericrisco/rsc-harness at commit e3d5b33, republished under its MIT licence (© ericrisco). 1,071 words, ~2,505 tokens.

Download SKILL.mdSave it as .claude/skills/bash-scripting/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
bash-scripting
description
Use when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks, quoting/word-splitting, arrays, trap cleanup, bash-vs-POSIX portability, ShellCheck findings. NOT CI workflow structure, runners, caching or matrix (that is `github-actions`).
tags
bash, shell, shellcheck, posix, scripting
recommends
github-actions, error-handling, docker, secure-coding
origin
risco

Bash scripting — scripts that survive a stranger's machine

You are the shell author who has been burned: by an unquoted "$@" that exploded a path with spaces, by rm -rf "$DIR/" where $DIR was empty, by a trap that fired twice, by a set -e that swore it caught errors and didn't. Write every script as if it will run in CI, in a container, and on a 2014 Mac with bash 3.2 — because eventually it will.

The first decision is not a line of code. It is: which shell am I targeting? That choice decides what you are allowed to write. Make it before the shebang.

The header you start every bash script with

bash
#!/usr/bin/env bash
set -euo pipefail        # see "Strict mode, honestly" — this is a baseline, not a force field
IFS=$'\n\t'              # split words on newline/tab only, never on spaces
  • #!/usr/bin/env bash — find bash on PATH; do not hardcode /bin/bash, which is 3.2 on macOS and may not exist on some images.
  • set -e — exit on an uncaught non-zero command. Leaky (below), still worth having.
  • set -u — error on an unset variable, so a typo'd $OUPUT fails loud instead of expanding to empty.
  • set -o pipefail — a pipeline fails if any stage fails, not just the last. Bashism — not in POSIX sh.
  • IFS=$'\n\t' — stops the classic "unquoted expansion splits on every space" bug at the source.

Pick your shell first

set -o pipefail, arrays, [[ ]], and local are bashisms. If your shebang is #!/bin/sh you may not get bash — on Debian/Alpine sh is dash/busybox.

#!/usr/bin/env bash#!/bin/sh (POSIX)
Where it runsanywhere bash is installedevery Unix; the only safe choice for an unknown box
You GAINarrays, [[ ]], pipefail, local, ${var,,}, process substitution <(…)maximal portability, smaller deps
You LOSEnothing (if bash is guaranteed)all the above — POSIX sh has none of them
Lint withshellcheck script.shshellcheck -s sh script.sh
Test withbash script.shdash script.sh

Two traps to internalize: macOS /bin/bash is 3.2 (no declare -A, no ${var,,}, no mapfile); and bash 5.3 added ${ cmd; } / GLOBSORT / read -E that will not run on either of the above. Pick a floor and stay above it — the full bash-vs-POSIX feature matrix, bash 3.2 workarounds, dash/busybox gotchas, the 5.3 features to guard, and how to test one script under several shells are in references/portability.md.

Strict mode, honestly

set -e is not a force field. It is silently suppressed in three places, and people ship broken scripts because they trusted it:

  1. In an assignment with command substitution. local x=$(failing) — the assignment succeeds (exit status is the local/assignment, not the substitution).
  2. In a condition. Anything in if, while, &&, ||, or after ! is exempt by design — set -e would make if grep … unusable otherwise.
  3. Inside functions called in a condition: a failing line won't abort.

So: do not lean on set -e for control flow. Check what matters explicitly.

bash
# Bad — set -e will NOT catch this; x is empty, script sails on
local x=$(curl -fsS "$url")

# Good — split declaration from assignment so the substitution's status is seen
local x
x=$(curl -fsS "$url") || { echo "fetch failed" >&2; return 1; }

trap 'echo "failed at line $LINENO" >&2' ERR gives you a breadcrumb on the uncaught failures set -e does catch. To deliberately ignore a non-zero exit, say so: cmd || true (and a comment why), never a bare unchecked cmd.

Quoting — the highest-value section

Unquoted expansions are the №1 cause of shell bugs and of the data-loss story everyone has heard. Quote every expansion unless you have a specific reason not to.

BadGoodWhy
rm $filerm "$file"space/glob in $file becomes multiple args (SC2086)
func $@func "$@""$@" preserves each arg verbatim; $@ re-splits them
x=$(cmd) … echo $xecho "$x"unquoted output word-splits and glob-expands
[ $x = y ][ "$x" = y ]empty/spaced $x makes [ a syntax error
for f in $(ls)for f in ./*parsing ls breaks on spaces/newlines (SC2045)
rm -rf $DIR/see belowthe disaster

The rm -rf disaster: if $DIR is unset/empty, rm -rf $DIR/ becomes rm -rf /. Guard the variable and quote it:

bash
: "${DIR:?DIR must be set}"   # abort with a message if unset or empty
rm -rf "${DIR:?}"/           # belt and braces: fail rather than expand to /

Use [[ … ]] in bash (no word-splitting inside, supports =~, &&); use [ … ] in POSIX sh. [ a == b ] is a bashism — POSIX [ uses =.

Show full SKILL.md (450 more words)Show less

Arrays, not space-split strings

The instant an argument list is built from a string, spaces betray you. Build it as an array and expand "${arr[@]}" (each element stays one argument).

bash
# Bad — flags string splits wrong if any value contains a space
flags="--name my project --force"
docker run $flags image          # 5 args, "my" and "project" split apart

# Good — array; "${flags[@]}" expands to exactly 4 arguments
flags=(--name "my project" --force)
docker run "${flags[@]}" image

Iterating files: never parse ls. Use a glob, or find -print0 with a NUL-delimited read so even newlines in names are safe.

bash
# Good — glob; the ./ prefix protects files named like "-rf"
for f in ./*.txt; do
  [ -e "$f" ] || continue       # guard the no-match case (glob stays literal)
  process "$f"
done

# Good — robust against spaces AND newlines in filenames
find . -name '*.log' -print0 | while IFS= read -r -d '' f; do
  process "$f"
done

macOS bash 3.2 has no mapfile/readarray; the find -print0 loop above is the portable way to collect names.

Cleanup with traps

A script that creates temp state must remove it even when interrupted. Register one EXIT trap right after you create the resource — EXIT fires on normal exit, on set -e abort, and after INT/TERM, so you don't need per-signal traps.

bash
tmp=$(mktemp -d)                          # never a fixed /tmp/foo path (race + collision)
trap 'rm -rf "$tmp"' EXIT                 # one trap, covers every exit path

work_in "$tmp"

Make cleanup idempotent (rm -rf tolerates a missing dir) so a double-fire or a re-entry is harmless. Track background PIDs and reap them in the same trap:

bash
server & srv_pid=$!
trap 'kill "$srv_pid" 2>/dev/null; rm -rf "$tmp"' EXIT

Input & variables

PatternUse
: "${1:?usage: deploy <env>}"require an argument, abort with a message
env="${1:-staging}"default when omitted
readonly ROOT="$PWD"constants that must not be reassigned
local x (bash)function-scope a variable so it doesn't leak (not POSIX)

Option parsing uses getopts (POSIX, single-dash flags):

bash
verbose=0; out=""
while getopts ":vo:" opt; do
  case "$opt" in
    v) verbose=1 ;;
    o) out="$OPTARG" ;;
    *) echo "usage: $0 [-v] [-o FILE]" >&2; exit 2 ;;
  esac
done
shift $((OPTIND - 1))

Use printf '%s\n' "$x" instead of echo "$x" for arbitrary data — echo's handling of -n/-e and backslashes is not portable.

Run ShellCheck — and fix, don't silence

ShellCheck v0.11.0 (2025-08) is the canonical static analyzer. Run it on every script; it catches most of the above before runtime.

bash
shellcheck script.sh             # bash target
shellcheck -s sh script.sh       # verify POSIX-sh compliance

Codes worth memorizing: SC2086 (unquoted expansion → quote it), SC2046 (unquoted $(…) word-splits), SC2164 (cd without || exit), SC2155 (local x=$(cmd) masks the command's exit status — declare then assign).

Silence a finding only with a justified directive on the line directly above it, never project-wide:

bash
# shellcheck disable=SC2086  # word-splitting is intentional: $flags is a flag list we control
some_cmd $flags
# shellcheck source=lib/common.sh   # resolve a dynamic `source` for cross-file analysis
. "$dir/common.sh"

Wire shellcheck into CI as a run: step — the workflow scaffolding around it belongs to ../github-actions/SKILL.md, the shell inside the step belongs here.

Anti-patterns

Anti-patternWhy it bitesDo instead
for x in $(ls *.txt)breaks on spaces/newlines; SC2045for x in ./*.txt; do [ -e "$x" ] || continue
Unquoted $var / $@word-split + glob; SC2086always "$var" / "$@"
cd "$d"; rm -rf .if cd fails you rm the wrong dir; SC2164cd "$d" || exit 1
Trusting set -e for control flowleaks in assignments/conditions/functionscheck explicitly: cmd || { …; exit 1; }
local x=$(cmd)masks cmd exit status; SC2155local x; x=$(cmd) || return 1
Bash 5.3 / declare -A in a 3.2 or sh target"command not found" on the user's boxpick a floor; see references/portability.md
echo "$untrusted" for datanon-portable -n/-e/backslash handlingprintf '%s\n' "$x"
[ a == b ] under #!/bin/sh== is a bashism; dash errorsPOSIX uses [ a = b ]
Fixed temp path /tmp/buildrace + collision + no cleanuptmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
pipefail in a #!/bin/sh scriptnot POSIX; dash ignores or errorsuse bash, or check pipeline status another way

© ericrisco, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/bash-scripting of ericrisco/rsc-harness.

  • SKILL.md
  • evals/README.md
  • evals/cases.yaml
  • references/portability.md
  • scripts/verify.sh

Open the folder on GitHubat commit e3d5b33

Compare with similar skills

Bash Scripting next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Bash Scripting compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bash Scripting this skillericrisco/rsc-harness167—~2.5kAutomated safety check: PassMIT
Sake CI Releasekattouf/Sake116—~731Automated safety check: PassMIT
Batch Filesgithub/awesome-copilot40k1 repos~4.3kAutomated safety check: PassMIT
Hns Moaiadk Dev Referencemodu-ai/moai-adk1.2k—~937Automated safety check: PassApache-2.0
Audit Standardsjeremylongshore/tons-of-skills-marketplace2.8k—~1.8kAutomated safety check: NotesMIT
Bats Shell Testing Patternswshobson/agents40k12 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Sake CI Release

    kattouf/Sake

    A skill your agent uses when working on CI workflows, GitHub Actions, release process, changelog generation (git-cliff), or dependabot configuration.

    116 GitHub stars~731 tokensUpdated 6 mo ago
    DevelopmentAuto-check passed
  • Batch Files

    github/awesome-copilot

    Official

    Expert-level Windows batch file (.bat/.cmd) skill for writing, debugging, and maintaining CMD scripts.

    40k GitHub starsUsed in 1 repo~4.3k tokens
    DevelopmentAuto-check passed
  • moai-adk-go local dev reference — version management/release process (sec 5), shell-script hook development (sec 7), build & dev commands (sec 10).

    1.2k GitHub stars~937 tokensUpdated today
    DevelopmentAuto-check passed
  • Audit Standards

    jeremylongshore/tons-of-skills-marketplace

    Audits the current project against the development standards defined in ~/.claude/CLAUDE.md.

    2.8k GitHub stars~1.8k tokensUpdated today
    Agent WorkflowsAuto-check: notes
  • Writes unit tests for shell scripts with Bats: error-condition tests, fixtures and mocks, cross-shell checks, parallel runs, helper files and CI integration.

    40k GitHub starsUsed in 12 repos~1.3k tokens
    Testing & QAAuto-check passed
  • A catalog of recurring bug shapes in the Mole Mac cleaner, used to review safety-sensitive diffs for deletion safety, unbounded commands, shell traps and weak tests.

    70k GitHub stars~2k tokensUpdated today
    DevelopmentAuto-check passed

More from ericrisco/rsc-harness

All 227 skills in this repo
  • Ab Testing

    ericrisco/rsc-harness

    A skill your agent uses when designing or analyzing a controlled experiment — falsifiable hypothesis, sample size from an MDE, reading significance/CI/power, CUPED, or rescuing tests that won't go…

    167 GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Accessibility

    ericrisco/rsc-harness

    A skill your agent uses when making a web UI conform to WCAG 2.2 Level AA — axe-core or Lighthouse a11y violations, keyboard operability, focus management, ARIA roles/names/live regions, contrast…

    167 GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Ads

    ericrisco/rsc-harness

    A skill your agent uses when running or fixing paid acquisition on Google or Meta — campaign structure (Performance Max, Demand Gen, Search, Advantage+), platform-fit creative, budget/scaling rules…

    167 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Agent Eval

    ericrisco/rsc-harness

    A skill your agent uses when measuring whether an LLM or agent system actually got better and gating merges on it: golden sets, fixing an inflated LLM-as-judge, scoring RAG (faithfulness, contextual…

    167 GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • AI Media

    ericrisco/rsc-harness

    A skill your agent uses when a creative goal must become a finished media file: pick and order generative-media models per modality — AI voiceover, image-to-video clips, score — then glue them with…

    167 GitHub stars~3.3k tokensUpdated today
    Auto-check passed
  • Analytics

    ericrisco/rsc-harness

    A skill your agent uses when instrumenting product or web analytics — GA4/PostHog SDK wiring, event taxonomy, funnels, double-counted events, consent gating, PII scrubbing.

    167 GitHub stars~2.8k tokensUpdated today
    Auto-check passed

Categories

Questions about Bash Scripting

What does Bash Scripting do?

A skill your agent uses when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks…. Bash Scripting is an agent skill from ericrisco/rsc-harness. Use when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks, quoting/word-splitting, arrays, trap cleanup, bash-vs-POSIX portability, ShellCheck findings.

When should I use Bash Scripting?

Bash Scripting fits situations like: hardening a shell script that must survive another machine — a CI step; devcontainer entrypoint: strict-mode leaks; quoting/word-splitting; bash-vs-POSIX portability.

How do I install Bash Scripting in Claude Code?

Run `npx skills add ericrisco/rsc-harness --skill bash-scripting -a claude-code`. Or copy the skill folder (skills/bash-scripting in ericrisco/rsc-harness) into .claude/skills/bash-scripting in your project. Claude Code loads it when a task matches its description.

How do I install Bash Scripting in Codex?

Run `npx skills add ericrisco/rsc-harness --skill bash-scripting -a codex`. Or copy the skill folder (skills/bash-scripting in ericrisco/rsc-harness) into .agents/skills/bash-scripting in your project. Codex loads it when a task matches its description.

Can I use Bash Scripting in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ericrisco/rsc-harness --skill bash-scripting -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bash-scripting, .gemini/skills/bash-scripting, .github/skills/bash-scripting and .opencode/skills/bash-scripting in your project.

What does Bash Scripting need to run?

Going by SKILL.md and its folder, Bash Scripting needs a shell for the scripts in its folder and the command-line tools its instructions call (shellcheck, bash, curl and docker). Our summary lists: A Bash shell; Docker.

Does Bash Scripting access the network?

SKILL.md contains no URLs. Its commands use curl and docker, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Bash Scripting safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Bash Scripting use?

Bash Scripting is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Bash Scripting use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1k tokens, read only when the agent opens those files.

What are the alternatives to Bash Scripting?

Skills that share tags, products or a category with Bash Scripting: Sake CI Release (kattouf/Sake, 116 stars), Batch Files (github/awesome-copilot, 40k stars), Hns Moaiadk Dev Reference (modu-ai/moai-adk, 1.2k stars) and Audit Standards (jeremylongshore/tons-of-skills-marketplace, 2.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bash Scripting?

ericrisco (a GitHub user) maintains it in ericrisco/rsc-harness, which has 167 GitHub stars. The repository holds 227 skills in this directory. The repository was last updated on October 7, 2026.

Source: ericrisco/rsc-harness on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.