Agent skill

Shell Scripting

by ancoleman in ancoleman/ai-design-components

Write robust, portable shell scripts with proper error handling, argument parsing, and testing.

MITAuto-check passedDevelopment

Install Shell Scripting

skills CLI
$ npx skills add ancoleman/ai-design-components --skill shell-scripting -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ancoleman/ai-design-components shell-scripting --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/shell-scripting .claude/skills/shell-scripting && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
shell-scripting
GitHub stars
526
Token cost
~2.2k tokens
SKILL.md length
455 words
Files
16 (incl. scripts, references)
Skills in repo
75
Repo updated
First seen
Licence
MIT

At a glance

Write robust, portable shell scripts with proper error handling, argument parsing, and testing.

  • Automating system tasks
  • SKILL.md covers Purpose, When to Use This Skill, POSIX sh vs Bash and Essential Error Handling, plus 11 more sections
  • Runs Shell scripts from its folder; calls jq, yq and shellcheck; needs API_KEY
  • Building CI/CD scripts

What it does

Shell Scripting is an agent skill from ancoleman/ai-design-components. Write robust, portable shell scripts with proper error handling, argument parsing, and testing. Use when automating system tasks, building CI/CD scripts, or creating container entrypoints.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 18 other files, including scripts and reference files (for example `examples/error-handling.sh`, `examples/getopts-advanced.sh` and `examples/getopts-basic.sh`).

It sits in Development, covering Shell scripting and CI/CD. It works with Bash. The repository describes itself as: Comprehensive UI/UX and Backend component design skills for AI-assisted development with Claude. The licence is MIT.

When your agent uses it

  • Automating system tasks
  • Building CI/CD scripts
  • Creating container entrypoints

Example prompts

  • “/shell-scripting”

Requirements

  • A Bash shell
  • Docker
  • A credential in API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 76551b7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • jq
    • yq
    • shellcheck
    • curl
    • brew
    • apt-get

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use curl, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Shell Scripting loads about 2.2k tokens when it runs, and up to ~23k if it reads all its reference files. Until then it costs about 51 tokens; SKILL.md has 455 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~51
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~23k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from ancoleman/ai-design-components at commit 76551b7, republished under its MIT licence (© ancoleman). 455 words, ~2,170 tokens.

Download SKILL.mdSave it as .claude/skills/shell-scripting/SKILL.md (or your agent's skills folder). This skill also uses 15 other files; get the full folder from GitHub.
name
shell-scripting
description
Write robust, portable shell scripts with proper error handling, argument parsing, and testing. Use when automating system tasks, building CI/CD scripts, or creating container entrypoints.

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
bash
#!/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
bash
#!/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
bash
#!/bin/bash
set -euo pipefail

TEMP_FILE=$(mktemp)

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

trap cleanup EXIT

Use for guaranteed cleanup of temporary files, locks, and resources.

For comprehensive error patterns, see references/error-handling.md.

Argument Parsing

Short Options with getopts (POSIX)
bash
#!/bin/bash

while getopts "hvf:o:" opt; do
    case "$opt" in
        h) usage ;;
        v) VERBOSE=true ;;
        f) INPUT_FILE="$OPTARG" ;;
        o) OUTPUT_FILE="$OPTARG" ;;
        *) usage ;;
    esac
done

shift $((OPTIND - 1))
Long Options (Manual Parsing)
bash
#!/bin/bash

while [[ $# -gt 0 ]]; do
    case "$1" in
        --help) usage ;;
        --verbose) VERBOSE=true; shift ;;
        --file) INPUT_FILE="$2"; shift 2 ;;
        --file=*) INPUT_FILE="${1#*=}"; shift ;;
        *) break ;;
    esac
done

For hybrid approaches and validation patterns, see references/argument-parsing.md.

Parameter Expansion Quick Reference

bash
# Default values
${var:-default}              # Use default if unset
${var:=default}              # Assign default if unset
: "${API_KEY:?Error: required}"  # Error if unset

