bash-defensive-patterns

Apply strict mode, error handling, and input validation to Bash scripts.

Updated Feb 2, 2026
One-click install
npx skills add https://github.com/raultorres2603/ComplAI --skill bash-defensive-patterns-raultorres2603
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bash-defensive-patterns
Source: https://github.com/raultorres2603/ComplAI/tree/main/.opencode/skills/bash-defensive-patterns
Command: npx skills add https://github.com/raultorres2603/ComplAI --skill bash-defensive-patterns-raultorres2603

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defensive Bash patterns help developers write robust, fault-tolerant shell scripts, reducing runtime errors and maintenance overhead in production environments.

Core Features & Use Cases

  • Strict mode and error handling to catch failures early.
  • Safe variable handling, input validation, and portable design for cross-platform use.
  • Logging, cleanup traps, and idempotent operations for predictable automation in CI/CD pipelines and system utilities.

Quick Start

Start by enabling strict mode and applying the defensive patterns to your Bash scripts.

Frequently Asked Questions about bash-defensive-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make bash scripts fail safely on errors?

Defensive bash patterns enable strict mode and error handling to catch failures early. Scripts immediately exit on errors and undefined variables, preventing silent runtime failures and reducing maintenance overhead in production.

What is strict mode in bash scripting?

Strict mode in bash scripting enforces safe variable usage and immediate termination on error. It treats unset variables as errors and stops execution on the first pipeline failure, ensuring fault-tolerant shell scripts.

How do I clean up temporary files when a bash script exits unexpectedly?

Bash cleanup traps automatically execute when a script exits, ensuring temporary files are removed even on unexpected termination. Trap-based cleanup functions enforce predictable automation and resource management in CI/CD pipelines.

How do I write idempotent bash scripts for CI/CD automation?

Idempotent bash scripts produce identical results across multiple runs without side effects. Defensive patterns achieve this through safe variable handling, input validation, and portable design for predictable CI/CD automation.

Can I use defensive bash patterns for cross-platform system utilities?

Defensive bash patterns enforce portable design and safe variable handling for cross-platform use. They support system utilities by ensuring scripts run reliably across different environments without unexpected failures.