Automated summary
A reference guide for writing defensive, portable Bash scripts aimed at production use, automation, and CI/CD pipelines.
Strengths
- Covers strict mode (`set -Eeuo pipefail`), consistent quoting, and EXIT traps for cleaning up temporary resources
- Ships a concrete quality checklist: ShellCheck, shfmt, Bats tests, input validation, and `--help` support
- Explicitly addresses Linux/macOS portability, input safety, and common pitfalls such as iterating over `$(ls)`
- Points to topical deep-dive guides for performance, security, advanced techniques, and tooling
Limitations
- The main body is largely an index; the real detail lives in external reference files not included here
- Does not discuss alternatives such as Python, Go, or config generators for complex automation needs
- Assumes prior familiarity with shell concepts like arrays, expansions, and exit codes
Use it whenever you need to author or harden a shell script for automation, deployment, or a CI/CD step.
Skip it for quick one-liners, or when the business logic outgrows what a shell script can reasonably maintain.
Security analysis
SafeThe skill is instructional and focused on defensive Bash practices, portability, testing, and CI/CD. Although it allows Bash and mentions commands like rm -rf, those are presented as safety examples with proper quoting and option termination; there are no destructive, exfiltrating, obfuscated, or safety-disabling instructions.
No concerns found
How this analysis is madeExamples
Write a production-grade bash deployment script that builds the app, uploads it via rsync, and restarts the service. Use strict mode, proper error handling, and a dry-run flag.Review this bash script for defensive programming issues: quoting, error handling, temp file cleanup, and ShellCheck warnings. Then rewrite it with fixes.Create a bash script for our CI pipeline that runs tests, generates a coverage report, and exits non-zero on any failure. Add Bats tests for it.name: bash-scripting description: Master of defensive Bash scripting for production automation, CI/CD pipelines, and system utilities. Expert in safe, portable, and testable shell scripts. Use when writing, creating, authoring, generating, or developing bash scripts, shell scripts, or automation. Also triggers for learning bash best practices, understanding defensive programming patterns, implementing error handling, ensuring portability, following shellcheck recommendations, or applying production-grade bash standards. Helps with CI/CD scripts, system utilities, deployment automation, and production bash code. allowed-tools: [Read, Edit, Write, Grep, Glob, Bash]
Reference Files
Deep-dive guides for specific topics:
- patterns-and-conventions.md - Defensive programming patterns, strict mode, and code style
- safety-and-security.md - Security patterns, input validation, and hardening
- portability-and-compatibility.md - Cross-platform compatibility and Bash version features
- documentation-and-ci-cd.md - Documentation standards and CI/CD integration
- performance-and-optimization.md - Optimization techniques and profiling
- advanced-techniques.md - Advanced patterns, dependencies, and common pitfalls
- tools-and-frameworks.md - Essential tools, testing frameworks, and external resources
Bash Scripting
Master guide for defensive Bash scripting following production-grade best practices. This skill provides comprehensive patterns, standards, and techniques for writing safe, portable, and maintainable shell scripts for automation, CI/CD pipelines, and system utilities.
Use this skill when writing new bash scripts or improving existing ones to follow defensive programming principles.
Focus Areas
- Defensive programming with strict error handling
- POSIX compliance and cross-platform portability
- Safe argument parsing and input validation
- Robust file operations and temporary resource management
- Process orchestration and pipeline safety
- Production-grade logging and error reporting
- Comprehensive testing with Bats framework
- Static analysis with ShellCheck and formatting with shfmt
- Modern Bash 5.x features and best practices
- CI/CD integration and automation workflows
Core Approach
Essential defensive programming patterns (see patterns-and-conventions.md for complete details):
- Strict mode: Always use
set -Eeuo pipefailwith error trapping - Quote variables: Prevent word splitting and globbing issues
- Safe iteration: Use proper arrays, avoid
for f in $(ls) - Conditionals: Use
[[ ]]for Bash,[ ]for POSIX - Temp files: Create safely with
mktempand cleanup traps - Output: Prefer
printfoverechofor reliability - Input validation: Check required variables with
: "${VAR:?message}" - Safe operations: End option parsing with
--, userm -rf -- "$dir" - NUL-safe patterns: Use
find -print0 | while IFS= read -r -d ''for filenames - Logging: Implement structured logging with configurable verbosity
- Idempotency: Design scripts to be repeatable and support dry-run modes
Quality Checklist
- Scripts pass ShellCheck static analysis with minimal suppressions
- Code is formatted consistently with shfmt using standard options
- Comprehensive test coverage with Bats including edge cases
- All variable expansions are properly quoted
- Error handling covers all failure modes with meaningful messages
- Temporary resources are cleaned up properly with EXIT traps
- Scripts support
--helpand provide clear usage information - Input validation prevents injection attacks and handles edge cases
- Scripts are portable across target platforms (Linux, macOS)
- Performance is adequate for expected workloads and data sizes
Output
Production-ready deliverables:
- Bash scripts with defensive programming practices
- Test suites using bats-core or shellspec with TAP output
- CI/CD pipeline configurations for automated testing
- Documentation (shdoc markdown, shellman man pages)
- Static analysis configuration (.shellcheckrc, .shfmt.toml)
- Security review with SAST and secrets scanning
- Structured logging and observability
Where to Find What
- Getting started: Review Focus Areas and Core Approach above
- Defensive patterns: patterns-and-conventions.md - Strict mode, quoting, code style
- Security: safety-and-security.md - Input validation, secure file ops, hardening
- Cross-platform: portability-and-compatibility.md - Platform detection, Bash versions
- CI/CD setup: documentation-and-ci-cd.md - GitHub Actions, pre-commit hooks
- Performance: performance-and-optimization.md - Profiling, logging, optimization
- Advanced patterns: advanced-techniques.md - Complex patterns, dependencies, pitfalls
- Tools: tools-and-frameworks.md - ShellCheck, bats-core, external resources
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/bash-scripting-mrwakbbr/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/bash-scripting-mrwakbbr' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/bash-scripting-mrwakbbr/download' --output '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md.part' && mv '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md.part' '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && test -s '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/bash-scripting' && cp -R '.skill-downloads/bash-scripting-mrwakbbr' '.claude/skills/bash-scripting'Cursor
test -f '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && test -s '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/bash-scripting' && cp -R '.skill-downloads/bash-scripting-mrwakbbr' '.cursor/skills/bash-scripting'Codex
test -f '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && test -s '.skill-downloads/bash-scripting-mrwakbbr/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/bash-scripting' && cp -R '.skill-downloads/bash-scripting-mrwakbbr' '.agents/skills/bash-scripting'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/bash-scripting-mrwakbbr'openskills read 'bash-scripting-mrwakbbr'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/bash-scripting-mrwakbbr/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.