bash-script-helper
Expert helper for bash scripting, debugging, and best practices
When & Why to Use This Skill
The Bash Script Helper is a specialized Claude skill designed to streamline the creation, troubleshooting, and optimization of shell scripts. It focuses on implementing industry-standard best practices—such as robust error handling with 'set -e', secure variable quoting, and modern syntax—to ensure your Linux and Unix automation is reliable, secure, and maintainable.
Use Cases
- Script Troubleshooting: Identifying and fixing common bash pitfalls like silent command failures, unquoted variables, and improper conditional logic.
- Legacy Code Refactoring: Modernizing older shell scripts by replacing backticks with $() and implementing [[ ]] for more robust string and file testing.
- DevOps Automation: Developing production-ready CI/CD glue scripts and system maintenance tasks with built-in error trapping and cleanup mechanisms.
- Security Hardening: Auditing scripts for vulnerabilities like eval usage or unvalidated user input to ensure safe execution in sensitive environments.
| name | bash-script-helper |
|---|---|
| description | Expert helper for bash scripting, debugging, and best practices |
Bash-script-helper
Instructions
When writing or debugging bash scripts:
- Always use #!/bin/bash shebang
- Set -e (exit on error), -u (error on undefined var)
- Use [[ ]] instead of [ ] for tests
- Quote variables: "$variable" not $variable
- Use $() instead of backticks
- Check command exit codes: $?
- Use trap for cleanup
- Provide meaningful error messages
- Validate input parameters
- Argument parsing with getopts
- Reading files line by line
- Function definitions and calls
- Arrays and associative arrays
- Use set -x for trace mode
- shellcheck for static analysis
- Use echo/printf for debugging output
- Avoid eval
- Sanitize user input
- Use mktemp for temporary files
- Set proper file permissions
Examples
Add examples of how to use this skill here.
Notes
- This skill was auto-generated
- Edit this file to customize behavior