Shell Scripting

Shell Scripting is a skill for Claude Code, Codex from cosmicstack-labs/mercury-agent-skills. It costs 24 tokens per session (6,143 once invoked), scanned C, original, MIT.

Guidance for writing shell scripts, which are text files that automate commands in an operating system. It covers error handling, portability across environments, debugging, and performance.

In plain words
What is it for?
Use it to write, review, debug, and improve automation scripts that run commands, process files, or manage system tasks.
Why use it?
It helps prevent scripts from continuing after failures, hiding errors, or behaving differently on another computer or in a container.

Skill for Claude CodeCodex

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/cosmicstack-labs/mercury-agent-skills/shell-scripting
Any agent
npx skills add cosmicstack-labs/mercury-agent-skills --skill shell-scripting
Clone the repo
git clone --depth 1 https://github.com/cosmicstack-labs/mercury-agent-skills

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 Shell Scripting

README.md
[![agentmods](https://agentmods.dev/badge/skills/cosmicstack-labs/mercury-agent-skills/shell-scripting.svg)](https://agentmods.dev/skills/cosmicstack-labs/mercury-agent-skills/shell-scripting)
Your own site
<a href="https://agentmods.dev/skills/cosmicstack-labs/mercury-agent-skills/shell-scripting"><img src="https://agentmods.dev/badge/skills/cosmicstack-labs/mercury-agent-skills/shell-scripting.svg" alt="Measured on agentmods" height="20"></a>
Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,143 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.00024 $0.06143
Opus 5 $0.00012 $0.03071
Sonnet 5 $0.00005 $0.01229
Haiku 4.5 $0.00002 $0.00614

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

Security

Grade C, and why

Shell Scripting 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.

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.

rm -rf ./*

Makes network callslowCapability

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

check_dependencies "jq" "curl" "aws" "docker"
categories/automation/shell-scripting/SKILL.md · 868 lines

How it starts

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

Shell Scripting

Core Principles

1. Fail Explicitly

A script that encounters an error should stop, not continue with corrupted state. Use defensive coding: validate assumptions, check exit codes, and never assume success.

2. Clarity Over Cleverness

Shell scripting is already cryptic enough. Write scripts that are easy to read, not impressive one-liners. Your future self will thank you.

3. Portability By Default

Unless you have a specific reason to require Bash 4+, write for POSIX sh. Your script may need to run in a container, an embedded system, or a legacy environment.

4. Defensive Safety

Every variable could be empty. Every command could fail. Every file could be missing. Write scripts that survive these realities.

5. Principle of Least Surprise

Scripts should behave predictably. Use consistent exit codes, clear error messages, and help text. No silent failures, no hidden side effects.

Scripting Maturity Model

Level Name Description
0 Ad-hoc One-off commands saved to a file. No error handling. Only the author understands it.
1 Functional Has shebang and basic structure. Handles common success paths. Brittle.
2 Defensive Uses set -euo pipefail, checks exit codes, validates arguments. Has basic error messages.
3 Robust Uses functions, has help text, proper argument parsing with defaults. Handles cleanup with traps. Portable across environments.
4 Production Comprehensive error handling, logging, structured output, CI-tested with shellcheck. Configuration via environment or config files.
5 Battle-tested Unit-tested, documented, versioned, handles edge cases (race conditions, signals, resource limits). Used in critical production pipelines.

Target at least Level 3 for any script that runs unattended.


Script Structure

Shebang and Set Flags

Every script begins with a shebang and safety flags:

#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────
# Script:     deploy.sh
# Author:     Your Name
# Description: Builds and deploys the application to staging
# Usage:      ./deploy.sh [--env staging|production] [--skip-tests]
# ─────────────────────────────────────────────────────────────

set -euo pipefail

# -e:  Exit immediately if any command exits with non-zero status
# -u:  Treat unset variables as an error (exit)
# -o pipefail: Pipeline's exit status is last non-zero command, or zero
# -x:  (debug) Print commands and their arguments as they execute

Read the full file on GitHub · 868 lines

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 · 868 lines · 24 tokens per session scan C 8186735c9897

Subscribe to this mod's changes

Shell Scripting is a skill published in the GitHub repository cosmicstack-labs/mercury-agent-skills (471 stars, last pushed 10d ago), licensed MIT. It adds 24 tokens to every session and 6,143 once invoked, about $0.0001 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.

Related

Other skills, from other repositories

modern-saas-builder

Founder-minded senior product engineer and SaaS architect skill. Use when building, planning, architecting, validating, designing, testing, securing, deploying, or monetizing modern SaaS products, micro-SaaS, web apps, AI agents, Web3/Base applications, agent commerce, or Telegram bots/Mini Apps. Always active when…

lijnati/modern-saas-builder-skills · 98 tokens

claude-md-improver

Audit and improve CLAUDE.md files in repositories. Use when user asks to check, audit, update, improve, or fix CLAUDE.md files. Scans for all CLAUDE.md files, evaluates quality against templates, outputs quality report, then makes targeted updates. Also use when the user mentions "CLAUDE.md maintenance" or "project…

anthropics/claude-plugins-official · 82 tokens

twitter-reader

Read Twitter/X for financial research using opencli (read-only). Use this skill whenever the user wants to read their Twitter feed, search for financial tweets, view bookmarks, look up user profiles, or gather market sentiment from Twitter/X. Triggers include: "check my feed", "search Twitter for", "show my…

himself65/finance-skills · 161 tokens

atlas-obscura

Search Atlas Obscura for weird, wonderful, and hidden gem places near any destination. Find the interesting stuff, not boring plaques. Search by coordinates, get full details with descriptions and images.

borski/travel-hacking-toolkit · 44 tokens

cf-validate

Валидация конфигурации 1С. Используй после создания или модификации конфигурации для проверки корректности.

Nikolay-Shirokov/cc-1c-skills · 31 tokens

producthunt-launch-kit

Use when the user asks to prepare a Product Hunt launch or generate Product Hunt listing assets. Generates tagline variants under 60 chars, a 500-char description, a maker comment, launch-day tweet thread, LinkedIn post, and a 4-email launch sequence.

Varnan-Tech/opendirectory · 58 tokens