shell-scripting

Writes and edits POSIX-compliant shell scripts with strict error handling and quoting discipline.

Updated Jul 8, 2026
One-click install
npx skills add https://github.com/NarenKarthikBM/specseyal --skill shell-scripting-narenkarthikbm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-scripting
Source: https://github.com/NarenKarthikBM/specseyal/tree/main/.claude/skills/shell-scripting
Command: npx skills add https://github.com/NarenKarthikBM/specseyal --skill shell-scripting-narenkarthikbm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Shell scripts often fail silently, break on paths with spaces, or assume tools exist that are not installed. This Skill enforces disciplined shell scripting practices so installers, uninstallers, and automation scripts behave predictably across environments. ## Core Features & Use Cases - Strict error handling: Starts scripts with set -euo pipefail or the POSIX-sh equivalent, with deliberate, documented exceptions. - Safe expansion and portability: Quotes every variable expansion and keeps shebang declarations consistent with the shell features actually used. - Defensive I/O and exit codes: Verifies command availability, checks destination paths before writing, and returns meaningful, distinguishable exit codes. - Use Case: When writing an installer script that copies files into a target directory, the Skill ensures the script checks for required tools like jq, confirms the destination exists, and exits with distinct codes for each failure mode. ## Quick Start Write a POSIX-compliant installer script that fails on the first error, quotes all variables, and checks that required commands exist before running.

Frequently Asked Questions about shell-scripting

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

FAQPage Schema
How do I write a shell script that fails on the first error?

Start the script with set -euo pipefail, or the POSIX-sh equivalent discipline, so any failing command, unset variable, or pipeline error stops execution immediately. If a specific command's failure is intentional, document that at the line rather than removing the guard.

How to check if a command exists before using it in bash?

Test for the command's availability explicitly before relying on it, and print a clear message naming the missing tool such as jq or yq. This prevents confusing failures several lines later with unrelated error output.

Why should I quote variable expansions in shell scripts?

An unquoted $var undergoes word splitting and glob expansion, which breaks on paths containing spaces or special characters. Quote every expansion unless there is a specific, commented reason not to.

Can I use bash features in a script with a #!/bin/sh shebang?

No. A #!/bin/sh shebang requires portable POSIX constructs, since the script may run under dash or another minimal shell. If bash-only features are needed, the shebang must explicitly say bash so the two never disagree.

What exit codes should a shell script return?

Return zero on success and nonzero on failure, using distinguishable nonzero codes when a caller might need to tell failure modes apart. Every exit path should carry a meaningful status rather than a generic error.