Skip to content
FunCoding

robust-error-handling-in-scripts

Use this skill when writing shell scripts, Python automation, or any unattended batch job. Ensure failures are detected, logged, and handled — never silently ignored.

Star
3,472
License
MIT
Last commit
Jun 7, 2026

memory_data/skills/robust-error-handling-in-scripts/SKILL.md

View on GitHub

Robust Error Handling in Scripts

Shell scripts:

set -euo pipefail  # Exit on error, undefined var, pipe failure
trap 'echo "Failed at line $LINENO"' ERR

Python scripts:

import logging, sys
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
try:
    main()
except Exception as e:
    logging.exception("Unhandled error: %s", e)
    sys.exit(1)

Retry with backoff for transient network/API failures:

from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=2, max=10))
def call_api(): ...

Similar Skills

perfect-docs

MAmattpocock/skills337k4,217 new stars in the last 7 days

Featured

domain-modeling

Write a glossary, record ADRs, and clarify vague terms.

MAmattpocock/skills337k4,217 new stars in the last 7 days

writing-beats

MAmattpocock/skills337k4,217 new stars in the last 7 days

writing-shape

MAmattpocock/skills337k4,217 new stars in the last 7 days

writing-fragments

MAmattpocock/skills337k4,217 new stars in the last 7 days

writing-plans

OBobra/superpowers331k5,030 new stars in the last 7 days