shell-script-validation
Skill1 starsChanged 8 days agoApache-2.0View on GitHub
Validate shell scripts with bash -n and shellcheck for syntax safety and maintainability checks. Does not enforce Bats suite pairing (TEST-00) — companion stem `bats` covers pairing rules. Use when committing script changes, running CI validation, or debugging shellcheck findings in PRs.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .apm/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .github/workflows/CLAUDE.mdCLAUDE.md
- .cursor/rules/agent-skills.mdcCursor rule
- .cursor/rules/bats.mdcCursor rule
- .cursor/rules/github-actions-workflow.mdcCursor rule
- .cursor/rules/go.mdcCursor rule
- .cursor/rules/go-test.mdcCursor rule
- .cursor/rules/instructions.mdcCursor rule
- .cursor/rules/markdown.mdcCursor rule
- .cursor/rules/shell-script.mdcCursor rule
- .cursor/rules/terraform.mdcCursor rule
- agent-skills-reviewSkill
- changelogSkill
- ci-sweeperSkill
- docs-creatorSkill
- docs-updaterSkill
- github-actions-reviewSkill
- github-actions-validationSkill
- github-issue-autofixSkill
- github-issue-triageSkill
- github-pr-bodySkill
- github-pr-reviewSkill
- github-pr-reviseSkill
- go-reviewSkill
- go-validationSkill
- instructions-reviewSkill
- loop-verifierSkill
- markdown-validationSkill
- refactorSkill
- shell-script-reviewSkill
- shell-script-validationSkill
- tech-debtSkill
- test-gapSkill
- agent-skills-reviewSkill
- changelogSkill
- ci-sweeperSkill
- docs-creatorSkill
- docs-updaterSkill
- github-actions-reviewSkill
- github-actions-validationSkill
- github-issue-autofixSkill
- github-issue-triageSkill
- github-pr-bodySkill
- github-pr-reviewSkill
- github-pr-reviseSkill
- go-reviewSkill
- go-validationSkill
- instructions-reviewSkill
- loop-verifierSkill
- markdown-validationSkill
- refactorSkill
- shell-script-reviewSkill
- tech-debtSkill
- test-gapSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 40
run shell script syntax and lint validation before merge
- Very specific: line 62
Run bash scripts/validate.sh -v -f --check-function-docs <absolute target path> (file or directory under review).
- Distinctive: line 64
If checks fail, fix reported issues and rerun the same command.
≈ “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
Input
- Shell script path or directory (recommended): pass explicit target paths. Without a target, the script searches from a root it computes relative to its own install location (three levels above
scripts/); in an installed skill copy that is the agent root directory (for example.claude/), not the repository root. Relative target and--testspaths resolve against that same root, so pass absolute paths - Validation script (required):
scripts/validate.sh - Default flags:
-v -f --check-function-docs -f(default on): rewrites script formatting withshfmtin place and, with--check-function-docs, reorders function doc sections withscripts/fix_function_doc_order.shwhen it is present — review the diff before continuing--check-function-docs(default on in this skill; off in the script unless passed): omit only when targets intentionally skip Google function header sections and function order checks--tests PATH(optional, repeatable): limit the Bats suites the script runs to PATH (directory or.batsfile); pass an absolute path--skip-tests(optional): skip Bats execution; use when the repository has no Bats suites orbatsis not installed
Output Specification
Return structured Markdown in accordance with references/common-output-format.md. That file is the source of truth for the output contract.
Structured results for bash -n and shellcheck (syntax and lint), plus Bats suite results unless --skip-tests is passed. With --check-function-docs, also reports Google Shell Style Guide function header sections and top-level function order (show_usage, parse_arguments, a-z, main; detection only).
Execution Scope
- Always use
scripts/validate.shfor comprehensive validation. Do not run individual commands. - Script runs checks in fixed order.
- Individual commands are for debugging only (see references/common-individual-commands.md).
- The script continues after a failing check (no fail-fast) and reports every script.
- Bats: Unless
--skip-testsis passed, the script also discovers and runs Bats suites (every.batsfile under its computed root — see Input — or only those under--tests PATH) and requiresbatsorbats-core. By default only failing tests and the summary line are printed; use-vfor the full pass/fail listing. - File changes:
-frewrites files in place (shfmtformatting, plus function doc section order with--check-function-docs). Do not modify files otherwise.
USE FOR:
- run shell script syntax and lint validation before merge
- reproduce CI failures for shell scripts
- validate a specific script path during iterative fixes
- normalize function doc section order when this skill ships
scripts/fix_function_doc_order.sh
DO NOT USE FOR:
- perform architecture/design review of shell scripts
- modify business logic in scripts as a primary task
- validate non-shell files
- enforce Bats suite pairing or suite layout (companion stem
batscovers pairing rules)
Reference Files Guide
- common-checklist.md (always read)
- common-output-format.md (always read)
- common-troubleshooting.md (read on failure)
- common-individual-commands.md (read on failure)
- category-standards.md (read on failure)
Workflow
- Run
bash scripts/validate.sh -v -f --check-function-docs <absolute target path>(file or directory under review). Add--tests <absolute path>to scope Bats to the suites paired with the target, or--skip-testswhen the repository has no Bats suites. - Review auto-fix diffs from
-f(formatting and function doc section order) before continuing. - If checks fail, fix reported issues and rerun the same command.
- Retry at most 2 times after fixes; if checks still fail, return blocking findings and stop.
Error Handling
| Condition | Severity | Action |
scripts/validate.sh missing | Fatal | Stop; report missing script |
| No shell scripts under target path | Info | Report no reviewable scripts; stop |
Required binary missing (shellcheck, shfmt, or bats/bats-core when Bats runs) | Fatal | Stop; report the missing binary; set Status: ❌ FAIL |
| Single tool fails, others succeed | Recoverable | Report every tool; mark the failed tool ❌ Fail with exit status |
| All tools fail | Fatal | Set Status: ❌ FAIL with per-tool stderr summaries in ## Error Details |
| Function docs intentionally skipped | Info | Omit --check-function-docs; document opt-out in Summary |
common-checklist.md unavailable | Fatal | Stop; report missing dependency |
common-output-format.md unavailable | Recoverable | Note missing file; emit ## Summary, ## Tool Results, and ## Error Details only |
Examples
- Prompt:
Validate shell scripts (syntax, shellcheck, optional function docs) - Command:
bash scripts/validate.sh -v -f --check-function-docs - Result: Structured report per references/common-output-format.md. Additional invocations: common-individual-commands.md (read on debugging).
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.

