shell-scripting

shell-scripting is a skill for Claude Code from ancoleman/ai-design-components. It costs 39 tokens per session (2,183 once invoked), scanned C, original, MIT.

A guide to writing reliable shell scripts, which are small programs that run commands in an operating system's terminal. It covers portable shell choices, error handling, argument parsing, and script tests.

In plain words
What is it for?
Use it for build scripts, CI/CD jobs, container startup scripts, backups, log rotation, and other system automation.
Why use it?
It helps prevent automation scripts from failing silently, mishandling inputs, or working only on one machine.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the infrastructure-skills plugin — 12 skills 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/ancoleman/ai-design-components/shell-scripting
Any agent
npx skills add ancoleman/ai-design-components --skill shell-scripting
Clone the repo
git clone --depth 1 https://github.com/ancoleman/ai-design-components

Made for: Claude Code.

Or install infrastructure-skills, the plugin that ships this one along with the rest of its 12 skills.

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/ancoleman/ai-design-components/shell-scripting.svg)](https://agentmods.dev/skills/ancoleman/ai-design-components/shell-scripting)
Your own site
<a href="https://agentmods.dev/skills/ancoleman/ai-design-components/shell-scripting"><img src="https://agentmods.dev/badge/skills/ancoleman/ai-design-components/shell-scripting.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,183 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.1 $0.00039 $0.02183
Opus 5 $0.00019 $0.01092
Sonnet 5 $0.00008 $0.00437
Haiku 4.5 $0.00004 $0.00218

Measured 2d ago against content hash 1662ac30f716, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, 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 2d ago.

The scan reads SKILL.md. This mod also ships 8 executable files (examples/error-handling.sh, examples/getopts-advanced.sh, examples/getopts-basic.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.

rm -rf "$TEMP_DIR"

Makes network callslowCapability

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

name=$(curl -sSL https://api.example.com/user | jq -r '.name')
skills/shell-scripting/SKILL.md · 374 lines

How it starts

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

Shell Scripting

Purpose

Provides patterns and best practices for writing maintainable shell scripts with error handling, argument parsing, and portability considerations. Covers POSIX sh vs Bash decision-making, parameter expansion, integration with common utilities (jq, yq, awk), and testing with ShellCheck and Bats.

When to Use This Skill

Use shell scripting when:

  • Orchestrating existing command-line tools and system utilities
  • Writing CI/CD pipeline scripts (GitHub Actions, GitLab CI)
  • Creating container entrypoints and initialization scripts
  • Automating system administration tasks (backups, log rotation)
  • Building development tooling (build scripts, test runners)

Consider Python/Go instead when:

  • Complex business logic or data structures required
  • Cross-platform GUI needed
  • Heavy API integration (REST, gRPC)
  • Script exceeds 200 lines with significant logic complexity

POSIX sh vs Bash

Use POSIX sh (#!/bin/sh) when:

  • Maximum portability required (Linux, macOS, BSD, Alpine)
  • Minimal container images needed
  • Embedded systems or unknown target environments

Use Bash (#!/bin/bash) when:

  • Controlled environment (specific OS, container)
  • Arrays or associative arrays needed
  • Advanced parameter expansion beneficial
  • Process substitution <(cmd) useful

For detailed comparison and testing strategies, see references/portability-guide.md.

Essential Error Handling

Fail-Fast Pattern

#!/bin/bash
set -euo pipefail

# -e: Exit on error
# -u: Exit on undefined variable
# -o pipefail: Pipeline fails if any command fails

Use for production automation, CI/CD scripts, and critical operations.

Explicit Exit Code Checking

#!/bin/bash

if ! command_that_might_fail; then
    echo "Error: Command failed" >&2
    exit 1
fi

Use for custom error messages and interactive scripts.

Trap Handlers for Cleanup

#!/bin/bash
set -euo pipefail

TEMP_FILE=$(mktemp)

cleanup() {
    rm -f "$TEMP_FILE"
}

trap cleanup EXIT

Read the full file on GitHub · 374 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. 2d ago First seen · 374 lines · 39 tokens per session scan C 1662ac30f716

Subscribe to this mod's changes

shell-scripting is a skill published in the GitHub repository ancoleman/ai-design-components (518 stars, last pushed 8mo ago), licensed MIT. It adds 39 tokens to every session and 2,183 once invoked, about $0.0002 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-09-03.

Related

Other skills, from other repositories

ci-cd-pipeline

Use near the end of a project to generate CI and make the app deploy-ready. Produces a polyglot GitHub Actions workflow (lint, typecheck, test, build) and multi-stage Dockerfiles. The finish line is CI-green and container-ready, not an actual deploy.

martian56/claude-engineer · 64 tokens

devops-engineer

Creates Dockerfiles, configures CI/CD pipelines, writes Kubernetes manifests, and generates Terraform/Pulumi infrastructure templates. Handles deployment automation, GitOps configuration, incident response runbooks, and internal developer platform tooling. Use when setting up CI/CD pipelines, containerizing…

Jeffallan/claude-skills · 107 tokens

deploy

Elixir/Phoenix deployment patterns — Dockerfile, fly.toml, runtime.exs, mix release, rel/ overlays. Use when configuring Fly.io, Docker, CI/CD, health checks, or production migrations.

oliver-kriska/claude-elixir-phoenix · 46 tokens

devops-specialist

DevOps 与运维专家。精通 CI/CD、容器化、编排、基础设施即代码、监控告警和自动化部署。用于构建高效、可靠的软件交付流水线和运维系统。.

huangwb8/skills · 55 tokens

platform-skills

Use when troubleshooting, implementing, reviewing, or auditing platform infrastructure as a system — where Kubernetes, GitOps, CI/CD, and security concerns intersect. Provides structured diagnosis with blast radius, validation steps, and rollback plan for: Kubernetes, Flux CD, Argo CD, Terraform, GitHub Actions…

nitinjain999/platform-skills · 137 tokens

base-cn-registry-mirror-strategy

国内镜像源与代理分层策略(Docker / Debian / Alpine / Node / Python / Maven / Gradle / Go),用于 Dockerfile 与 CI 的可维护加速。.

seed-forge/harness-ai-kit · 47 tokens