Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Bash Defensive Patterns

  • 9.5k installs
  • 38.3k repo stars
  • Updated July 22, 2026
  • wshobson/agents

bash-defensive-patterns is an agent skill that Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring.

About

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety. --- name: bash-defensive-patterns description: Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety. --- # Bash Defensive Patterns Comprehensive guidance for writing production-ready Bash scripts using defensive programming techniques, error handling, and safety best practices to prevent common pitfalls and ensure reliability. ## When to Use This Skill - Writing production automation scripts - Building CI/CD pipeline scripts - Creating system administration utilities - Developing error-resilient deployment automation - Writing scripts that must handle edge cases safely - Building maintainable shell script libraries - Implementing comprehensive logging and monitoring - Creating scripts that must work across different platforms ## Detailed patterns and worked examples Detailed pattern documentation lives in `references/details.md`.

  • Bash Defensive Patterns
  • Writing production automation scripts
  • Building CI/CD pipeline scripts
  • Creating system administration utilities
  • Developing error-resilient deployment automation

Bash Defensive Patterns by the numbers

  • 9,539 all-time installs (skills.sh)
  • +228 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #94 of 2,184 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

bash-defensive-patterns capabilities & compatibility

Capabilities
bash defensive patterns · writing production automation scripts · building ci/cd pipeline scripts · creating system administration utilities · developing error resilient deployment automation
Use cases
documentation
From the docs

What bash-defensive-patterns says it does

--- name: bash-defensive-patterns description: Master defensive Bash programming techniques for production-grade scripts.
SKILL.md
Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.
SKILL.md
Read that file when the navigation tier above is insufficient.
SKILL.md
**Always use strict mode** - `set -Eeuo pipefail` 2.
SKILL.md
npx skills add https://github.com/wshobson/agents --skill bash-defensive-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs9.5k
repo stars38.3k
Security audit3 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

What problem does bash-defensive-patterns solve for developers using this skill?

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

Who is it for?

Developers who need bash-defensive-patterns patterns described in the cached skill documentation.

Skip if: Skip when docs are empty or the task is outside the skill's documented scope.

When should I use this skill?

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

What you get

Actionable workflows and conventions from SKILL.md for bash-defensive-patterns.

  • hardened bash script patterns
  • trap handler examples

By the numbers

  • Documents 4 strict-mode flags: -E, -e, -u, and pipefail

Files

SKILL.mdMarkdownGitHub ↗

Bash Defensive Patterns

Comprehensive guidance for writing production-ready Bash scripts using defensive programming techniques, error handling, and safety best practices to prevent common pitfalls and ensure reliability.

When to Use This Skill

  • Writing production automation scripts
  • Building CI/CD pipeline scripts
  • Creating system administration utilities
  • Developing error-resilient deployment automation
  • Writing scripts that must handle edge cases safely
  • Building maintainable shell script libraries
  • Implementing comprehensive logging and monitoring
  • Creating scripts that must work across different platforms

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices Summary

1. Always use strict mode - set -Eeuo pipefail 2. Quote all variables - "$variable" prevents word splitting 3. Use [[]] conditionals - More robust than [ ] 4. Implement error trapping - Catch and handle errors gracefully 5. Validate all inputs - Check file existence, permissions, formats 6. Use functions for reusability - Prefix with meaningful names 7. Implement structured logging - Include timestamps and levels 8. Support dry-run mode - Allow users to preview changes 9. Handle temporary files safely - Use mktemp, cleanup with trap 10. Design for idempotency - Scripts should be safe to rerun 11. Document requirements - List dependencies and minimum versions 12. Test error paths - Ensure error handling works correctly 13. Use `command -v` - Safer than which for checking executables 14. Prefer printf over echo - More predictable across systems

Related skills

How it compares

Use bash-defensive-patterns for shell script hardening during review; use general debugging skills for runtime application errors outside Bash.

FAQ

What does bash-defensive-patterns do?

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

When should I use bash-defensive-patterns?

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

Is bash-defensive-patterns safe to install?

Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.