shellcheck
Lint shell scripts to detect bugs, stylistic problems, and potential errors. Supports multiple shells and outputs structured JSON with severity levels.
Instructions
Run ShellCheck on a shell script to find bugs, stylistic issues, and potential errors. Use when: reviewing shell scripts, validating CI pipeline scripts, or debugging script errors. Prefer over: manual bash syntax inspection when you want automated rule-based analysis (300+ rules). Avoid when: checking many large scripts — run ShellCheck locally for bulk analysis.
Supported shells: bash, sh, dash, ksh, ash
Returns structured JSON with issue details including line, column, code, message, and severity.
Common error codes:
SC1090: Can't follow non-constant source
SC2148: Tips depend on target shell and yours is unknown
SC2086: Double quote to prevent globbing
SC2164: Use cd with || exit
SC2006: Use $(...) instead of legacy backticks
SC2029: Note that, unlike in BASH, a variable cannot contain a newline
SC2230: Which is redundant
SC2068: Double quote array subscript
SC2196: Several way to test global flag
SC2001: See if you can use ${var//search/replace}
SC2162: read without -r will mangle backslashes
SC2129: Style: Consider using { cmd1; cmd2; } >> file instead of individual redirects
Use exclude parameter to suppress warnings (e.g., "SC1090,SC2148"). Use severity parameter to filter by minimum severity (error, warning, info, style).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shell | No | Shell type to check | bash |
| exclude | No | Comma-separated list of warning codes to exclude (e.g., 'SC1090,SC2148') | |
| severity | No | Minimum severity to report | |
| file_path | No | Path to the shell script file to check | |
| enable_all | No | Enable all optional checks | |
| check_sourced | No | Enable checks for sourced files | |
| script_content | No | Raw shell script content to check (alternative to file_path) |