Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Bash Script Validator

ASecurity

Validate, lint, audit, or fix bash/shell/.sh scripts via ShellCheck.

6 stars
0 votes
0 copies
0 views
Added 10/5/2026
ai-agentspythongoc#shellbashkubernetesterraformdevopssecuritydocumentation

Security Analysis

A100/100

Pro scans all 17 files and shows the line behind each finding

Scanned 10/5/2026

$npx -y skills add hybridlabor-api/aos --skill bash-script-validator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bash Script Validator?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Bash Script Validator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hybridlabor-api-bash-script-validator/badge)](https://www.skillsdirectory.com/skills/hybridlabor-api-bash-script-validator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: bash-script-validator
description: Validate, lint, audit, or fix bash/shell/.sh scripts via ShellCheck.
category: engineering-method
source: cc-devops-skills
date_added: "2026-09-25"
---

# Bash Script Validator

## Overview

This skill validates Bash and POSIX shell scripts with layered checks:

1. Syntax validation (`bash -n` or `sh -n`)
2. ShellCheck static analysis (system binary or wrapper fallback)
3. Custom security, portability, and optimization checks

Use the default flow below, then branch to fallbacks only when the environment is constrained.

## Trigger Guidance

Use this skill when the request includes script quality, linting, syntax checking, or shell portability work.

### Trigger Phrases

- "Validate this bash script"
- "Lint this `.sh` file"
- "Find security issues in this shell script"
- "Why does this script fail ShellCheck?"
- "Make this script POSIX compliant"
- "Review this shell script before CI"

### Non-Trigger Examples

- General Linux command questions with no script file
- Kubernetes, Terraform, or pipeline validation tasks that do not involve shell scripts
- Pure prose editing tasks

## Deterministic Execution Model

Run commands from this skill directory:

```bash
cd devops-skills-plugin/skills/bash-script-validator
```

### Step 1: Preflight

1. Confirm target path exists and is readable.
2. Confirm `bash` is available.
3. Determine whether fixes can be applied directly (write access) or only suggested (read-only).

### Step 2: Run Baseline Validation (Default Path)

```bash
bash scripts/validate.sh <script-path>
```

For deterministic stage behavior, set the ShellCheck provider explicitly:

```bash
# Modes: auto (default), system, wrapper, disabled
VALIDATOR_SHELLCHECK_MODE=system bash scripts/validate.sh <script-path>
```

Record:

- Detected shell type
- Exit code (`0` clean, `1` warnings, `2` errors)
- All reported issue lines and ShellCheck codes (`SC####`) when present

### Step 3: Load Only Needed References

Progressive disclosure by issue type:

- ShellCheck code explanations: `docs/shellcheck-reference.md`
- General fix patterns and security mistakes: `docs/common-mistakes.md`
- Bash-only behavior: `docs/bash-reference.md`
- POSIX portability or bashism fixes: `docs/shell-reference.md`
- Text-processing optimization issues: `docs/grep-reference.md`, `docs/awk-reference.md`, `docs/sed-reference.md`, `docs/regex-reference.md` (only when directly relevant)

### Step 4: Provide or Apply Fixes

For each issue, include:

1. Exact location from validator output (line number and snippet)
2. Root cause
3. Corrected code
4. Why the change is safer or more portable
5. Subsection-level citation (format below)

If the request includes patching files and write access is available, apply fixes in small batches grouped by issue type.

### Step 5: Rerun Policy (Mandatory After Changes)

After each batch of edits, rerun the validator:

```bash
bash scripts/validate.sh <script-path>
```

Rerun loop rules:

1. Continue until no new errors are introduced.
2. If warnings remain by design, document why they are intentionally accepted.
3. If constraints prevent full resolution, report unresolved items with a clear next action.
4. Always report the latest rerun exit code and remaining issue count.

## Fallback Behavior

Use these branches only when the default flow cannot run as-is.

| Constraint | Fallback action | Reporting requirement |
| --- | --- | --- |
| `shellcheck` missing, wrapper available | Let `scripts/validate.sh` use `scripts/shellcheck_wrapper.sh --cache` automatically | State that wrapper mode was used |
| `shellcheck` and wrapper unavailable | Run syntax + custom checks only (validator does this) | Explicitly call out reduced coverage and missing ShellCheck analysis |
| Python unavailable for wrapper | Skip wrapper path, keep syntax + custom checks | State why ShellCheck could not run |
| Target file is read-only | Provide precise patch suggestions without editing | Mark response as "advisory only" |
| Target file missing or unreadable | Stop and request a valid file path | Do not fabricate results |
| Binary/non-text input | Stop validation | Report unsupported input type |

## Citation Guidance for Fixes

Use subsection-level citations for every non-trivial fix.

Required citation format:

```text
Reference: docs/<file>.md -> <Section> -> <Subsection>
```

Examples:

- `Reference: docs/common-mistakes.md -> 1. Unquoted Variables -> Solution`
- `Reference: docs/shellcheck-reference.md -> SC2164: Use || exit After cd`
- `Reference: docs/shell-reference.md -> POSIX Best Practices -> 5. Avoid Bashisms`

Citation rules:

1. Cite the most specific section that justifies the fix.
2. For ShellCheck findings, include both the `SC####` code and the matching section.
3. If no exact subsection exists, cite the closest section and state that the fix is inferred from that guidance.

## Response Template

Use this structure for deterministic output:

- `Validation Results`
- `Command`: `bash scripts/validate.sh <script-path>`
- `Detected shell`: `<shell>`
- `Exit code`: `<code>`
- `Summary`: `<errors> errors, <warnings> warnings, <info> info`
- `Issue`: `<short label> (Line <n>)`
- `Problem`:
  ```bash
  <problematic snippet>
  ```
- `Fix`:
  ```bash
  <corrected snippet>
  ```
- `Why`: `<short explanation>`
- `Reference`: `docs/<file>.md -> <Section> -> <Subsection>`
- `Rerun command`: `bash scripts/validate.sh <script-path>`
- `Exit code after fixes`: `<code>`
- `Remaining issues`: `<count or none>`

## Example Flows

### Fully Automated Environment

```bash
# 1) Baseline validation
bash scripts/validate.sh examples/bad-bash.sh

# 2) Apply fixes to target script
# 3) Rerun validation
bash scripts/validate.sh examples/bad-bash.sh
```

Expected behavior: full syntax + ShellCheck + custom-check coverage, with iterative reruns until stable.

### Deterministic CI Gate

```bash
# Requires a system shellcheck binary.
bash scripts/run_ci_checks.sh
```

This runner enforces `VALIDATOR_REQUIRE_SHELLCHECK=1` and `VALIDATOR_SHELLCHECK_MODE=system`
so CI fails if the ShellCheck stage is skipped or unavailable.

### Constrained Environment (No ShellCheck Runtime)

```bash
# shellcheck unavailable and wrapper cannot run
bash scripts/validate.sh examples/bad-shell.sh
```

Expected behavior: syntax + custom checks still run. Report reduced coverage and list what must be revalidated once ShellCheck is available.

## Validator Script Details

### Scripts

- `scripts/validate.sh`: primary validator entrypoint
- `scripts/shellcheck_wrapper.sh`: optional ShellCheck fallback using a cached Python virtual environment

### Detection and Ordering

Validation order in `scripts/validate.sh`:

1. File checks (exists/readable/text)
2. Shebang-based shell detection
3. Syntax check
4. ShellCheck (or fallback/skip behavior)
5. Custom checks
6. Summary with exit code

### Exit Codes

- `0`: no issues found
- `1`: warnings found
- `2`: errors found

## References

Load only what is needed:

- `docs/bash-reference.md`
- `docs/shell-reference.md`
- `docs/shellcheck-reference.md`
- `docs/common-mistakes.md`
- `docs/grep-reference.md`
- `docs/awk-reference.md`
- `docs/sed-reference.md`
- `docs/regex-reference.md`

## Done Criteria

This skill update is complete when all are true:

1. Trigger guidance is explicit (positive and non-trigger examples).
2. Default workflow is deterministic and ordered.
3. Fallback behavior is explicit for missing tooling and constrained environments.
4. Fix explanations include subsection-level citations.
5. Post-fix rerun policy is mandatory and reported with exit codes.
6. Documentation supports both fully automated and constrained execution paths.

Attribution

hybridlabor-apihybridlabor-api
View sourceSee grades on GitHubMore from hybridlabor-api →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698431 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →