Add shellcheck to pre-commit, Claude Code lint hook, and CI#36
Add shellcheck to pre-commit, Claude Code lint hook, and CI#36ojongerius merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds ShellCheck-based linting for shell scripts to the repo’s local automation, ensuring *.sh files are checked both during git pre-commit and after Claude edits.
Changes:
- Add a
shellcheckjob to Lefthookpre-commitfor staged*.shfiles. - Extend the Claude
lint-on-edithook to runshellcheckwhen editing*.shfiles.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lefthook.yml |
Adds a new pre-commit job to run shellcheck on staged shell scripts. |
.claude/hooks/lint-on-edit.sh |
Runs shellcheck after Claude edits shell scripts (when available). |
lefthook.yml
Outdated
|
|
||
| - name: shellcheck | ||
| glob: "*.sh" | ||
| run: shellcheck {staged_files} |
There was a problem hiding this comment.
The new pre-commit job will fail on developer machines/CI where shellcheck isn’t installed (unlike the Claude lint hook, which silently skips when missing). Consider either (a) guarding the lefthook command with a command -v shellcheck check and a clear skip message, or (b) documenting/enforcing shellcheck as a required dev dependency so the behavior is consistent across tooling.
| run: shellcheck {staged_files} | |
| run: if command -v shellcheck >/dev/null 2>&1; then shellcheck {staged_files}; else echo "Skipping shellcheck: 'shellcheck' is not installed."; fi |
| ;; | ||
| *.sh) | ||
| if command -v shellcheck >/dev/null 2>&1; then | ||
| shellcheck "$FILE_PATH" >&2 || { echo "shellcheck: $FILE_PATH has issues" >&2; exit 2; } |
There was a problem hiding this comment.
This hook skips shell linting entirely when shellcheck isn’t installed, but the new lefthook.yml pre-commit job will fail in that situation. To avoid confusing/contradictory behavior, consider aligning the policy (either require shellcheck in both places, or have both skip with a clear message when it’s missing).
| shellcheck "$FILE_PATH" >&2 || { echo "shellcheck: $FILE_PATH has issues" >&2; exit 2; } | |
| shellcheck "$FILE_PATH" >&2 || { echo "shellcheck: $FILE_PATH has issues" >&2; exit 2; } | |
| else | |
| echo "shellcheck: required to lint $FILE_PATH but is not installed" >&2 | |
| exit 2 |
d53b9c3 to
fa87bf9
Compare
65f6825 to
1d6560b
Compare
Summary
shellcheckjob to Lefthook pre-commit (graceful skip if not installed)*.shcase to Claude Code lint-on-edit hook (graceful skip if not installed).github/workflows/shellcheck.yml— path-filtered CI check that hard-fails on shellcheck violationsVerified: all
.claude/hooks/*.shscripts passshellcheckas-is.