ShellCheck - Shell script linting

VerifiedCaution

Lint and fix shell script issues using ShellCheck. Detects common errors, explains their impact, and provides specific corrections.

Sby Skills Guide Bot
DevelopmentBeginner
3/8/2026
Claude Code
#shell-scripting#linting#static-analysis#bash#code-quality

Recommended for

Automated summary

Runs ShellCheck on shell scripts, explains each finding by severity, and proposes concrete fixes.

Strengths

  • Documents the useful ShellCheck options: severity filter, --shell dialect, json/gcc output formats, and multi-file checks
  • Ships a ready-to-use fix catalog for common codes (SC2086, SC2046, SC2006, SC2164, SC2155, SC2162, SC2034)
  • Insists on running ShellCheck before any manual review and explains why each issue matters
  • Explains when and how to disable a rule per line, per block, or file-wide

Limitations

  • Assumes ShellCheck is already installed and available on the command line
  • Covers static linting only: it does not test how the script actually behaves at runtime
  • Auto-fixes through the Edit tool are limited to simple cases; ambiguous findings still need human judgement
When to use it

Use it whenever a bash or sh script needs to be checked, cleaned up, or reviewed before execution or commit.

When not to use it

Avoid it when you need to debug a script that fails at runtime or test its business logic, which ShellCheck does not cover.

Security analysis

Caution
Quality score92/100

The skill is a legitimate ShellCheck wrapper with no destructive, exfiltration, obfuscation, or safety-disabling instructions. Because it can run Bash and edit files, it warrants caution rather than safe, but the described actions are scoped to linting and fixing scripts.

Findings
  • •Declares Bash and Edit, so it can execute ShellCheck and modify user script files; auto-fix behavior should require user confirmation.
How this analysis is made

Examples

Lint a single script
Can you shellcheck deploy.sh and explain every warning it reports?
Review before committing
Review my backup.sh script for shell issues and give me the corrected version.
Fix quoting warnings
shellcheck says SC2086 on several lines in cleanup.sh — fix them all and show the diff.

name: shellcheck description: Lint and fix shell script issues using ShellCheck. Use when the user says "check this script", "lint shell", "shellcheck", "fix script warnings", "validate bash", or asks to review a shell script for issues. allowed-tools: Bash, Read, Edit

ShellCheck

Lint shell scripts and fix common issues using ShellCheck.

Instructions

  1. Run ShellCheck on the script
  2. Analyze findings by severity
  3. Explain each issue clearly
  4. Provide fixes for each issue

Run ShellCheck

# Basic check
shellcheck script.sh

# With severity filter
shellcheck --severity=warning script.sh

# Specific shell dialect
shellcheck --shell=bash script.sh

# Output formats
shellcheck --format=json script.sh
shellcheck --format=gcc script.sh

# Check multiple files
shellcheck *.sh

Common issues and fixes

SC2086: Double quote to prevent globbing

# Bad
rm $file
echo $var

# Good
rm "$file"
echo "$var"

SC2046: Quote command substitution

# Bad
rm $(find . -name "*.tmp")

# Good
rm "$(find . -name "*.tmp")"
# Or for multiple results:
find . -name "*.tmp" -delete

SC2006: Use $() instead of backticks

# Bad
date=`date`

# Good
date=$(date)

SC2164: Use cd ... || exit

# Bad
cd /some/dir
do_something

# Good
cd /some/dir || exit 1
do_something

SC2155: Declare and assign separately

# Bad
local var=$(command)

# Good
local var
var=$(command)

SC2162: Read without -r mangles backslashes

# Bad
read line

# Good
read -r line

SC2034: Variable appears unused

# Check if it's exported or used in eval/source
# Or prefix with _ to indicate intentionally unused
_unused_var="value"

Disable warnings

# Disable for next line
# shellcheck disable=SC2086
echo $unquoted_var

# Disable for entire file (at top)
# shellcheck disable=SC2034,SC2086

# Disable for block
# shellcheck disable=SC2086
{
    echo $var1
    echo $var2
}

Output format

## Issues Found

### Errors (must fix)
- Line 10, SC2086: Double quote to prevent globbing and word splitting

### Warnings (should fix)
- Line 15, SC2155: Declare and assign separately to avoid masking return values

### Suggestions
- Line 20, SC2034: UNUSED_VAR appears unused (verify or prefix with _)

## Fixed Code
[Show corrected version]

Rules

  • MUST run shellcheck before reviewing manually
  • MUST explain why each issue matters
  • MUST provide specific fix for each issue
  • Never ignore errors (SC level error)
  • Always explain when disabling is appropriate
  • Offer to auto-fix simple issues with Edit tool

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/shellcheck-shell-script-linting-mmh8qqw4/download' --output '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md.part' && mv '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md.part' '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Bash, Read, Edit

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md' && test -s '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/shellcheck' && cp -R '.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4' '.claude/skills/shellcheck'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/shellcheck-shell-script-linting-mmh8qqw4'

openskills read 'shellcheck-shell-script-linting-mmh8qqw4'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/shellcheck-shell-script-linting-mmh8qqw4/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills