bash-best-practices

Provide guidelines and code examples for robust, portable Bash scripts.

Updated Feb 12, 2026
One-click install
npx skills add https://github.com/kobogithub/knowledge --skill bash-best-practices
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bash-best-practices
Source: https://github.com/kobogithub/knowledge/tree/main/skills/bash-best-practices
Command: npx skills add https://github.com/kobogithub/knowledge --skill bash-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write more reliable, maintainable, and portable Bash scripts by providing a comprehensive set of best practices and patterns.

Core Features & Use Cases

  • Defensive Coding: Implement strict modes, safe variable handling, and robust error checking.
  • Portability: Write scripts that work consistently across different operating systems and Bash versions.
  • Common Patterns: Utilize pre-built functions and structures for logging, retries, argument parsing, and more.
  • Use Case: Ensure your CI/CD pipeline scripts are resilient to failures and execute predictably by adopting these best practices.

Quick Start

Apply the bash-best-practices skill to review and refactor your existing Bash script located at './my_script.sh'.

Frequently Asked Questions about bash-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write robust Bash scripts that handle errors correctly?▼

To write robust Bash scripts, apply strict modes, safe variable quoting, and robust error checking. These practices prevent unpredictable failures and ensure scripts execute predictably in automation and CI/CD pipelines.

What is the best way to make shell scripts portable across different operating systems?▼

Making shell scripts portable requires following specific guidelines for cross-OS compatibility. This involves utilizing common scripting patterns and avoiding OS-specific syntax to ensure consistent execution across different environments.

How do I add a strict mode to my Bash script for CI/CD automation?▼

Adding strict mode to Bash scripts involves implementing defensive coding practices like safe variable handling and error checking. This ensures your CI/CD pipeline scripts are resilient and execute predictably.

Why does my Bash script fail when variables are unquoted?▼

Bash scripts fail with unquoted variables due to word splitting and globbing issues. Proper variable quoting is a core defensive coding practice that prevents unexpected failures and ensures reliable script execution.

What are common patterns for logging and argument parsing in shell scripting?▼

Common shell scripting patterns provide pre-built functions and structures for logging, retries, and argument parsing. Utilizing these patterns helps developers write more maintainable and reliable Bash scripts.

Can I use these Bash scripting best practices for DevOps automation tasks?▼

Yes, these Bash scripting best practices are essential for DevOps automation tasks. They provide guidelines for defensive coding, portability, and common patterns required for reliable shell scripting in DevOps environments.