# Writing Bash Scripts

> Bash script style guide. Always use when writing bash scripts, shell scripts, or CLI bash tools.

- Skill: `lexler/writing-bash-scripts` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add lexler/writing-bash-scripts`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lexler/writing-bash-scripts/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: lexler (https://skillmd.com/u/lexler)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/lexler/writing-bash-scripts

---


# Bash Script Style Guide

- Use `#!/usr/bin/env bash` as shebang
- Always use `set -euo pipefail` for safety
- Keep scripts minimal: no unnecessary comments or echoes
- Minimal input validation; print usage to stderr and exit if inputs are missing/invalid
- Don't check for installed commands if failure is obvious on use
- Make script executable: `chmod +x <script>`
- Prefer concise, direct logic over verbosity

