wshobson avatar

Bash Defensive Patterns

Built for developers who've been burned by shell scripts failing in production. Implements bash strict mode, proper error trapping, and variable quoting patterns that prevent the usual disasters. Covers atomic file operations, signal handling for background processes, and idempotent script design. The argument parsing and logging templates alone will save you from reinventing wheels. Most valuable for CI/CD pipelines and system automation where a script failure at 2 AM costs real money. Takes the guesswork out of defensive bash programming with patterns that actually work in the wild.

skills.sh installs
14.1K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill bash-defensive-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
DevOps & CI/CD, Documentation, CLI & Terminal

More from wshobson/agents

All 174
1wshobson avatarsecrets-managementwshobson/agentsImplement secure secrets management for CI/CD pipelines using Vault, AWS Secrets Manager, or native platform solutions. Use when handling sensitive credentials,13.6Kskills.sh installs
2pluginagentmarketplace avatarjava-spring-bootpluginagentmarketplace/custom-plugin-javaBuild production Spring Boot applications - REST APIs, Security, Data, Actuator11.8Kskills.sh installs
3wshobson avatarbats-testing-patternswshobson/agentsMaster Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test11.4Kskills.sh installs
4getcargohq avatarcargo-gtmgetcargohq/cargo-skillsFront door for any GTM task on Cargo — sourcing, waterfall enrichment, email/phone/LinkedIn lookup, email verification, scoring, qualification, sequencing, CRM 11.2Kskills.sh installs
5getcargohq avatarcargo-aigetcargohq/cargo-skillsCreate and configure AI agents, attach knowledge for RAG, manage MCP servers, and handle agent memories using the Cargo CLI. Use when the user wants to create o11.2Kskills.sh installs
6getcargohq avatarcargo-analyticsgetcargohq/cargo-skillsDownload workflow run results, export segment data, and monitor run metrics using the Cargo CLI. Use when the user wants run metrics, error rates, data export, 11.2Kskills.sh installs