Skip to content
Skills Library
Programming · Building & coding

shell-scripting-guide

/shell-scripting-guide

Use when writing or editing POSIX shell or Bash automation. Triggers on `.sh` files, `#!/usr/bin/env bash` shebangs, and prompts about scripting CI tasks, build helpers, devops automation, or one-off pipelines, even when the user doesn't say 'shell'. Apply for strict mode, quoting, parameter expansion, exit codes, idempotency, shellcheck/shfmt.

Repository
platform ↗
Licence
MIT
Last repository change
08.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
16
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when writing or editing POSIX shell or Bash automation. Triggers on `.sh` files, `#!/usr/bin/env bash` shebangs, and prompts about scripting CI tasks, build helpers, devops automation, or one-off pipelines, even when the user doesn't say 'shell'. Apply for strict mode, quoting, parameter expansion, exit codes, idempotency, shellcheck/shfmt.

Triggers from the description

t say
Original author description

Use when writing or editing POSIX shell or Bash automation. Triggers on `.sh` files, `#!/usr/bin/env bash` shebangs, and prompts about scripting CI tasks, build helpers, devops automation, or one-off pipelines, even when the user doesn't say 'shell'. Apply for strict mode, quoting, parameter expansion, exit codes, idempotency, shellcheck/shfmt.

How it works

  1. Essentials
  2. Gotchas
  3. Progressive disclosure
Original SKILL.md headings · 34 lines, 274 words
SKILL.md preview
---
name: shell-scripting-guide
description: "Use when writing or editing POSIX shell or Bash automation. Triggers on `.sh` files, `#!/usr/bin/env bash` shebangs, and prompts about scripting CI tasks, build helpers, devops automation, or one-off pipelines, even when the user doesn't say 'shell'. Apply for strict mode, quoting, parameter expansion, exit codes, idempotency, shellcheck/shfmt."
---

# Shell Scripting Coding Guidelines

Write portable shell scripts with quoted arguments, explicit failure handling, and ShellCheck and shfmt validation.

## Essentials

- **POSIX compatibility** - Use POSIX sh, lint with shellcheck, format with shfmt, see [references/posix-compatibility.md](references/posix-compatibility.md)
- **Strict mode** - Use strict mode and safe defaults, see [references/strict-mode.md](references/strict-mode.md)
- **Quoting** - Quote all expansions to avoid word splitting, see [references/quoting.md](references/quoting.md)
- **Functions** - Write small, focused functions, see [references/functions.md](references/functions.md)
- **Parameter expansion** - Set default values and manipulate variables, see [references/parameter-expansion.md](references/parameter-expansion.md)
- **Error handling** - Implement exit codes and error messages, see [references/error-handling.md](references/error-handling.md)
- **Idempotency** - Make scripts safely re-runnable, see [references/idempotency.md](references/idempotency.md)

## Gotchas

- Unquoted variables word-split and glob-expand: `cp $file dest/` silently breaks on filenames with spaces; quote everything
- `set -e` doesn't catch errors inside `if`, `&&`, `||`, or pipelines without `-o pipefail`: combine `set -euo pipefail` at the top

## Progressive disclosure

- Read [references/posix-compatibility.md](references/posix-compatibility.md) - Load when ensuring portability across shells
- Read [references/strict-mode.md](references/strict-mode.md) - Load when setting up error handling and safety flags
- Read [references/quoting.md](references/quoting.md) - Load when variables expand incorrectly or word splitting occurs
- Read [references/functions.md](references/functions.md) - Load when organizing script logic or creating reusable code
- Read [references/parameter-expansion.md](references/parameter-expansion.md) - Load when setting default values or manipulating variables
- Read [references/error-handling.md](references/error-handling.md) - Load when implementing exit codes or error messages
- Read [references/argument-parsing.md](references/argument-parsing.md) - Load when parsing command-line flags or arguments
- Read [references/validation.md](references/validation.md) - Load when checking preconditions or input validity
- Read [references/idempotency.md](references/idempotency.md) - Load when scripts should be safely re-runnable
- Read [references/common-patterns.md](references/common-patterns.md) - Load when learning common shell idioms
- Read [references/script-template.md](references/script-template.md) - Load when starting a new shell script
Files in this package (16)
  • SKILL.md 3 KB
  • SOURCES.md 1 KB
  • eval-queries.json 5 KB
  • evals.json 3 KB
  • moon.yml 1 KB
  • references/argument-parsing.md 1 KB
  • references/common-patterns.md 1 KB
  • references/error-handling.md 1 KB
  • references/functions.md 1 KB
  • references/idempotency.md 1 KB
  • references/parameter-expansion.md 1 KB
  • references/posix-compatibility.md 1 KB
  • references/quoting.md 1 KB
  • references/script-template.md 1 KB
  • references/strict-mode.md 1 KB
  • references/validation.md 1 KB

Versions

The database has no other skills named shell-scripting-guide.

Database snapshot: 13.11.2026 · package version 638c2bcebc24 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100bash-scripting
    Expert guidance for writing, hardening, debugging, and reviewing Bash and POSIX shell scripts. Use whenever the user writes, edits, refactors, or pastes a .sh / .bash file or shell snippet; asks for a script, automation, wrapper, installer, backup, deploy, cron, CI/CD, or…
  • 90shell-scripts
    Use when writing or reviewing Bash scripts and shell snippets, especially for shebang selection, quoting, parameter expansion ("${VAR}" style), test expressions (`[ ]` vs `[[ ]]`), ShellCheck-guided fixes, and portability decisions across POSIX sh, Bash, and zsh compatibility targets.
  • 100bash-scripting
    Use when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks, quoting/word-splitting, arrays, trap cleanup, bash-vs-POSIX portability, ShellCheck findings. NOT CI…
  • 100bash-ops
    Defensive Bash scripting for production automation, CI scripts, and agent-facing tools. Triggers on: bash, shell script, defensive bash, bash strict mode, set -euo pipefail, set -Eeuo pipefail, shellcheck, trap, IFS, cleanup trap, mktemp, getopts, argument parsing, exit codes,…
  • 100shell-guide
    Shell/Bash scripting guardrails, patterns, and best practices for AI-assisted development. Use when working with shell scripts (.sh, .bash), Makefiles, or when the user mentions Bash/Shell. Provides POSIX compliance guidelines, error handling patterns, and ShellCheck rules…
  • 100shell-scripting
    Bash, Zsh, POSIX sh, Fish scripts, one-liners, dotfiles, completions. Use for quoting or globbing bugs, shellcheck warnings, porting between shells.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.