bash-scripting-safe

bash-scripting-safe is a skill for Claude Code, Codex from vikasudasi/skill-vault. It costs 38 tokens per session (1,121 once invoked), scanned A, original, Apache-2.0.

A guide to writing Bash shell scripts that handle errors, spaces in filenames, variables, and file operations safely. Bash is a command-line language commonly used for automation on Linux and macOS.

In plain words
What is it for?
Use it to write automation scripts with strict error handling, safe quoting, reliable pipelines, careful filename processing, and repeatable operations.
Why use it?
It reduces the risk of scripts silently failing, using the wrong files, or deleting or changing more data than intended.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to write automation scripts with strict error handling, safe quoting, reliable pipelines, careful filename processing, and repeatable operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vikasudasi/skill-vault/bash-scripting-safe
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add vikasudasi/skill-vault --skill bash-scripting-safe
Clone the repo
git clone --depth 1 https://github.com/vikasudasi/skill-vault

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for bash-scripting-safe

README.md
[![agentmods](https://agentmods.dev/badge/skills/vikasudasi/skill-vault/bash-scripting-safe/github.svg)](https://agentmods.dev/skills/vikasudasi/skill-vault/bash-scripting-safe)
Your own site
<a href="https://agentmods.dev/skills/vikasudasi/skill-vault/bash-scripting-safe"><img src="https://agentmods.dev/badge/skills/vikasudasi/skill-vault/bash-scripting-safe/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for bash-scripting-safe

Your own site · 80×15
<a href="https://agentmods.dev/skills/vikasudasi/skill-vault/bash-scripting-safe"><img src="https://agentmods.dev/badge/skills/vikasudasi/skill-vault/bash-scripting-safe.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,121 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.01121
Opus 5.5 $0.00015 $0.00448
Sonnet 5.5 $0.00008 $0.00224
Haiku 4.5 $0.00004 $0.00112

Measured 1mo ago against content hash 4c194271d342, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

bash-scripting-safe scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/safe_template.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skill_vault/data/skills/bash-scripting-safe/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Safe Bash Scripting

Use when writing a shell script that must not corrupt files, delete the wrong thing, or silently fail. Bash is powerful precisely because it's dangerous — the discipline below is what makes it safe.

Always start with these three lines

#!/usr/bin/env bash
set -euo pipefail
  • -e — exit on first failing command (no silent mid-script failure).
  • -u — error on unset variable (catches typos like $file vs $files).
  • -o pipefail — a failing command anywhere in a pipeline fails the pipeline.

Add IFS=$'\n\t' when you parse output: it changes Bash's default word-splitting (space, tab, newline) to just newline + tab, so filenames containing spaces no longer get split into multiple arguments.

Quote everything (word splitting is the #1 data-loss path)

dir="$1"                          # quote expansions
for f in "$dir"/*.txt; do         # quotes + glob
  cp "$f" "$dest/"
done

Unquoted $var undergoes word splitting (splits on spaces) and globbing (* and ? expand). The classic disaster:

# WRONG — if "$file" contains a space, rm deletes multiple files; glob expansion is worse
rm $file

# RIGHT
rm -- "$file"

A variable is only safe unquoted when you intend splitting/globbing. Prefer "$@"-style quoting everywhere else.

Redirects and atomic file writes

  • Use a temp file + mv for atomic writes; never > straight onto a file you also read later in the same script (it truncates the input mid-run):
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT          # clean up scratch even on error
grep foo input.txt > "$tmp"
mv "$tmp" output.txt              # atomic swap
  • mktemp for scratch files (safer than hard-coded /tmp/name which can collide or be a symlink). trap ... EXIT guarantees cleanup on failure.
  • Beware set -e + empty globs: "$dir"/*.txt with no matches stays a literal *.txt string — check with shopt -s nullglob or test existence.

Error handling

if ! command -v jq >/dev/null 2>&1; then
  echo "jq is required" >&2
  exit 1
fi

Read the full file on GitHub · 123 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 123 lines · 38 tokens per session scan A 4c194271d342

Subscribe to this mod's changes

bash-scripting-safe is a skill published in the GitHub repository vikasudasi/skill-vault (0 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 38 tokens to every session and 1,121 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

shell-scripting

Use this skill when writing bash or zsh scripts, parsing arguments, handling errors, or automating CLI workflows. Triggers on bash scripting, shell scripts, argument parsing, process substitution, here documents, signal trapping, exit codes, and any task requiring portable shell script development.

alibaba/anolisa · 60 tokens

shell-scripting

A guide to writing Bash shell scripts, which automate command-line tasks on Linux and similar systems. It covers variables, arrays, conditions, loops, functions, and safer script structure.

chaterm/terminal-skills · 13 tokens

bash-scripting

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…

ericrisco/rsc-harness · 82 tokens

mainframe

Discover MAINFRAME read-only shell helpers and route durable agent authority through its control plane when available.

gtwatts/mainframe · 22 tokens

mainframe

Pi shell policy, explicit task checkpoints, and runtime status. Use for Mainframe status, shell-policy questions, or resuming checkpointed project work.

gtwatts/mainframe · 33 tokens

bash-defensive-patterns

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

martineserios/thebrana · 36 tokens