bash-script-template

Generate bash script templates with best practices including error handling, argument parsing, logging, and portability considerations.

509 stars

Best use case

bash-script-template is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generate bash script templates with best practices including error handling, argument parsing, logging, and portability considerations.

Teams using bash-script-template should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/bash-script-template/SKILL.md --create-dirs "https://raw.githubusercontent.com/a5c-ai/babysitter/main/library/specializations/cli-mcp-development/skills/bash-script-template/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/bash-script-template/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How bash-script-template Compares

Feature / Agentbash-script-templateStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generate bash script templates with best practices including error handling, argument parsing, logging, and portability considerations.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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

```bash
#!/usr/bin/env bash
#
# <scriptName> - <description>
#
# Usage: <scriptName> [options] <arguments>
#

set -euo pipefail
IFS=$'\n\t'

# Script directory
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"

# Colors (if terminal supports)
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

# Logging functions
log_info() { echo -e "${BLUE}[INFO]${NC} $*"; }
log_success() { echo -e "${GREEN}[OK]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
die() { log_error "$*"; exit 1; }

# Cleanup on exit
cleanup() {
    # Add cleanup tasks here
    :
}
trap cleanup EXIT

# Usage
usage() {
    cat <<EOF
Usage: ${SCRIPT_NAME} [options] <argument>

<description>

Options:
    -h, --help      Show this help message
    -v, --verbose   Enable verbose output
    -d, --dry-run   Show what would be done
    -f, --force     Force operation
    -o, --output    Output file path

Arguments:
    argument        Required argument description

Examples:
    ${SCRIPT_NAME} -v input.txt
    ${SCRIPT_NAME} --output result.txt input.txt
EOF
}

# Parse arguments
parse_args() {
    local OPTIND opt
    while getopts ":hvdfo:-:" opt; do
        case "${opt}" in
            h) usage; exit 0 ;;
            v) VERBOSE=true ;;
            d) DRY_RUN=true ;;
            f) FORCE=true ;;
            o) OUTPUT="${OPTARG}" ;;
            -)
                case "${OPTARG}" in
                    help) usage; exit 0 ;;
                    verbose) VERBOSE=true ;;
                    dry-run) DRY_RUN=true ;;
                    force) FORCE=true ;;
                    output=*) OUTPUT="${OPTARG#*=}" ;;
                    *) die "Unknown option: --${OPTARG}" ;;
                esac
                ;;
            :) die "Option -${OPTARG} requires an argument" ;;
            ?) die "Unknown option: -${OPTARG}" ;;
        esac
    done
    shift $((OPTIND - 1))

    # Required arguments
    if [[ $# -lt 1 ]]; then
        usage
        die "Missing required argument"
    fi

    ARGUMENT="$1"
}

# Defaults
VERBOSE=${VERBOSE:-false}
DRY_RUN=${DRY_RUN:-false}
FORCE=${FORCE:-false}
OUTPUT=${OUTPUT:-}

# Main function
main() {
    parse_args "$@"

    if [[ "${VERBOSE}" == true ]]; then
        log_info "Verbose mode enabled"
    fi

    if [[ "${DRY_RUN}" == true ]]; then
        log_warn "Dry run mode - no changes will be made"
    fi

    log_info "Processing: ${ARGUMENT}"

    # Main logic here

    log_success "Done!"
}

main "$@"
```

## Target Processes

- shell-script-development
- cross-platform-cli-compatibility
- cli-application-bootstrap

Related Skills

typescript

509
from a5c-ai/babysitter

TypeScript configuration, strict mode, generics, and type utilities.

persona-template

509
from a5c-ai/babysitter

Generate user persona documents and empathy maps from templates

typescript-sdk-specialist

509
from a5c-ai/babysitter

TypeScript SDK development with Node.js and browser support. Design SDK architecture, implement type-safe API clients, support ESM and CommonJS modules, and configure bundling for browsers.

godot-gdscript

509
from a5c-ai/babysitter

GDScript programming skill for Godot Engine, including signals, coroutines, and performance optimization.

linker-script

509
from a5c-ai/babysitter

GNU linker script generation and optimization for embedded systems. Expert skill for memory layout definition, section placement, multi-image linking, and memory protection configuration.

ipa-transcription-phonological

509
from a5c-ai/babysitter

Transcribe speech using International Phonetic Alphabet and analyze sound systems including phonotactics and phonological rules

mcp-sdk-typescript-bootstrapper

509
from a5c-ai/babysitter

Bootstrap MCP (Model Context Protocol) servers with the official TypeScript SDK. Creates complete server implementations with transport layer, tools, resources, and proper error handling.

code-template-manager

509
from a5c-ai/babysitter

Manage and generate competitive programming templates

prompt-template-design

509
from a5c-ai/babysitter

Structured prompt template creation with variables, formatting, and version control

template-scaffolding

509
from a5c-ai/babysitter

Template loading, variable filling, and scaffolding for all GSD artifacts. Manages 22+ templates covering every document type in the GSD system, from PROJECT.md to milestone archives.

process-builder

509
from a5c-ai/babysitter

Scaffold new babysitter process definitions following SDK patterns, proper structure, and best practices. Guides the 3-phase workflow from research to implementation.

Workflow & Productivity

babysitter

509
from a5c-ai/babysitter

Orchestrate via @babysitter. Use this skill when asked to babysit a run, orchestrate a process or whenever it is called explicitly. (babysit, babysitter, orchestrate, orchestrate a run, workflow, etc.)