/devops-skills:bash-script-validatorfrom devops-skills
Validates, lints, and optimizes bash/shell scripts with syntax checks, ShellCheck integration, security vulnerability detection, and performance suggestions.
Ships in devops-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill provides comprehensive validation for bash and shell scripts, checking for syntax errors, best practices, security vulnerabilities, and performance optimizations. It automatically detects whether a script is bash or POSIX sh based on the shebang and applies appropriate validation rules.
Use this skill when:
bash -nsh -neval with variablesrm -rf usageset -e, set -u, set -o pipefail# Validate a script
bash scripts/validate.sh path/to/script.sh
# The validator will:
# 1. Detect shell type from shebang
# 2. Run syntax validation
# 3. Run ShellCheck (if installed)
# 4. Run custom security/optimization checks
# 5. Generate detailed report
========================================
BASH/SHELL SCRIPT VALIDATOR
========================================
File: myscript.sh
Detected Shell: bash
[SYNTAX CHECK]
✓ No syntax errors found (bash -n)
[SHELLCHECK]
myscript.sh:15:5: warning: Quote to prevent word splitting [SC2086]
myscript.sh:23:9: error: Use || exit to handle cd failure [SC2164]
[CUSTOM CHECKS]
⚠ Potential command injection: eval with variable found
Line 42: eval $user_input
ℹ Useless use of cat detected
Line 18: cat file.txt | grep pattern
========================================
VALIDATION SUMMARY
========================================
Errors: 2
Warnings: 3
Info: 1
When validating shell scripts, Claude MUST follow these steps:
Invoke the validator on shell script files:
bash scripts/validate.sh <script-path>
Analyze results to identify issues:
Reference documentation for detailed explanations:
docs/shellcheck-reference.mddocs/common-mistakes.mddocs/bash-reference.mddocs/shell-reference.mdSuggest fixes with code examples:
Explain best practices from the included guides:
User: "Check this bash script for issues"
Claude MUST:
1. Run: bash scripts/validate.sh <script-path>
2. Read the validation output and identify all issues
3. Read docs/common-mistakes.md for fix patterns
4. Read docs/shellcheck-reference.md for SC error explanations (if needed)
5. For EACH issue found:
a. Show the problematic code
b. Explain the issue (referencing documentation)
c. Provide the corrected code
d. Explain why the fix improves the script
After running the validator, Claude should respond with:
## Validation Results
Found X errors, Y warnings, Z info issues.
### Issue 1: Unquoted Variable (Line 25)
**Problem:**
\`\`\`bash
if [ ! -f $file ]; then # Word splitting risk
\`\`\`
**Reference:** See `common-mistakes.md` section "1. Unquoted Variables"
**Fix:**
\`\`\`bash
if [ ! -f "$file" ]; then # Properly quoted
\`\`\`
**Why:** Unquoted variables undergo word splitting and glob expansion,
causing unexpected behavior with filenames containing spaces or special characters.
### Issue 2: ...
Located in examples/ directory:
Use these for reference when learning or teaching shell scripting.
The validator detects shell type from shebang:
#!/bin/bash, #!/usr/bin/env bash → bash#!/bin/sh, #!/usr/bin/sh → POSIX sh#!/bin/zsh → zsh#!/bin/ksh → ksh#!/bin/dash → dashThe validator automatically detects and uses the best available ShellCheck installation:
Option 1: System-wide (Recommended - fastest)
# macOS
brew install shellcheck
# Ubuntu/Debian
apt-get install shellcheck
# Fedora
dnf install shellcheck
Option 2: Automatic via Wrapper (Python required)
# The wrapper automatically installs shellcheck-py in a venv
# Requires: python3 and pip3
./scripts/shellcheck_wrapper.sh --cache script.sh
# Cache location: ~/.cache/bash-script-validator/shellcheck-venv
# Clear cache: ./scripts/shellcheck_wrapper.sh --clear-cache
Option 3: Manual Python install
pip3 install shellcheck-py
The validator works without ShellCheck but provides enhanced validation when it's available. The wrapper provides automatic installation with caching for faster subsequent runs.
# 1. Validate current bash script
bash scripts/validate.sh myscript.sh
# 2. Change shebang to #!/bin/sh
# 3. Re-validate - catches bashisms
bash scripts/validate.sh myscript.sh
# 4. Reference shell-reference.md for POSIX alternatives
# 5. Fix bashisms (arrays → set --, [[ ]] → [ ], etc.)
# 6. Re-validate until clean
The validator automatically checks for:
eval usagerm -rf patternsReference common-mistakes.md for detailed explanations.
Identifies:
Reference tool-specific docs (grep, awk, sed) for better patterns.
#!/bin/bash
for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.sh$'); do
if ! bash .claude/skills/bash-script-validator/scripts/validate.sh "$file"; then
echo "Validation failed for $file"
exit 1
fi
done
# Example for GitHub Actions
- name: Validate Shell Scripts
run: |
find . -name "*.sh" -exec bash .claude/skills/bash-script-validator/scripts/validate.sh {} \;
Use the included documentation to:
bash-reference.mdshell-reference.mdgrep, awk, and sed referencesregex-reference.mdcommon-mistakes.mdshellcheck-reference.mdset -euo pipefail for strict modebash-script-validator/
├── SKILL.md # This file
├── scripts/
│ └── validate.sh # Main validation script
├── docs/
│ ├── bash-reference.md # Bash features and syntax
│ ├── shell-reference.md # POSIX sh reference
│ ├── shellcheck-reference.md # ShellCheck error codes
│ ├── grep-reference.md # grep patterns and usage
│ ├── awk-reference.md # AWK text processing
│ ├── sed-reference.md # sed stream editing
│ ├── regex-reference.md # Regular expressions
│ └── common-mistakes.md # Common pitfalls
└── examples/
├── good-bash.sh # Best practices example
├── bad-bash.sh # Anti-patterns example
├── good-shell.sh # POSIX sh example
└── bad-shell.sh # Bashisms example
The validator performs checks in this order:
bash -n or sh -n)All documentation is included in the docs/ directory for offline reference and context loading.
Note: This skill automatically loads relevant documentation based on the validation results, providing Claude with the necessary context to explain issues and suggest fixes effectively.
docs/awk-reference.md (opens in a new tab)docs/bash-reference.md (opens in a new tab)docs/common-mistakes.md (opens in a new tab)docs/grep-reference.md (opens in a new tab)docs/regex-reference.md (opens in a new tab)docs/sed-reference.md (opens in a new tab)docs/shell-reference.md (opens in a new tab)docs/shellcheck-reference.md (opens in a new tab)examples/bad-bash.sh (opens in a new tab)examples/bad-shell.sh (opens in a new tab)examples/good-bash.sh (opens in a new tab)examples/good-shell.sh (opens in a new tab)scripts/shellcheck_wrapper.sh (opens in a new tab)scripts/validate.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
Generated from the plugin's indexed repository (gitjfmd/ansible-skills) — no native marketplace selected
npx claudepluginhub p/gitjfmd-devops-skills-devops-skills-plugin31 skills in this plugin
/ansible-generatorComprehensive toolkit for generating best practice Ansible playbooks, roles, tasks, and inventory files./ansible-validatorComprehensive toolkit for validating, linting, testing, and automating Ansible playbooks, roles, and collections. Use this skill when working with Ansible files (.yml, .yaml playbooks, roles, inventories), validating automation code, debugging playbook execution, performing dry-run testing with check mode, or working with custom modules and collections./azure-pipelines-generatorComprehensive toolkit for generating best practice Azure DevOps Pipelines following current standards and conventions. Use this skill when creating new Azure Pipelines, implementing CI/CD workflows, or building deployment pipelines./azure-pipelines-validatorComprehensive toolkit for validating, linting, and securing Azure DevOps Pipeline configurations./bash-script-generatorComprehensive toolkit for generating best practice bash scripts following current standards and conventions. Use this skill when creating new bash scripts, implementing shell automation, text processing workflows, or building production-ready command-line tools./dockerfile-generatorComprehensive toolkit for generating production-ready Dockerfiles following current standards and best practices. Use this skill when creating new Dockerfiles, implementing containerization for applications, or optimizing existing Docker builds.