0128-bash-defensive-patterns
CommunityWrite safer Bash scripts with robust guards.
System Documentation
What problem does it solve?
It prevents common Bash failures—silent error masking, unsafe variable handling, brittle parsing, and unmanaged cleanup—so your production scripts behave reliably under real-world edge cases.
Core Features & Use Cases
- Strict mode foundations: Use
set -Eeuo pipefailto fail fast on errors, unset variables, and broken pipelines. - Error trapping and cleanup: Add
traphandlers for ERR and EXIT to log failures and reliably remove temporary resources. - Defensive safety patterns: Apply quoting discipline, safe arrays/read loops, robust argument parsing, structured logging, signal-aware orchestration, and atomic/idem-potent file operations.
Use Case: Build a CI/CD helper script that moves artifacts, validates inputs, logs meaningful status, and safely cleans up even when jobs are interrupted or commands fail mid-run.
Quick Start
Use the 0128-bash-defensive-patterns skill to harden your deployment Bash script by enabling strict mode, validating inputs, and adding traps for error logging and temporary file cleanup.
Dependency Matrix
Required Modules
None requiredComponents
Standard packageđź’» Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: 0128-bash-defensive-patterns Download link: https://github.com/MrJmpl3/codex_____data_____configuration/archive/main.zip#0128-bash-defensive-patterns Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.