Shell scripting best practices for writing safe, portable, and maintainable bash/sh scripts. Use when writing, reviewing, or refactoring shell scripts,…
Shell Scripts Best Practices (Community)
Comprehensive best practices guide for shell scripting, designed for AI agents and LLMs. Contains 49 rules across 9 categories, prioritized by impact from critical (safety, portability) to incremental (style). Each rule includes detailed explanations, real-world examples comparing incorrect vs. correct implementations, and specific impact metrics.
When to Apply
Reference these guidelines when:
Writing new bash or POSIX shell scripts
Reviewing shell scripts for security vulnerabilities
Debugging scripts that fail silently or behave unexpectedly
Porting scripts between Linux, macOS, and containers
Optimizing shell script performance
Setting up CI/CD pipelines with shell scripts
Rule Categories by Priority
related skills
semantically similar in the cross-vendor index
don't have the plugin yet? install it then click "run inline in claude" again.
+organizes guidance by risk tier (safety/portability first), making prioritization explicit for constrained environments
+provides before-after code examples rather than prescriptions only, improving retention and verifiability
+explicitly names failure modes (silent failure, portability breaks) that scripts encounter in practice
weaknesses
~no numbered step procedure shown; reads as reference guide, not actionable workflow or decision tree
~trigger phrases stay generic (reviewing, debugging, optimizing) rather than concrete shell failure patterns (shellcheck violations, posix flag mismatches, word-split bugs)
~output contract and outcome signal absent; unclear what success looks like after applying these rules