bash-shell-scripting

Enforce strict-mode safety, error handling, and cleanup in Bash scripts.

15|2|Updated Dec 13, 2025
One-click install
npx skills add https://github.com/d-padmanabhan/agent-engineering-handbook --skill bash-shell-scripting-d-padmanabhan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bash-shell-scripting
Source: https://github.com/d-padmanabhan/agent-engineering-handbook/tree/main/skills/bash-shell-scripting
Command: npx skills add https://github.com/d-padmanabhan/agent-engineering-handbook --skill bash-shell-scripting-d-padmanabhan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Bash scripting turns into a reliability nightmare when error handling, portability, and argument validation are inconsistent, leading to silent failures and flaky CI runs.

Core Features & Use Cases

  • Strict-mode correctness: Applies safe defaults like fail-fast behavior and unset-variable protections to reduce hidden runtime bugs.
  • Production-grade error handling: Supports structured ERR trapping and consistent cleanup patterns for dependable execution.
  • Portability and quality gates: Enforces shellcheck cleanliness and shfmt formatting so scripts stay predictable across environments.
  • Real-world use case: Use it to harden a deployment or repo-maintenance script that must safely validate inputs, prevent concurrent runs, and produce clear failures.

Quick Start

Ask the AI to "harden this script by converting it to strict mode, adding argument parsing, shellcheck/shfmt compliance, and a safe cleanup trap."

Frequently Asked Questions about bash-shell-scripting

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

FAQPage Schema
How do I add strict mode and error handling to a Bash script?

To add strict mode and error handling to a Bash script, apply fail-fast defaults, unset-variable protections, and structured ERR trapping to prevent silent failures and ensure consistent cleanup behavior.

How do I prevent concurrent runs in shell scripts?

You can prevent concurrent runs in shell scripts by implementing optional lock and trap patterns, which manage concurrency safety and prevent partial execution during overlapping process invocations.

Does shellcheck work with shfmt formatting for CLI automation?

Shellcheck works alongside shfmt formatting to enforce portability and quality gates for CLI automation, requiring zero tolerance for linting errors and consistent formatting compliance across environments.

What is the best way to parse arguments safely in production Bash scripts?

The best way to parse arguments safely in production Bash scripts is to enforce safe quoting and robust validation patterns, preventing subshell pitfalls and ensuring predictable execution for Makefile-adjacent automation.

Why does my Bash deployment script fail silently during cleanup?

Your Bash deployment script likely fails silently during cleanup because it lacks structured ERR trapping and consistent cleanup traps, which are required to produce clear failures and prevent partial execution.