bash-cli-framework-5-error-handling

Sub-skill of bash-cli-framework: 5. Error Handling (+1).

5 stars

Best use case

bash-cli-framework-5-error-handling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of bash-cli-framework: 5. Error Handling (+1).

Teams using bash-cli-framework-5-error-handling 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/5-error-handling/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_core/bash/bash-cli-framework/5-error-handling/SKILL.md"

Manual Installation

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

How bash-cli-framework-5-error-handling Compares

Feature / Agentbash-cli-framework-5-error-handlingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of bash-cli-framework: 5. Error Handling (+1).

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

# 5. Error Handling (+1)

## 5. Error Handling


Robust error handling with cleanup:

```bash
#!/bin/bash
# ABOUTME: Error handling and cleanup functions
# ABOUTME: Ensures graceful exit and resource cleanup

# Trap for cleanup on exit
cleanup() {
    local exit_code=$?

    # Remove temporary files
    [[ -n "$TEMP_DIR" && -d "$TEMP_DIR" ]] && rm -rf "$TEMP_DIR"

    # Log exit status
    if [[ $exit_code -eq 0 ]]; then
        log_info "Script completed successfully"
    else
        log_error "Script exited with code $exit_code"
    fi

    exit $exit_code
}

# Set trap
trap cleanup EXIT INT TERM

# Error handler
die() {
    local message="$1"
    local exit_code="${2:-1}"

    log_critical "$message"
    exit "$exit_code"
}

# Assert function
assert() {
    local condition="$1"
    local message="${2:-Assertion failed}"

    if ! eval "$condition"; then
        die "$message"
    fi
}
```


## 6. Argument Parsing


Standard argument parsing pattern:

```bash
#!/bin/bash
# ABOUTME: Argument parsing framework
# ABOUTME: Supports short/long options with values

# Default values
VERBOSE=false
DRY_RUN=false
CONFIG_FILE=""

show_usage() {
    cat << EOF
Usage: $SCRIPT_NAME [OPTIONS] <arguments>

Options:
    -h, --help          Show this help message
    -v, --verbose       Enable verbose output
    -n, --dry-run       Show what would be done without doing it
    -c, --config FILE   Use specified configuration file
    --version           Show version information

Examples:
    $SCRIPT_NAME --verbose process
    $SCRIPT_NAME -c config.yaml --dry-run

EOF
}

parse_args() {
    while [[ $# -gt 0 ]]; do
        case "$1" in
            -h|--help)
                show_usage
                exit 0
                ;;
            -v|--verbose)
                VERBOSE=true
                LOG_LEVEL="DEBUG"
                shift
                ;;
            -n|--dry-run)
                DRY_RUN=true
                shift
                ;;
            -c|--config)
                CONFIG_FILE="$2"
                shift 2
                ;;
            --version)
                echo "$SCRIPT_NAME version $VERSION"
                exit 0
                ;;
            --)
                shift
                break
                ;;
            -*)
                die "Unknown option: $1"
                ;;
            *)
                break
                ;;
        esac
    done

    # Remaining arguments
    ARGS=("$@")
}
```

Related Skills

agent-os-framework

5
from vamseeachanta/workspace-hub

Generate standardized .agent-os directory structure with product documentation, mission, tech-stack, roadmap, and decision records. Enables AI-native workflows.

tax-form-currency-field-handling

5
from vamseeachanta/workspace-hub

Handle currency field rounding and formatting quirks when entering precise decimal values into tax software forms

diagnose-venv-shebang-import-errors

5
from vamseeachanta/workspace-hub

Debugging pattern for ModuleNotFoundError when CLI entry points use wrong Python interpreter

diagnose-shebang-virtualenv-import-errors

5
from vamseeachanta/workspace-hub

Debugging pattern for ModuleNotFoundError when CLI entry points use wrong Python interpreter

diagnose-shebang-venv-import-errors

5
from vamseeachanta/workspace-hub

Troubleshoot ModuleNotFoundError in CLI tools by identifying shebang-venv mismatches

diagnose-dirty-ntfs-mount-errors

5
from vamseeachanta/workspace-hub

Troubleshoot NTFS mount failures by identifying dirty volume flags and driver type

debug-toml-section-scoping-errors

5
from vamseeachanta/workspace-hub

Diagnose and fix TOML configuration errors caused by misplaced key-value pairs in named sections

batch-syntax-repair-from-injection-errors

5
from vamseeachanta/workspace-hub

Detect and fix systematic syntax errors caused by line-injection scripts that split multiline constructs

bash-pipefail-grep-error-handling

5
from vamseeachanta/workspace-hub

Handle grep exit codes safely under set -eo pipefail by isolating pipeline failure scope

bash-script-framework-example-1-create-new-cli-tool

5
from vamseeachanta/workspace-hub

Sub-skill of bash-script-framework: Example 1: Create New CLI Tool (+1).

bash-script-framework

5
from vamseeachanta/workspace-hub

Create organized bash script structure with color output, menu systems, error handling, and cross-platform support. Standardizes CLI tooling.

bash-cli-framework-1-color-definitions

5
from vamseeachanta/workspace-hub

Sub-skill of bash-cli-framework: 1. Color Definitions (+3).