Shellcheck Clean + Shell Collector
Enforce Shellcheck Clean using data collected by Shell Collector. Automatically check testing and quality standards on every PR.
How Shell Collector Powers This Guardrail
The Shell Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Shellcheck Clean guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the Shell Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/shell@v1.0.5
# with: ...
# Step 2: Enable the Shell Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/shell@v1.0.5
include: [shellcheck-clean]
# with: ...
What Shell Collector Collects
This collector gathers the following data that the Shellcheck Clean guardrail evaluates.
project
Detects shell scripts in the repository by scanning for .sh and .bash files. Identifies shell types from shebang lines (bash, sh, zsh, dash, etc.). Writes script count, file locations, and shell type metadata to .lang.shell.
shellcheck
Runs ShellCheck against all detected shell scripts with JSON output. Parses results into normalized lint warnings at .lang.shell.lint and tool-specific summary data at .lang.shell.native.shellcheck including pass/fail status and per-severity issue counts.
shellcheck-cicd
Detects ShellCheck executions in CI pipelines and records the command and version. Writes CI integration metadata to .lang.shell.native.shellcheck.cicd confirming ShellCheck is part of the CI workflow.
Example Data Flow
Here's an example of the data that Shell Collector writes to the Component JSON, which Shellcheck Clean then evaluates.
{
"lang": {
"shell": {
"script_count": 3,
"scripts": ["deploy.sh", "build/compile.sh", "scripts/test.sh"],
"shells": ["bash", "sh"],
"source": {
"tool": "shell-collector",
"integration": "code"
},
"native": {
"shellcheck": {
"passed": false,
"version": "0.10.0",
"files_checked": 3,
"error_count": 0,
"warning_count": 1,
"info_count": 0,
"style_count": 0,
"cicd": {
"commands": ["shellcheck scripts/*.sh"],
"version": "0.10.0"
}
}
},
"lint": {
"warnings": [
{
"file": "deploy.sh",
"line": 15,
"column": 3,
"message": "Double quote to prevent globbing and word splitting.",
"linter": "shellcheck",
"severity": "warning",
"code": "SC2086"
}
],
"linters": ["shellcheck"],
"source": {
"tool": "shellcheck",
"integration": "code"
}
}
}
}
}
Configuration Options
Shell Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
find_command |
Optional |
find . -type f \( -name '*.sh' -o -name '*.bash' \) -not -path '*/node_modules/*' -not -path '*/vendor/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/.terraform/*'
|
Command to find shell scripts (must output one file path per line) |
shellcheck_severity |
Optional |
style
|
Minimum ShellCheck severity level to collect (error, warning, info, style). Default collects everything. |
Shell Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_severity |
Optional |
error
|
Minimum severity level to enforce (error, warning, info, style). Issues below this level are ignored. |
max_shellcheck_warnings |
Optional |
0
|
Maximum number of ShellCheck warnings allowed at or above min_severity (0 = must be completely clean) |
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 200+ built-in guardrails.