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

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

Good fit Use it to write, review, debug, and improve automation scripts that run commands, process files, or manage system tasks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cosmicstack-labs/mercury-agent-skills/shell-scripting
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 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/github.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/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 Shell Scripting

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 5 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 64
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • high Tool Misuse · line 128
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • high Tool Misuse · line 206
    Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
    Fix: Limit tool chaining depth and validate the output of each tool before passing it to the next. Require explicit user approval for multi-step chains.
  • high Prompt Injection · line 577
    This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
    Fix: Remove or rewrite any text that instructs the agent to ignore prompts, override safety rules, or trust unverified content. Ensure skill content cannot be injected to alter agent behavior.
  • high Tool Misuse · line 746
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
How audits are shown
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.00024 $0.06143
Opus 5.5 $0.00010 $0.02457
Sonnet 5.5 $0.00005 $0.01229
Haiku 4.5 $0.00002 $0.00614

Measured 1mo ago against content hash 8186735c9897, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 (485 stars, last pushed 1mo ago), licensed MIT. It adds 24 tokens to every session and 6,143 once invoked, about $0.0001 per session on Opus 5.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

agent-platform-model-registry

Agent Platform Model Registry Management. Use when you need to upload, list, describe, update, or delete machine learning models (and their versions) in the Agent Platform Model Registry. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform models.

google/skills · 60 tokens

gke-workload-security

Audits, configures, and hardens workload-level security controls for Google Kubernetes Engine (GKE) applications and namespaces. Covers running security audits (auditcluster.sh), enforcing Network Policies (default-deny and Dataplane V2 logging), isolating high-risk pods inside GKE Sandbox (gVisor), enforcing Pod…

google/skills · 171 tokens

gke-reliability

Improves GKE workload reliability, using PDBs, health probes, and topology spread constraints. Use when configuring GKE workload reliability, setting up PDBs, or configuring GKE health probes (liveness, readiness, startup). Don't use for generating K8s YAML manifests (use gke-manifest-generation) or disaster recovery…

google/skills · 85 tokens

google-cloud-solution-agentic-analytics-spark-knowledge-catalog

Discovers requirements and designs an end-to-end governed agentic analytics solution using Knowledge Catalog and Managed Service for Apache Spark (Lightning Engine). Use when designing data science and analytics workflows across structured and unstructured distributed data (including in S3, Azure Blob, AlloyDB, and…

google/skills · 132 tokens