bash-defensive-patterns
Has your agent write safer and more reliable Bash scripts. It's useful for automating system tasks, ensuring they work correctly.
What it does
This tool helps you write safer and more reliable command-line scripts (Bash). It teaches you how to avoid common mistakes and ensure your scripts work correctly, even in unexpected situations.
When to use it
- ✓When creating scripts to automate tasks on your computer.
- ✓When building tools that run on servers or in the cloud.
- ✓When you need your scripts to be robust and not fail easily.
Example of what to ask your AI
“How can I write a Bash script that checks if a file exists before trying to delete it?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool suggests practices like checking what you're about to do, ensuring the information the script receives is correct, and setting up the script to report errors.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill bash-defensive-patternsOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/bash-defensive-patterns/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
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.
Use this skill when
- 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
Do not use this skill when
- You need a single ad-hoc shell command, not a script
- The target environment requires strict POSIX sh only
- The task is unrelated to shell scripting or automation
Instructions
- Confirm the target shell, OS, and execution environment.
- Enable strict mode and safe defaults from the start.
- Validate inputs, quote variables, and handle files safely.
- Add logging, error traps, and basic tests.
Safety
- Avoid destructive commands without confirmation or dry-run flags.
- Do not run scripts as root unless strictly required.
Refer to resources/implementation-playbook.md for detailed patterns, checklists, and templates.
Resources
resources/implementation-playbook.mdfor detailed patterns, checklists, and templates.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
FAQ
What are 'Bash scripts'?
They are small sequences of commands you write for the computer to automatically perform a task.
Why do I need 'defensive scripts'?
To prevent your scripts from causing accidental problems, like deleting important files or stopping unexpectedly.
Will this tool write the script for me?
No, it teaches you best practices so you can write better, safer scripts yourself.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 48k
- Ranking position
- #2400
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC