Skills bash-scripting
📦

bash-scripting

Safe

Create production-ready bash scripts with error handling

Building reliable shell scripts requires defensive patterns and thorough testing. This workflow guides you through creating robust bash scripts with proper error handling, logging, and automated test coverage.

Supports: Claude Codex Code(CC)
📊 70 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "bash-scripting". Create a backup script with error handling

Expected outcome:

  • Script template with strict mode enabled
  • Usage function with option documentation
  • Logging functions with timestamps
  • Trap handlers for cleanup on failure
  • Main backup logic with error checking
  • Bats test file with 5+ test cases

Using "bash-scripting". Add logging to my existing script

Expected outcome:

  • log() function with INFO/WARN/ERROR levels
  • Timestamp formatting (YYYY-MM-DD HH:MM:SS)
  • Debug mode toggle via VERBOSE flag
  • Log rotation configuration example
  • Integration points for existing functions

Security Audit

Safe
v1 • 2/25/2026

Static analyzer flagged 42 patterns but all are false positives. The skill is workflow documentation referencing other skills (@bash-pro, @bash-defensive-patterns) and contains a safe bash template using standard command substitution. No executable security risks detected.

1
Files scanned
198
Lines analyzed
0
findings
1
Total audits
No security issues found
Audited by: claude

Quality Score

38
Architecture
100
Maintainability
87
Content
31
Community
100
Security
83
Spec Compliance

What You Can Build

System Administration Automation

Create reliable scripts for server maintenance, backup operations, and system monitoring with proper error handling and logging.

CI/CD Pipeline Development

Build deployment and build scripts with comprehensive testing, rollback capability, and detailed logging for troubleshooting.

Infrastructure Tooling

Develop command-line tools for infrastructure management with professional argument parsing, usage documentation, and edge case handling.

Try These Prompts

Basic Script Structure
Create a bash script template with strict mode (set -euo pipefail), usage function, argument parsing, and basic logging. Include cleanup trap handler.
Error Handling Implementation
Add comprehensive error handling to my bash script including trap handlers for EXIT/INT/TERM, retry logic for failed commands, and meaningful exit codes.
Testing Setup with Bats
Generate Bats test cases for my bash script covering normal execution, error conditions, edge cases, and argument validation. Include mock functions for external commands.
Full Production Script
Guide me through all 7 phases to create a production-ready deployment script with logging, error handling, rollback capability, Bats tests, and ShellCheck configuration.

Best Practices

  • Always use strict mode (set -euo pipefail) to catch errors early
  • Quote all variable expansions to handle spaces and special characters
  • Use ShellCheck before deployment to catch common mistakes

Avoid

  • Using backticks instead of $(...) for command substitution
  • Ignoring return codes from critical commands
  • Hardcoding paths instead of using variables or arguments

Frequently Asked Questions

What other skills do I need to use this workflow?
This workflow references @bash-pro, @bash-defensive-patterns, @bash-linux, @bats-testing-patterns, and @shellcheck-configuration. These provide specialized patterns for each phase.
Is this workflow compatible with sh or dash?
The workflow targets bash specifically. Some patterns like arrays and process substitution require bash. For POSIX sh compatibility, additional modifications would be needed.
How do I run the Bats tests this workflow generates?
Install Bats (brew install bats or apt install bats), then run 'bats tests/' in your script directory. The workflow generates a tests/ folder with .bats test files.
What is ShellCheck and why is it recommended?
ShellCheck is a static analysis tool for shell scripts that catches common mistakes, syntax errors, and portability issues. Run it with 'shellcheck script.sh' before deployment.
Can I use this workflow for one-off scripts?
Yes, but you can skip phases based on script criticality. For quick scripts, focus on Phase 2 (structure) and Phase 4 (error handling). Full workflow is for production scripts.
How do I handle secrets in bash scripts?
Never hardcode secrets. Use environment variables, read from protected files, or use secret management tools. The workflow's error handling should mask sensitive values in logs.

Developer Details

File structure

📄 SKILL.md