bash-script-helper
Expert helper for bash scripting, debugging, and best practices
When & Why to Use This Skill
This Claude skill serves as a comprehensive assistant for Bash scripting, designed to streamline the creation, debugging, and optimization of shell scripts. By enforcing industry-standard best practices—such as robust error handling, secure variable quoting, and modern syntax—it helps developers and sysadmins build reliable, secure, and maintainable automation workflows for Linux and Unix environments. It focuses on reducing runtime errors and improving script portability through static analysis principles.
Use Cases
- Automating System Maintenance: Create robust cron jobs and maintenance scripts with built-in error trapping and meaningful exit codes.
- Script Debugging and Refactoring: Identify and fix common shell scripting pitfalls like unquoted variables, improper test conditions, or unsafe command executions.
- Standardizing DevOps Runbooks: Ensure all infrastructure-as-code and deployment scripts follow consistent security guidelines and performance best practices.
- Safe Resource Management: Implement secure temporary file creation using mktemp and automatic cleanup routines to prevent system clutter and security vulnerabilities.
| 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