shell-guidelines
Skill3 starsChanged 8 days agoMITView on GitHub
Apply Shell policy to persisted scripts, CI or automation, constrained POSIX or BusyBox targets, non-trivial command fragments, and quoting, interpreter, portability, or safety reviews. Use as a conditional language overlay; routine single-layer shell commands do not require activation, and this skill never owns the lifecycle.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- analyze-projectSkill
- api-contract-strategySkill
- architecture-patternsSkill
- close-changeSkill
- design-changeSkill
- development-standardsSkill
- docker-multiarch-buildSkill
- error-patternsSkill
- go-guidelinesSkill
- herdr-implementSkill
- implement-changeSkill
- logging-standardsSkill
- lua-guidelinesSkill
- organize-docsSkill
- output-stylesSkill
- plan-changeSkill
- powershell-guidelinesSkill
- python-guidelinesSkill
- review-changeSkill
- review-designSkill
- review-implementationSkill
- review-planSkill
- routeros-scripting-guidelinesSkill
- runtime-diagnosisSkill
- security-guardrailsSkill
- skill-authoringSkill
- skill-minerSkill
- skills-routingSkill
- smart-commitSkill
- sops-age-guardrailsSkill
- sync-truthSkill
- testing-strategySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 5 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Read-only review checks: references/review-checklist.md
- Very specific: line 20
Use #!/bin/sh and the ash/POSIX subset for BusyBox ash or a target contract fixed to POSIX sh.
- Very specific: line 21
Use #!/usr/bin/env bash for CI and Linux bash, and #!/usr/bin/env zsh for zsh scripts.
- Very specific: line 26
Start Bash and zsh entrypoints with set -euo pipefail, and POSIX sh entrypoints with set -eu (pipefail is not portable).
- Very specific: line 28
Check the exit status of every external command, through set -e or an explicit test.
- Distinctive: line 35
Treat user input as data: expand it quoted and pass it as arguments to a fixed command.
- Very specific: line 37
Use descriptive variable names such as file_path or exit_status in place of path, status, pipestatus, argv, commands, functions, options …
- Distinctive: line 42
Keep scripts small and linear, with functions above the main flow, early returns, and each external mutation visible.
- Distinctive: line 43
Use an existing structured-data tool or a short embedded standard-library Python fragment when Shell parsing would be fragile.
- Distinctive: line 44
Keep each reusable business rule in one implementation, in the language that owns it.
- Distinctive: line 45
Keep an existing working Shell implementation, a simple script, a parent-shell effect, or a constrained native runtime in Shell.
- Very specific: line 49
Create temporary files with mktemp or another native mechanism that respects TMPDIR, and clean only task-owned paths.
- Very specific: line 54
Run shellcheck for bash and sh where available, and the interpreter's syntax check (bash -n, sh -n, zsh -n):
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Shell Guidelines
Apply these rules to persisted or correctness-sensitive Shell: scripts (.sh, bash, zsh), CI and local automation, fragments whose quoting, expansion, interpreter, pipeline or failure behavior affects correctness, Shell for a constrained native runtime such as OpenWrt BusyBox ash or a target fixed to POSIX sh, Shell that must affect the invoking shell (sourced environments, profiles, launchers), and review or syntax audit of shell files. Ad hoc tool choice and command composition read references/tool-selection.md in skills-routing; language selection reads references/language-selection.md there.
Progressive Disclosure
- Script structure, diagnostics and error-handling examples (the
ERRtrap, input validation):references/script-patterns.md - A script targeting macOS or Homebrew
PATH, needing Bash 4+, or an option behaving unexpectedly:references/macos-homebrew.md - Read-only review checks:
references/review-checklist.md
Rules
Interpreter
- Use
#!/bin/shand the ash/POSIX subset for BusyBox ash or a target contract fixed to POSIXsh; that constrained runtime keeps its native shell. An incidental minimal base image does not establish the constraint. In POSIXsh, use[ ]and avoid[[ ]]and arrays. - Use
#!/usr/bin/env bashfor CI and Linux bash, and#!/usr/bin/env zshfor zsh scripts. Keep zsh-only features in zsh scripts. - Require Bash 4+ explicitly (shebang or runtime) or provide a compatibility fallback when a script uses
mapfile/readarrayor associative arrays; macOS/bin/bashis 3.2.
Strict Mode And Failure
- Start Bash and zsh entrypoints with
set -euo pipefail, and POSIXshentrypoints withset -eu(pipefailis not portable). - Give a Bash entrypoint with an
ERRtrapset -Eeuo pipefailand a minimal trap such astrap 'echo "Error on line $LINENO" >&2' ERR. In POSIXsh, check each command's status explicitly; theERRtrap is Bash and zsh only. - Check the exit status of every external command, through
set -eor an explicit test. - Under
set -e, increment counters with((i+=1))or((++i));((i++))returns status 1 when the counter is 0.
Inputs And Quoting
- Quote every variable expansion unless splitting or globbing is intended and documented.
- Validate the launcher's own inputs (argument presence and shape, environment variables it dereferences, paths it resolves) and reject unexpected values early. Domain parsing and state validation belong to the implementation the launcher starts.
- Treat user input as data: expand it quoted and pass it as arguments to a fixed command.
- Supply secrets and credentials through the environment or the project's secret mechanism.
- Use descriptive variable names such as
file_pathorexit_statusin place ofpath,status,pipestatus,argv,commands,functions,optionsandparametersin any shell. - Name script files in kebab-case:
my-script.sh.
Structure
- Keep scripts small and linear, with functions above the main flow, early returns, and each external mutation visible.
- Use an existing structured-data tool or a short embedded standard-library Python fragment when Shell parsing would be fragile; pass data through arguments, stdin or files rather than interpolating it into source. A named script is a readability choice, not a language change.
- Keep each reusable business rule in one implementation, in the language that owns it. A Shell entrypoint may locate and start a co-delivered implementation, and its normal delivery and update workflow stays intact.
- Keep an existing working Shell implementation, a simple script, a parent-shell effect, or a constrained native runtime in Shell. When parsing, state, recovery, concurrency or distribution cost makes it unreliable, read
references/language-selection.mdinskills-routingbefore proposing a rewrite.
Temporary Files And Scope
- Create temporary files with
mktempor another native mechanism that respectsTMPDIR, and clean only task-owned paths. Environment scope and temporary storage followdevelopment-standards. - Resolve script-owned resources from the script location or an explicit owning root, and keep them distinct from a CLI's intentionally caller-selected working directory.
Checks
Run shellcheck for bash and sh where available, and the interpreter's syntax check (bash -n, sh -n, zsh -n):
bash -n path/to/script.sh
shellcheck path/to/script.shFor generic error-handling patterns (resilience, resource management, monitoring), see error-patterns.
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.

