Shell script validation

From y-miyazaki/terraform-aws-base · View interactive version

Shell script validation is an AI agent skill from the GitHub repository y-miyazaki/terraform-aws-base. 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.

How to use this skill

Skill file

Input

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

USE FOR:

DO NOT USE FOR:

Reference Files Guide

Workflow

  1. 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-tests when the repository has no Bats suites.
  2. Review auto-fix diffs from -f (formatting and function doc section order) before continuing.
  3. If checks fail, fix reported issues and rerun the same command.
  4. 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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.