Repository navigation
chore(agents): guard the installers and lint shell edits with Claude Code hooks - #15
Merged
Merged
Conversation
- .claude/settings.json: allow shellcheck and zsh -n, deny running bootstrap.sh, init/*, sudo, defaults write, brew and chsh - PreToolUse Bash hook blocks the installers and system changes however the command is chained (cd x && sh .osx, source init/.osx, bash -c) - PostToolUse Edit|Write hook runs ShellCheck (or zsh -n) on the edited file and feeds problems back - AGENTS.md: fix stale .shellcheckrc note, add the CI ShellCheck command and zsh -n check, note threads don't load repo hooks - .editorconfig: lf, final newline, 2-space indent for shell files Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012HeotRG6Zd1MKjxSnSmB6Z
FrancesCoronel
marked this pull request as ready for review
October 24, 2026 15:16
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: AGENTS.md told agents not to run
bootstrap.shorinit/*, but nothing enforced it, andcd init && sh .osxorsource init/.osxwould have gone straight through. Shell edits were only checked once CI ran, the zsh files weren't checked at all, and AGENTS.md still said.shellcheckrcwas "once added".After: in local and standalone cloud Claude Code sessions, a PreToolUse hook blocks the installers and system changes however the command is chained, and every edit to a shell file gets ShellCheck (or
zsh -n) feedback in the same turn. AGENTS.md lists the exact check CI runs.How:
.claude/settings.json: allowsshellcheckandzsh -n; deniesbootstrap.sh,init/*,sudo,defaults write,brewandchsh. Wires up both hooks..claude/hooks/guard-installers.sh(PreToolUse, Bash): splits the command on;,&&,|, subshells and backticks, then exits 2 when a part runs an installer (directly or throughsh/bash/source/./env/exec/xargs), or usessudo,chsh,defaults write|delete|import,scutil --setor a mutatingbrewsubcommand. Reading, grepping, diffing and ShellChecking those files still works. Deny rules are prefix matches and miss these cases, which is why there's a hook too..claude/hooks/shellcheck-edited.sh(PostToolUse, Edit|Write): runsshellcheck --severity styleon*.sh,*.bashand sh/bash shebang files, andzsh -non zsh files, then exits 2 with the output when either fails. Skips quietly if the tool isn't installed.AGENTS.md: fixed the stale.shellcheckrcline (it disables SC1090 and SC1091), added a Checks section with the ShellCheck command CI runs (first-line shebang match, same asci-shell.yml) and thezsh -ncheck, and said that Project threads don't load repo hooks, so the written rule is what applies there..editorconfig: lf, final newline, 2-space indent and no trailing whitespace for the shell files. App-exported themes are left alone.What I ran: ShellCheck at style severity on all 10 tracked shebang scripts plus both hooks (clean);
zsh -non.zshrc,.zprofile,.zshenvandzsh/.p10k.zsh(clean);jq empty .claude/settings.json. I tested the hooks only by piping JSON into them and ran no install script. The guard blocked 14 cases (for example./bootstrap.sh,cd init && sh .osx,source init/.osx,bash -c "cd x; bash init/.npm",env bash bootstrap.sh,echo $(sudo whoami),brew install jq) and allowed 10 (shellcheck init/.osx bootstrap.sh,cat init/.osx,git diff bootstrap.sh,git commit -m "guard sudo and brew install",brew info jq,defaults read ..., the AGENTS.md check command and others). The ShellCheck hook exited 2 on an unquoted$1and on a broken.zshrc, and exited 0 on clean files, non-shell files and missing files.Not in this PR: saying
bashinstead ofshin the install steps (left for Frances), and the Project-level setup script and instructions (account settings, not repo files).Generated by Claude Code