← ClaudeAtlas

shell-scriptinglisted

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.
ancoleman/ai-design-components · ★ 368 · Web & Frontend · score 80
Install: claude install-skill ancoleman/ai-design-components
# 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