bash-script-writing_skill

This skill helps you write clean, modular bash scripts with strict error handling and clear structure for reliable automation.
  • Shell

31

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill steveclarke/dotfiles --skill bash-script-writing

  • SKILL.md2.6 KB

Overview

This skill teaches how to write clean, modular, production-ready bash scripts with strict error handling and a maintainable structure. It provides a recommended file layout, helper functions, naming conventions, and a checklist to ensure reliable automation. Use it to produce scripts that are readable, testable, and safe for production use.

How this skill works

The skill prescribes a template and conventions: strict mode (set -euo pipefail), a documented header, top-level main() orchestration, and small focused functions. It supplies logging helpers (log, info, warn, error), clear error patterns, and examples of good vs bad error handling. Follow the template to refactor or create scripts that fail fast with descriptive messages.

When to use it

  • Creating a new automation script for deployment, backup, or maintenance
  • Refactoring monolithic or fragile bash code into modular functions
  • When asked to "write a script", "bash script", or "shell script" for automating tasks
  • Adding robust error handling and clear logs to existing shell scripts
  • Standardizing scripts across multiple machines for consistent behavior

Best practices

  • Start every script with strict mode: set -euo pipefail
  • Include a header with overview, usage, and configuration at the top
  • Put main() near the top so the workflow is obvious
  • Prefer small, single-purpose functions with verb-based names
  • Use helper logging functions and always provide context in error messages
  • Avoid silent failures; check command results and handle failures explicitly

Example use cases

  • A deployment script that creates directories, uploads artifacts, and restarts services with clear failure messages
  • A setup script that validates environment variables, configures hosts, and reports missing config
  • Refactoring a large installer into parse_arguments, validate, install, and cleanup functions
  • Daily maintenance cron script that logs progress and exits with meaningful codes
  • Cross-machine sync tool that standardizes variables and error handling across systems

FAQ

Strict mode prevents silent errors: it exits on failures, treats unset variables as errors, and makes pipelines fail when any command fails.

How large should functions be?

Keep functions focused and short—roughly 5–20 lines. If you need to describe the behavior with an "and", split it into two functions.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
bash-script-writing skill by steveclarke/dotfiles | VeilStrat