Lint and test shell scripts using ShellCheck and BATS. Use when checking bash/sh scripts for errors, writing shell script tests, fixing ShellCheck warnings, setting up CI/CD for shell scripts, or improving bash code quality.
A Claude Code skill for linting and testing shell scripts using ShellCheck and BATS with 2025 best practices.
This skill helps you:
See SKILL.md for the complete skill implementation with:
# Install ShellCheck
brew install shellcheck # macOS
sudo apt-get install shellcheck # Linux
# Lint your script
shellcheck scripts/example.sh
# Install BATS
brew install bats-core # macOS
sudo apt-get install bats # Linux
# Create test file
cat > tests/example.bats <<'EOF'
#!/usr/bin/env bats
@test "script runs successfully" {
run bash scripts/example.sh
[ "$status" -eq 0 ]
}
EOF
# Run tests
bats tests/
name: Shell Quality
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ShellCheck
uses: ludeeus/action-shellcheck@master
- name: Install BATS
run: sudo apt-get install -y bats
- name: Run Tests
run: bats tests/
Use this template for new scripts:
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
error_exit() {
echo "ERROR: $1" >&2
exit "${2:-1}"
}
main() {
[[ $# -lt 1 ]] && {
echo "Usage: $0 <argument>" >&2
exit 1
}
# Your logic here
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi
Recommended layout:
project/
├── scripts/ # Shell scripts
│ ├── main.sh
│ └── utils.sh
├── tests/ # BATS tests
│ ├── main.bats
│ └── utils.bats
├── .shellcheckrc # ShellCheck config
└── .github/
└── workflows/
└── quality.yml
@test "function succeeds with valid input" {
run example_function "test"
[ "$status" -eq 0 ]
[ -n "$output" ]
}
@test "function fails gracefully" {
run example_function ""
[ "$status" -ne 0 ]
[[ "$output" =~ "ERROR" ]]
}
@test "script returns valid JSON" {
run bash scripts/api.sh
[ "$status" -eq 0 ]
echo "$output" | jq empty
}
Create .shellcheckrc in project root:
shell=bash
disable=SC1090
enable=all
source-path=SCRIPTDIR
# Lint all scripts
find scripts -name "*.sh" -exec shellcheck {} +
# Run all tests
bats tests/
# Run with verbose output
bats -t tests/
# Combined check
shellcheck scripts/*.sh && bats tests/
ShellCheck Issues:
"$var"# shellcheck source=path/to/file.shif ! command; then instead of $?BATS Issues:
teardown() cleanup$BATS_TEST_DIRNAME for relative pathsContributions welcome! Please submit issues or pull requests.
Part of the gemini-search-plugin project.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer