bash-scripting
Skill0 starsChanged 8 months agoMITView on GitHub
Use when creating, modifying, or refactoring Bash shell scripts that require production-quality standards including function-based architecture, strict error handling, getopts argument parsing, signal trapping, and CLI-first design.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- himadajin/skillstheir own version, first seen Oct 11, 2026
- Mindrally/skillstheir own version, first seen Oct 8, 2026
- ebal/AI-Skillstheir own version, first seen Jul 15, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- Mindrally/skills★ 275same name
- himadajin/skills★ 1same name
- ebal/AI-Skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adr-generationSkill
- browser-controlSkill
- github-actionsSkill
- gitignore-standardsSkill
- git-operationsSkill
- html-reportSkill
- java-developmentSkill
- mermaid-diagramsSkill
- meta-workspaceSkill
- powershell-scriptingSkill
- project-backlogSkill
- project-documentationSkill
- project-setupSkill
- python-developmentSkill
- refinement-tribunalSkill
- skill-cli-developmentSkill
- technical-writingSkill
- testing-standardsSkill
- typescript-developmentSkill
- web-auth-bridgeSkill
- worktree-isolationSkill
- writing-ai-instructionsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 9 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 51
No library or source usage assumed
- Distinctive: line 100
Default to FullScript when ambiguous
- Very specific: line 105
Write errors, warnings, and all diagnostic/status output (including log_info) to stderr.
- Distinctive: line 110
Write diagnostic, logging, or status output to stdout outside of the primary program output
- Very specific: line 116
Use #!/usr/bin/env bash as the shebang
- Very specific: line 125
Use named readonly exit code constants prefixed with E_ (e.g., E_USAGE=2)
- Very specific: line 131
Put business logic at top level.
- Very specific: line 132
Call exit without an explicit numeric code or named exit code constant
- Very specific: line 133
Use string booleans (e.g., TRUE/FALSE string variables) in place of integer flags (0/1) or function return codes
- Distinctive: line 137
Prefer 1–5 lines, maximum 10 lines
- Distinctive: line 139
Use pipeline-friendly idioms and standard Unix tools
- Distinctive: line 143
Create a FullScript scaffold
- Distinctive: line 144
Add long-form comments or headers
- Very specific: line 159
All constants declared with readonly.
- Distinctive: line 164
No business logic or procedural code at the top level
- Distinctive: line 170
No scaffolding, function definitions, or header comments unless essential
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bash Shell Script Development
Objective
Produce Bash scripts in two modes: full scripts for persisted CLI tools and one-offs for ad-hoc execution. Full scripts must be function-first, strictly error-handled, signal-aware, and documented; one-offs must be short and runnable inline.
Scope
In-scope:
- New Bash scripts and refactors
- One-offs and terminal snippets
- Function-based design, guard clauses, fail-fast error handling
- Argument parsing with
getopts - Usage documentation
- Signal trapping and cleanup
- Exit code conventions
Out-of-scope:
- Shell libraries or sourced function files
- Non-Bash shells (sh, zsh, fish)
- System init scripts or daemon wrappers
- Makefile recipes
- CI/CD pipeline scripts (GitHub Actions, Jenkins, etc.)
Inputs
Required inputs:
- Purpose and functional requirements
- Target output form: FullScript or OneOff
- New development or refactor
Optional inputs:
- Mode selection override
- Existing patterns to mirror
- Domain context (file I/O, system administration, build automation)
- Required options and positional arguments
Assumptions:
- Bash 4.0+ available on
PATH(Linux: typically default; macOS: requires a newer Bash than the system/bin/bash3.2, e.g., via Homebrew) - Script is invoked directly as a CLI tool (not sourced)
- No library or source usage assumed
Outputs
Format:
- FullScript: executable script file (no extension)
- OneOff: snippet (1–5 lines preferred, max 10 lines)
FullScript Structure:
- Shebang:
#!/usr/bin/env bash - Header comment (description, usage summary, changelog)
- Strict mode:
set -euo pipefail - Constants (
readonly) - Script state variables (mutable globals, initialized to defaults)
- Utility functions (
die,log_info,log_warn,log_error) usagefunction- Cleanup and signal handler functions
- Business logic functions
parse_argsfunction (defined last among helpers)mainfunction (defined last)- Trap registrations (
EXIT,INT,TERM) main "$@"invocation
Files produced:
- FullScript: single executable script file named in lowercase-hyphenated form
- OneOff: no file unless requested
Formatting requirements (FullScript):
- Indent with tabs
- UPPER_SNAKE_CASE for constants; lowercase snake_case for functions and variables
readonlyfor all constantslocalfor all variables declared inside functions- ANSI-compliant syntax preferred when equivalent in readability and safety to Bash-specific syntax
- Max 3 levels of nesting; extract deeper logic into named functions
- One blank line between function definitions, except for grouped one-line helpers (e.g.,
log_info/log_warn/log_error) which may appear consecutively - Section dividers (
# ---------------------------------------------------------------------------) separating each logical group
Constraints
Conflict resolution: User requirements override defaults unless they violate safety or explicit MUST rules.
Mode selection rules:
- OneOff: user asks for a one-liner, quick command, ad-hoc check, or terminal snippet
- FullScript: user asks for a script file, reusable CLI tool, or multi-step workflow
- Default to FullScript when ambiguous
Global MUST:
- Choose FullScript or OneOff and follow the mode rules
- Write errors, warnings, and all diagnostic/status output (including
log_info) to stderr; write primary program output to stdout - Validate all required inputs before executing logic
Global MUST NOT:
- Write diagnostic, logging, or status output to stdout outside of the primary program output
- Use undefined variables
- Ignore non-zero exit codes without an explicit comment or log explaining that the failure is non-critical
FullScript MUST:
- Use
#!/usr/bin/env bashas the shebang - Enable
set -euo pipefailimmediately after the header comment - Declare all constants with
readonly - Declare all in-function variables with
local - Define a
diefunction for fatal errors that prints to stderr and exits with a code - Define a
usagefunction that writes to stdout - Define a
parse_argsfunction usinggetoptsthat handles:(missing arg) and\?(unknown option) cases - Define
mainas the final function and invoke it withmain "$@" - Register traps for
EXIT(cleanup),INT(exit 130), andTERM(exit 143) - Use named
readonlyexit code constants prefixed withE_(e.g.,E_USAGE=2) - Include a header comment with at minimum: a description, a usage summary, and a changelog
FullScript MUST NOT:
- Hard-code paths or configurable values (use constants or arguments)
- Put business logic at top level; only constants/state declarations, strict mode (
set -euo pipefail), trap registrations, and the finalmain "$@"invocation belong at top level - Call
exitwithout an explicit numeric code or named exit code constant - Use string booleans (e.g.,
TRUE/FALSEstring variables) in place of integer flags (0/1) or function return codes
OneOff MUST:
- Prefer 1–5 lines, maximum 10 lines
- Skip function definitions, header comments, and
setpreamble unless essential - Use pipeline-friendly idioms and standard Unix tools
OneOff MUST NOT:
- Create a FullScript scaffold
- Add long-form comments or headers
Procedure
- Select mode using the mode rules.
- FullScript: write the header comment, then lay out strict mode, constants, script state, utilities, usage, signal handlers, business logic,
parse_args,main, traps, and invocation in that order. - OneOff: build the minimal expression and keep length within limits.
- Apply guard clauses, error handling, signal trapping, and naming conventions.
Validation
Pass Conditions (FullScript):
- Structure matches the FullScript Structure list
set -euo pipefailpresent immediately after the header- All constants declared with
readonly; all in-function variables declared withlocal die,usage,parse_args, andmainare all definedtrapcoversEXIT,INT, andTERM; handler functions are definedparse_argsusesgetoptsand handles both:and\?casesmain "$@"is the only top-level invocation- No business logic or procedural code at the top level
- Exit calls use named
E_-prefixed constants
Pass Conditions (OneOff):
- 1–5 lines when possible, never more than 10 lines
- No scaffolding, function definitions, or header comments unless essential
Failure Modes:
- FullScript missing
set -euo pipefail,trap,parse_args, ormain - Business logic or procedural code at top level
exitcalled without an explicit code- String booleans used instead of integer flags
- OneOff exceeds 10 lines without justification
Examples
OneOff:
# Preview files older than 7 days:
find . -type f -name "*.log" -mtime +7 -print
# After reviewing the list, uncomment the next line to delete:
# find . -type f -name "*.log" -mtime +7 -exec rm -f {} +FullScript (structure overview):
#!/usr/bin/env bash
#
# Processes files in a given directory.
#
# Usage: process-files [-v] [-n <limit>] <dir>
# process-files -h
#
# Changelog:
# - 2025-01-01: Initial version.
set -euo pipefail
readonly E_GENERAL=1
readonly E_USAGE=2
readonly E_INTERRUPT=130
readonly E_TERMINATED=143
readonly SCRIPT_NAME="$(basename "$0")"
readonly DEFAULT_LIMIT=10
verbose=0
limit="${DEFAULT_LIMIT}"
input_dir=""
die() { echo "${SCRIPT_NAME}: error: $1" >&2; exit "${2:-${E_GENERAL}}"; }
log_info() { echo "${SCRIPT_NAME}: $*" >&2; }
log_warn() { echo "${SCRIPT_NAME}: warning: $*" >&2; }
log_error() { echo "${SCRIPT_NAME}: error: $*" >&2; }
usage() { cat <<EOF
Usage: ${SCRIPT_NAME} [-v] [-n <limit>] <dir>
...
EOF
}
cleanup() { :; }
_on_exit() { local c=$?; cleanup || true; exit "${c}"; }
_on_interrupt() { echo "${SCRIPT_NAME}: interrupted." >&2; exit "${E_INTERRUPT}"; }
_on_terminate() { echo "${SCRIPT_NAME}: terminated." >&2; exit "${E_TERMINATED}"; }
process_files() { local dir="$1"; ...; }
parse_args() { ...; }
main() { parse_args "$@"; process_files "${input_dir}"; }
trap _on_exit EXIT
trap _on_interrupt INT
trap _on_terminate TERM
main "$@"Persona
Persona: Production-quality Bash engineer
You are a Bash engineer with deep production experience building reliable CLI tools. You prioritize strict error handling, explicit validation, and function-based organization. You choose clarity and maintainability over clever one-liners in full scripts, and you keep signal handling and exit codes consistent and correct.
References
- Modes and selection guide: references/modes.md
- Templates: references/templates.md
- Standards and patterns: references/standards.md
- Examples: references/examples.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

