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.
Imported description, not reviewed yet
This item came from its original repository and was only scanned automatically; no editor has written an Arabic description for it yet. Read its content yourself before you rely on it. This page is not indexed by search engines until it is reviewed.
Download
Install
After downloading, run the command in a terminal. unzip asks before it replaces any file that is there.
For this project
It goes in: .claude/skills/shell-scripting-bash-defensive-patterns/
mkdir -p .claude/skills && unzip ~/Downloads/shell-scripting-bash-defensive-patterns.zip -d .claude/skillsFor your account on the whole machine
It goes in: ~/.claude/skills/shell-scripting-bash-defensive-patterns/
mkdir -p ~/.claude/skills && unzip ~/Downloads/shell-scripting-bash-defensive-patterns.zip -d ~/.claude/skills
Instructions
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
- Always use strict mode -
set -Eeuo pipefail - Quote all variables -
"$variable"prevents word splitting - Use [[]] conditionals - More robust than [ ]
- Implement error trapping - Catch and handle errors gracefully
- Validate all inputs - Check file existence, permissions, formats
- Use functions for reusability - Prefix with meaningful names
- Implement structured logging - Include timestamps and levels
- Support dry-run mode - Allow users to preview changes
- Handle temporary files safely - Use mktemp, cleanup with trap
- Design for idempotency - Scripts should be safe to rerun
- Document requirements - List dependencies and minimum versions
- Test error paths - Ensure error handling works correctly
- Use
command -v- Safer thanwhichfor checking executables - Prefer printf over echo - More predictable across systems
Files
- folderreferences11 KB
- details.md11 KB
- LICENSE1 KB
- SKILL.md1.9 KB
What the automatic scan found
We scanned the files automatically when they were imported. This is what the scan pointed at. It does not mean the item is harmful, and it does not mean it is safe: read it yourself.
- Needs a lookDeletes files forcibly and recursively
In file plugins/shell-scripting/skills/bash-defensive-patterns/references/details.md, line 33
Comments (0)
No comments yet. Be the first.
Sign in to comment. Commenting comes at level 1 (Member).