bash-ops

bash-ops is a skill for Claude Code, Codex from 0xDarkMatter/claude-mods. It costs 108 tokens per session (3,411 once invoked), scanned C, original, MIT.

A guide to writing defensive Bash shell scripts for automation, continuous integration, and agent-facing tools. It covers strict error handling, cleanup, argument parsing, exit codes, and keeping machine-readable output separate from messages.

In plain words
What is it for?
Use it for production shell scripts, CI steps, automation, and scripts shipped with a skill. It covers strict mode, ShellCheck, traps, temporary files, option parsing, input handling, and stdout/stderr conventions.
Why use it?
It helps unattended scripts fail clearly without leaving partial or corrupted state. It also gives a way to decide when a task has become too complex for Bash and should use Python instead.

Skill for Claude CodeCodex

Part of the claude-mods plugin — 50 skills, 3 commands, 3 agents, 4 hooks shipped together

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.

agentmods
npx agentmods add skills/0xdarkmatter/claude-mods/bash-ops
Any agent
npx skills add 0xDarkMatter/claude-mods --skill bash-ops
Clone the repo
git clone --depth 1 https://github.com/0xDarkMatter/claude-mods

Made for: Claude Code, Codex.

Or install claude-mods, the plugin that ships this one along with the rest of its 50 skills, 3 commands, 3 agents, 4 hooks.

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-ops

README.md
[![agentmods](https://agentmods.dev/badge/skills/0xdarkmatter/claude-mods/bash-ops.svg)](https://agentmods.dev/skills/0xdarkmatter/claude-mods/bash-ops)
Your own site
<a href="https://agentmods.dev/skills/0xdarkmatter/claude-mods/bash-ops"><img src="https://agentmods.dev/badge/skills/0xdarkmatter/claude-mods/bash-ops.svg" alt="Measured on agentmods" height="20"></a>
Per session 108 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,411 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
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 $0.00108 $0.03411
Opus 5 $0.00054 $0.01706
Sonnet 5 $0.00022 $0.00682
Haiku 4.5 $0.00011 $0.00341

Measured 4d ago against content hash bb4c0f6300ab, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

bash-ops scanned grade C with 2 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 4d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (assets/script-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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- `mktemp -d` for a temp **directory**; clean it with `rm -rf -- "$tmpdir"`.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

this — they branch on registry exit codes, so a non-zero `curl` must not kill the
skills/bash-ops/SKILL.md · 231 lines

How it starts

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

Bash Operations

Defensive Bash for scripts that run unattended — CI steps, automation, and the scripts/ a skill ships. The goal: a script that fails loudly on the first problem, never corrupts state, and emits parseable output.

This is the house standard for any shell script in this repo. The script contract below is the same one enforced by docs/SKILL-RESOURCE-PROTOCOL.md §2–§7 — that protocol governs every skill resource, and its rules are bash rules. Treat the two as one standard: the resource protocol decides what a skill script must guarantee (streams, exit codes, help block); this skill teaches how to write the Bash that delivers it. The canonical reference implementation is skills/supply-chain-defense/scripts/preinstall-check.sh — read it whenever you need a worked example of every rule here applied at once.

Bash vs Python — choose before you write

Reach for Python (and the python-cli-ops skill) when a script grows past ~100 lines, needs data structures (nested maps, JSON manipulation beyond a jq filter), arithmetic beyond integers, or string processing with real parsing. Bash excels at gluing processes together: launching tools, moving files, checking conditions, wiring pipelines. The moment you find yourself simulating a hash-of-hashes or doing float math, stop — that's Python's job. This mirrors SKILL-RESOURCE-PROTOCOL §3, which expects .sh for shell glue and .py for logic.

Strict mode — the first three lines

#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'

Each flag earns its place — and each has a sharp edge:

Flag Buys you The edge to know
set -e Abort on any unchecked non-zero command Does not fire inside if/&&/`
set -u Error on unset variable expansion "$@" and "${arr[@]}" on an empty array trip -u in old Bash; use "${arr[@]:-}" or guard with Bash 4.4+.
set -o pipefail A pipe fails if any stage fails, not just the last Without it, `grep x file
set -E ERR trap inherits into functions/subshells/command-subs Pair with a trap … ERR that reports $LINENO.
IFS=$'\n\t' Word-splitting only on newline/tab, never spaces Filenames with spaces stop splitting into pieces. Unset/space-IFS is the #1 cause of "it worked until a path had a space".

Read the full file on GitHub · 231 lines

Files

What ships with it

5 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. 4d ago First seen · 231 lines · 108 tokens per session scan C bb4c0f6300ab

Subscribe to this mod's changes

bash-ops is a skill published in the GitHub repository 0xDarkMatter/claude-mods (32 stars, last pushed 11d ago), licensed MIT. It adds 108 tokens to every session and 3,411 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.