Source profileQuality 79/100

wshobson/agents/plugins/shell-scripting/skills/bash-defensive-patterns/SKILL.md

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.

Source repository stars
38,313
Declared platforms
0
Static risk flags
1
Last source update
2026-07-22
Source checked
2026-07-28

Decision brief

What it does—and where it fits

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.

Best for

  • Writing production automation scripts
  • Building CI/CD pipeline scripts
  • Creating system administration utilities

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/wshobson/agents --skill "plugins/shell-scripting/skills/bash-defensive-patterns"
Safe inspection promptEditorial

Inspect the Agent Skill "bash-defensive-patterns" from https://github.com/wshobson/agents/blob/c4b82b0ad771190355eb8e204b1329732a18449a/plugins/shell-scripting/skills/bash-defensive-patterns/SKILL.md at commit c4b82b0ad771190355eb8e204b1329732a18449a. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    When to Use This Skill

    Writing production automation scripts

    Writing production automation scriptsBuilding CI/CD pipeline scriptsCreating system administration utilities
  2. 02

    Detailed patterns and worked examples

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

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

    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…

    Always use strict mode - set -Eeuo pipefailQuote all variables - "$variable" prevents word splittingUse [[]] conditionals - More robust than [ ]

Permission review

Static risk signals and limitations

Reads files

low · line 18

The documentation asks the agent to read local files, directories, or repositories.

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

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score79/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars38,313SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
wshobson/agents
Skill path
plugins/shell-scripting/skills/bash-defensive-patterns/SKILL.md
Commit
c4b82b0ad771190355eb8e204b1329732a18449a
License
MIT
Collected
2026-07-28
Default branch
main
View the original SKILL.md

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