# String manipulation
${#var}                      # String length
${var:offset:length}         # Substring
${var%.txt}                  # Remove suffix
${var##*/}                   # Basename
${var/old/new}               # Replace first
${var//old/new}              # Replace all

# Case conversion (Bash 4+)
${var^^}                     # Uppercase
${var,,}                     # Lowercase

For complete expansion patterns and array handling, see references/parameter-expansion.md.

Common Utilities Integration

JSON with jq
bash
# Extract field
name=$(curl -sSL https://api.example.com/user | jq -r '.name')

# Filter array
active=$(jq '.users[] | select(.active) | .name' data.json)

# Check existence
if ! echo "$json" | jq -e '.field' >/dev/null; then
    echo "Error: Field missing" >&2
fi
YAML with yq
bash
# Read value (yq v4)
host=$(yq eval '.database.host' config.yaml)

# Update in-place
yq eval '.port = 5432' -i config.yaml

# Convert to JSON
yq eval -o=json config.yaml
Text Processing
bash
# awk: Extract columns
awk -F',' '{print $1, $3}' data.csv

# sed: Replace text
sed 's/old/new/g' file.txt

# grep: Pattern match
grep -E "ERROR|WARN" logfile.txt

For detailed examples and best practices, see references/common-utilities.md.

Testing and Validation

ShellCheck: Static Analysis
bash
# Check script
shellcheck script.sh

# POSIX compliance
shellcheck --shell=sh script.sh

# Exclude warnings
shellcheck --exclude=SC2086 script.sh
Show full SKILL.md (183 more words)Show less
Bats: Automated Testing
bash
#!/usr/bin/env bats

@test "script runs successfully" {
    run ./script.sh --help
    [ "$status" -eq 0 ]
    [ "${lines[0]}" = "Usage: script.sh [OPTIONS]" ]
}

@test "handles missing argument" {
    run ./script.sh
    [ "$status" -eq 1 ]
    [[ "$output" =~ "Error" ]]
}

Run tests:

bash
bats test/

For CI/CD integration and debugging techniques, see references/testing-guide.md.

Defensive Programming Checklist

bash
#!/bin/bash
set -euo pipefail

# Check required commands
command -v jq >/dev/null 2>&1 || {
    echo "Error: jq required" >&2
    exit 1
}

# Check environment variables
: "${API_KEY:?Error: API_KEY required}"

# Check files
[ -f "$CONFIG_FILE" ] || {
    echo "Error: Config not found: $CONFIG_FILE" >&2
    exit 1
}

# Quote all variables
echo "Processing: $file"        # ❌ Unquoted
echo "Processing: \"$file\""    # ✅ Quoted

Platform Considerations

macOS vs Linux Differences
bash
# sed in-place
sed -i '' 's/old/new/g' file.txt    # macOS
sed -i 's/old/new/g' file.txt       # Linux

# Portable: Use temp file
sed 's/old/new/g' file.txt > file.txt.tmp
mv file.txt.tmp file.txt

# readlink
readlink -f /path                    # Linux only
cd "$(dirname "$0")" && pwd         # Portable

For complete platform differences, see references/portability-guide.md.

Script Categories

System Administration: Cron jobs, log rotation, backup automation Build/Deployment: CI/CD pipelines, Docker builds, deployments Development Tooling: Project setup, test runners, code generators Container Entrypoints: Initialization, signal handling, configuration

Production Script Template

bash
#!/bin/bash
set -euo pipefail

readonly SCRIPT_NAME="$(basename "$0")"
readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

TEMP_DIR=""

cleanup() {
    local exit_code=$?
    rm -rf "$TEMP_DIR"
    exit "$exit_code"
}

trap cleanup EXIT

log() {
    echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" >&2
}

main() {
    # Check dependencies
    command -v jq >/dev/null 2>&1 || exit 1

    # Parse arguments
    # Validate input
    # Process
    # Report results

    log "Completed successfully"
}

main "$@"

For complete production template, see examples/production-template.sh.

Tool Recommendations

Core Tools:

  • jq: JSON parsing and transformation
  • yq: YAML parsing (v4 recommended)
  • ShellCheck: Static analysis and linting
  • Bats: Automated testing framework

Installation:

bash
# macOS
brew install jq yq shellcheck bats-core

# Ubuntu/Debian
apt-get install jq shellcheck
  • linux-administration: System commands and administration
  • building-ci-pipelines: Using scripts in CI/CD
  • infrastructure-as-code: Terraform/Pulumi wrappers
  • kubernetes-operations: kubectl scripts, Helm hooks
  • writing-dockerfiles: Container entrypoints

Additional Resources

Reference Files:

  • references/error-handling.md - Comprehensive error patterns
  • references/argument-parsing.md - Advanced parsing techniques
  • references/parameter-expansion.md - Complete expansion reference
  • references/portability-guide.md - POSIX vs Bash differences
  • references/testing-guide.md - ShellCheck and Bats guide
  • references/common-utilities.md - jq, yq, awk, sed usage

Example Scripts:

  • examples/production-template.sh - Production-ready template
  • examples/getopts-basic.sh - Simple getopts usage
  • examples/getopts-advanced.sh - Complex option handling
  • examples/long-options.sh - Manual long option parsing
  • examples/error-handling.sh - Error handling patterns
  • examples/json-yaml-processing.sh - jq/yq examples

Utility Scripts:

  • scripts/lint-script.sh - ShellCheck wrapper for CI
  • scripts/test-script.sh - Bats wrapper for CI

© ancoleman, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 15 other files (scripts, references) in skills/shell-scripting of ancoleman/ai-design-components.

  • SKILL.md
  • examples/error-handling.sh
  • examples/getopts-advanced.sh
  • examples/getopts-basic.sh
  • examples/json-yaml-processing.sh
  • examples/long-options.sh
  • examples/production-template.sh
  • outputs.yaml
  • references/argument-parsing.md
  • references/common-utilities.md
  • references/error-handling.md
  • references/parameter-expansion.md
  • references/portability-guide.md
  • references/testing-guide.md
  • scripts/lint-script.sh
  • scripts/test-script.sh

Open the folder on GitHubat commit 76551b7

Compare with similar skills

Shell Scripting next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Shell Scripting compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Shell Scripting this skillancoleman/ai-design-components526—~2.2kAutomated safety check: PassMIT
Bash Propromovaweb/setupvibe1019 repos~4.7kAutomated safety check: PassGPL-3.0
Shellpproenca/dot-skills214—~1.9kAutomated safety check: PassMIT
Bash Defensive Patternspromovaweb/setupvibe10113 repos~572Automated safety check: PassGPL-3.0
ShellCheck Configurationwshobson/agents40k10 repos~403Automated safety check: PassMIT
Bats Shell Testing Patternswshobson/agents40k11 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Bash Pro

    promovaweb/setupvibe

    Master of defensive Bash scripting for production automation, CI/CD pipelines, and system utilities.

    101 GitHub starsUsed in 9 repos~4.7k tokens
    DevelopmentAuto-check passed
  • Shell

    pproenca/dot-skills

    Shell scripting best practices for writing safe, portable, and maintainable bash/sh scripts.

    214 GitHub stars~1.9k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Bash Defensive Patterns

    promovaweb/setupvibe

    Master defensive Bash programming techniques for production-grade scripts.

    101 GitHub starsUsed in 13 repos~572 tokens
    DevOps & CloudAuto-check passed
  • Master ShellCheck static analysis configuration and usage for shell script quality. Use when setting up linting infrastructure, fixing code issues, or…

    40k GitHub starsUsed in 10 repos~403 tokens
    DevelopmentAuto-check passed
  • Writes unit tests for shell scripts with Bats: error-condition tests, fixtures and mocks, cross-shell checks, parallel runs, helper files and CI integration.

    40k GitHub starsUsed in 11 repos~1.3k tokens
    Testing & QAAuto-check passed
  • Headless Codex CLI Automation

    XiaomiMiMo/MiMo-Code

    Runs OpenAI Codex CLI as a non-interactive worker for CI, Docker, Kubernetes or remote servers, with sandbox modes and JSONL-friendly output.

    14k GitHub stars~2.7k tokensUpdated 4 days ago
    DevOps & CloudAuto-check passed

More from ancoleman/ai-design-components

All 75 skills in this repo
  • Building AI Chat

    ancoleman/ai-design-components

    Builds AI chat interfaces and conversational UI with streaming responses, context management, and multi-modal support.

    526 GitHub starsUsed in 1 repo~3.4k tokens
    Auto-check passed
  • Building Forms

    ancoleman/ai-design-components

    Builds form components and data collection interfaces including contact forms, registration flows, checkout processes, surveys, and settings pages.

    526 GitHub stars~3.7k tokensUpdated 10 mo ago
    Auto-check passed
  • Building Tables

    ancoleman/ai-design-components

    Builds tables and data grids for displaying tabular information, from simple HTML tables to complex enterprise data grids.

    526 GitHub stars~1.8k tokensUpdated 10 mo ago
    Auto-check passed
  • Creating Dashboards

    ancoleman/ai-design-components

    Creates comprehensive dashboard and analytics interfaces that combine data visualization, KPI cards, real-time updates, and interactive layouts.

    526 GitHub stars~3.5k tokensUpdated 10 mo ago
    Auto-check passed
  • Designing Layouts

    ancoleman/ai-design-components

    Designs layout systems and responsive interfaces including grid systems, flexbox patterns, sidebar layouts, and responsive breakpoints.

    526 GitHub stars~1.7k tokensUpdated 10 mo ago
    Auto-check passed
  • Displaying Timelines

    ancoleman/ai-design-components

    Displays chronological events and activity through timelines, activity feeds, Gantt charts, and calendar interfaces.

    526 GitHub stars~2.7k tokensUpdated 10 mo ago
    Auto-check passed

Works with

Questions about Shell Scripting

What does Shell Scripting do?

Write robust, portable shell scripts with proper error handling, argument parsing, and testing. Shell Scripting is an agent skill from ancoleman/ai-design-components. Write robust, portable shell scripts with proper error handling, argument parsing, and testing.

When should I use Shell Scripting?

Shell Scripting fits situations like: automating system tasks; building CI/CD scripts; creating container entrypoints.

How do I install Shell Scripting in Claude Code?

Run `npx skills add ancoleman/ai-design-components --skill shell-scripting -a claude-code`. Or copy the skill folder (skills/shell-scripting in ancoleman/ai-design-components) into .claude/skills/shell-scripting in your project. Claude Code loads it when a task matches its description.

How do I install Shell Scripting in Codex?

Run `npx skills add ancoleman/ai-design-components --skill shell-scripting -a codex`. Or copy the skill folder (skills/shell-scripting in ancoleman/ai-design-components) into .agents/skills/shell-scripting in your project. Codex loads it when a task matches its description.

Can I use Shell Scripting in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ancoleman/ai-design-components --skill shell-scripting -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/shell-scripting, .gemini/skills/shell-scripting, .github/skills/shell-scripting and .opencode/skills/shell-scripting in your project.

What does Shell Scripting need to run?

Going by SKILL.md and its folder, Shell Scripting needs a shell for the scripts in its folder, the command-line tools its instructions call (jq, yq, shellcheck, curl, brew and apt-get) and credentials named API_KEY. Our summary lists: A Bash shell; Docker; A credential in API_KEY.

Does Shell Scripting access the network?

SKILL.md contains no URLs. Its commands use curl, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Shell Scripting safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Shell Scripting use?

Shell Scripting is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Shell Scripting use?

About 2.2k tokens (SKILL.md is roughly 8.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 21k tokens, read only when the agent opens those files.

What are the alternatives to Shell Scripting?

Skills that share tags, products or a category with Shell Scripting: Bash Pro (promovaweb/setupvibe, 101 stars), Shell (pproenca/dot-skills, 214 stars), Bash Defensive Patterns (promovaweb/setupvibe, 101 stars) and ShellCheck Configuration (wshobson/agents, 40k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Shell Scripting?

ancoleman (a GitHub user) maintains it in ancoleman/ai-design-components, which has 526 GitHub stars. The repository holds 75 skills in this directory. The repository was last updated on December 11, 2025.

Source: ancoleman/ai-design-components on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.