Skip to content

Add shellcheck to pre-commit, Claude Code lint hook, and CI#36

Merged
ojongerius merged 1 commit intomainfrom
shellcheck
Apr 4, 2026
Merged

Add shellcheck to pre-commit, Claude Code lint hook, and CI#36
ojongerius merged 1 commit intomainfrom
shellcheck

Conversation

@ojongerius
Copy link
Copy Markdown
Contributor

@ojongerius ojongerius commented Apr 4, 2026

Summary

  • Adds shellcheck job to Lefthook pre-commit (graceful skip if not installed)
  • Adds *.sh case to Claude Code lint-on-edit hook (graceful skip if not installed)
  • Adds .github/workflows/shellcheck.yml — path-filtered CI check that hard-fails on shellcheck violations
  • Three layers: Lefthook (local), Claude Code hook (agent edits), CI (enforced)

Verified: all .claude/hooks/*.sh scripts pass shellcheck as-is.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shellcheck job to Lefthook pre-commit for staged *.sh files.
  • Extend the Claude lint-on-edit hook to run shellcheck when editing *.sh files.

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}
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
;;
*.sh)
if command -v shellcheck >/dev/null 2>&1; then
shellcheck "$FILE_PATH" >&2 || { echo "shellcheck: $FILE_PATH has issues" >&2; exit 2; }
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
@ojongerius ojongerius force-pushed the shellcheck branch 2 times, most recently from d53b9c3 to fa87bf9 Compare April 4, 2026 19:51
@ojongerius ojongerius changed the title Add shellcheck to pre-commit and Claude Code lint hook Add shellcheck to pre-commit, Claude Code lint hook, and CI Apr 4, 2026
@ojongerius ojongerius force-pushed the shellcheck branch 2 times, most recently from 65f6825 to 1d6560b Compare April 4, 2026 19:52
@ojongerius ojongerius merged commit 6e1041b into main Apr 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants