| name | bash-script-template |
| description | Generate bash script templates with best practices including error handling, argument parsing, logging, and portability considerations. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
| graph | {"domains":["domain:software-engineering"],"specializations":["specialization:cli-mcp-development"],"skillAreas":["skill-area:cli-design","skill-area:command-line-interface-tools"],"roles":["role:backend-engineer","role:platform-engineer"],"workflows":["workflow:feature-development"],"topics":["topic:developer-experience"]} |
Bash Script Template
Generate bash script templates with best practices.
Capabilities
- Generate robust bash script templates
- Set up proper error handling
- Implement argument parsing with getopts
- Create logging utilities
- Configure strict mode settings
- Generate reusable function libraries
Usage
Invoke this skill when you need to:
- Create new bash scripts with best practices
- Set up proper error handling patterns
- Implement argument parsing
- Create portable shell scripts
Inputs
| Parameter | Type | Required | Description |
|---|
| scriptName | string | Yes | Script name |
| description | string | Yes | Script description |
| arguments | array | No | Script arguments |
| functions | array | No | Functions to include |
Generated Template
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
if [[ -t 1 ]]; then
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[0;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m'
else
readonly RED='' GREEN='' YELLOW='' BLUE='' NC=''
fi
log_info() { echo -e "${BLUE}[INFO]${NC} $*"; }
log_success() { echo -e "${GREEN}[OK] $*"; }
() { -e >&2; }
() { -e >&2; }
() { log_error ; 1; }
() {
:
}
cleanup EXIT
() {
<<
}
() {
OPTIND opt
opt;
h) usage; 0 ;;
v) VERBOSE= ;;
d) DRY_RUN= ;;
f) FORCE= ;;
o) OUTPUT= ;;
-)
) usage; 0 ;;
verbose) VERBOSE= ;;
dry-run) DRY_RUN= ;;
force) FORCE= ;;
output=*) OUTPUT= ;;
*) die ;;
;;
:) die ;;
?) die ;;
$((OPTIND - ))
[[ -lt 1 ]];
usage
die
ARGUMENT=
}
VERBOSE=
DRY_RUN=
FORCE=
OUTPUT=
() {
parse_args
[[ == ]];
log_info
[[ == ]];
log_warn
log_info
log_success
}
main
Target Processes
- shell-script-development
- cross-platform-cli-compatibility
- cli-application-bootstrap