shell-scripting

Write defensive Bash scripts with ShellCheck compliance and safety patterns.

155|25|Updated Apr 27, 2025
One-click install
npx skills add https://github.com/sammcj/agentic-coding --skill shell-scripting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-scripting
Source: https://github.com/sammcj/agentic-coding/tree/main/Claude/skills/shell-scripting
Command: npx skills add https://github.com/sammcj/agentic-coding --skill shell-scripting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates common bash scripting pitfalls and security risks by providing battle-tested patterns for writing safe, maintainable shell code.

Core Features & Use Cases

  • Defensive Programming: Comprehensive safety patterns for variable handling, error checking, and input validation.
  • ShellCheck Compliance: Automated linting guidance to catch bugs before they happen.
  • Use Case: Imagine you need to create a deployment script that processes configuration files, validates dependencies, and handles errors gracefully without crashing your production environment.

Quick Start

Use the shell-scripting skill to review my bash script for security issues and suggest improvements based on modern best practices.

Frequently Asked Questions about shell-scripting

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

FAQPage Schema
How do I write bash scripts that are safe and follow best practices?

Write bash scripts safely by enforcing a strict mode (set -euo pipefail), using proper shebangs, quoting variables correctly, validating inputs, checking for required variables, and handling errors explicitly. ShellCheck linting catches common mistakes automatically before runtime.

What are the main security risks in shell scripting and how do I avoid them?

Common bash security risks include unquoted variables, missing error handling, unsafe array operations, and unchecked user input. Defensive programming patterns—mandatory variable checks, input validation, safe function definitions, and proper quoting—eliminate these vulnerabilities in scripts under 100 lines.

Can I use bash for deployment and automation tasks?

Bash is well-suited for deployment automation, orchestrating other programs, and simple build pipelines. This approach works for scripts that coordinate tools and handle straightforward workflows, avoiding complex logic and data structures where other languages perform better.

How do I check my bash script for bugs and compliance issues?

ShellCheck is a linting tool that automatically detects bash scripting errors and anti-patterns. Run it against your script to catch bugs before execution and ensure compliance with modern shell scripting standards and safety guidelines.

What should I include in a reliable bash script template?

A reliable bash script template includes a proper shebang (#!/bin/bash), strict mode flags (set -euo pipefail), input validation, error handling with exit codes, quoted variables, required variable checks, and safe array handling patterns ready for immediate use.

When should I not use bash for a task?

Avoid bash for scripts requiring complex business logic, nontrivial data structures, or extensive conditional workflows. For these cases, use a general-purpose programming language; bash excels at orchestration, small utilities, and straightforward automation under 100 lines.