shell-script-robust

Write and review Bash and POSIX shell scripts with strict error handling and idempotent execution.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill shell-script-robust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-script-robust
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/shell-script-robust
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill shell-script-robust

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the fragility of shell scripting by enforcing strict safety rails, preventing common pitfalls like word-splitting, silent failures, and resource leaks.

Core Features & Use Cases

  • Production-Grade Hardening: Implements strict error handling (set -euo pipefail) and robust quoting to ensure scripts behave predictably.
  • Idempotency & Safety: Provides patterns for safe re-runs, dry-run modes, and automatic cleanup of temporary files using traps.
  • Use Case: Use this when writing CI/CD glue code, deployment automation, or cron jobs that must be reliable, secure, and easy to debug.

Quick Start

Use the shell-script-robust skill to review my current bash script and harden it with strict error handling and proper cleanup patterns.

Frequently Asked Questions about shell-script-robust

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

FAQPage Schema
How do I write a bash script with strict error handling and proper cleanup?

To write a bash script with strict error handling, enforce `set -euo pipefail`, apply robust quoting to prevent word-splitting, and implement trap-based cleanup for temporary resources. This guarantees predictable execution and prevents silent failures in production environments.

What is the best way to make shell scripts idempotent for CI/CD pipelines?

The best way to make shell scripts idempotent for CI/CD pipelines is to implement safe re-run patterns, dry-run modes, and trap-based automatic cleanup. This prevents partial state execution and ensures reliable automation glue code across multiple pipeline runs.

Why does my shell script fail silently in automation and how do I fix it?

Shell scripts fail silently in automation when strict error handling is missing. Fix this by applying `set -euo pipefail` to catch failures immediately, using defensive programming to validate inputs, and enforcing shellcheck compliance to eliminate common shell vulnerabilities.

Can I use POSIX shell scripting for portable deployment automation across different systems?

Yes, you can use POSIX shell scripting for portable deployment automation across different systems. By targeting POSIX compliance and enforcing defensive programming patterns, your system maintenance scripts achieve high reliability and portability across diverse Unix-like environments.

How do I ensure shellcheck compliance when hardening existing bash scripts?

To ensure shellcheck compliance when hardening existing bash scripts, review your code against strict safety rails that enforce proper quoting and strict error handling. This process addresses common shell vulnerabilities and transforms fragile scripts into production-grade, reliable automation code.