Advanced Bash Platform
Enterprise-grade skill for bash, linux, terminal, patterns. Includes structured workflows, validation checks, and reusable patterns for development.
Advanced Bash Platform
A Claude Code skill for writing robust, maintainable Bash scripts and shell automation. Covers scripting best practices, error handling, argument parsing, portability, performance optimization, and common patterns for system administration, CI/CD, and developer tooling.
When to Use This Skill
Choose Advanced Bash Platform when:
- You need to write production-quality Bash scripts
- You want robust error handling and debugging in shell scripts
- You need to automate system administration tasks
- You're building CI/CD pipeline scripts
- You want to create developer tooling and CLI utilities with Bash
Consider alternatives when:
- You need a full CLI application (use Node.js/Python with a CLI framework)
- You want cross-platform scripting (use Python or Node.js)
- You need complex data processing (use a programming language, not Bash)
Quick Start
# Install the skill claude install advanced-bash-platform # Write a robust script claude "Write a Bash script that deploys a Docker container with health checks, rollback on failure, and logging" # Add argument parsing claude "Add proper argument parsing to this script with --help, required and optional flags, and validation" # Debug a script claude "This script fails intermittently: [paste]. Add proper error handling and debugging output"
Core Concepts
Script Header Template
#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' # Script description # Usage: script.sh [options] <argument> readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
Error Handling
| Setting | Effect | When to Use |
|---|---|---|
set -e | Exit on any error | Always |
set -u | Error on undefined variables | Always |
set -o pipefail | Catch pipe failures | Always |
trap cleanup EXIT | Run cleanup on exit | Scripts with temp files |
| ` | true` |
Common Patterns
| Pattern | Use Case | Implementation |
|---|---|---|
| Argument Parsing | CLI options | getopts or manual while case |
| Logging | Structured output | Functions with timestamp and level |
| Temp Files | Intermediate data | mktemp with trap cleanup |
| Lock Files | Prevent concurrent runs | flock or PID file |
| Progress | Long operations | Counter with \r overwrite |
| Retry | Unreliable commands | Loop with backoff |
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
shell | string | "bash" | Target: bash, zsh, sh (POSIX) |
style | string | "strict" | Style: strict (set -euo), relaxed |
logging | boolean | true | Include logging functions |
portability | string | "bash" | Portability: posix, bash, linux_only |
complexity | string | "moderate" | Level: simple, moderate, advanced |
Best Practices
-
Always use
set -euo pipefail— This catches the vast majority of scripting bugs: unhandled errors, undefined variables, and swallowed pipe failures. Every production Bash script should start with this. -
Quote all variable expansions —
"$variable"not$variable. Unquoted variables are split on whitespace and subject to glob expansion. This causes subtle bugs with filenames containing spaces or special characters. -
Use functions for organization — Any script longer than 50 lines should be organized into functions. Functions make scripts testable, reusable, and easier to read. Put the main logic in a
main()function and call it at the bottom. -
Don't parse ls output —
lsoutput is not reliable for scripting. Useglob patternsfor file iteration:for file in *.txt; do. Usefindwith-print0andxargs -0for complex file operations. -
Use shellcheck — Run ShellCheck on every Bash script. It catches hundreds of common scripting mistakes including quoting issues, undefined variables, and portability problems. Add it to your CI pipeline.
Common Issues
Script works locally but fails in CI — Different shell versions, missing utilities, or different PATH configurations. Use #!/usr/bin/env bash for portability, check for required tools at the start, and avoid bashisms if targeting sh.
Variable is empty when it shouldn't be — You're likely running in a subshell (pipe or command substitution) where the variable is set but not visible to the parent. Avoid setting variables inside while read loops with pipes — use process substitution instead.
Script is too slow — Avoid calling external commands in loops. Each grep, sed, or awk invocation forks a process. Use Bash built-ins for simple string operations and batch external tool usage where possible.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.