feat: add block-no-verify hook for Claude Code and Cursor#649
feat: add block-no-verify hook for Claude Code and Cursor#649tupe12334 wants to merge 1 commit intoaffaan-m:mainfrom
Conversation
Adds npx block-no-verify@1.1.2 as a PreToolUse Bash hook in hooks/hooks.json and a beforeShellExecution hook in .cursor/hooks.json to prevent AI agents from bypassing git hooks via the hook-bypass flag. This closes the last enforcement gap in the ECC security stack — the bypass flag silently skips pre-commit, commit-msg, and pre-push hooks. Closes affaan-m#648 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe PR adds Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
Greptile SummaryThis PR adds Key issues found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Agent as Claude Code / Cursor Agent
participant Hook as PreToolUse Hook (hooks.json)
participant npx as npx block-no-verify@1.1.2
participant npm as npm Registry
participant Shell as Shell / Git
Agent->>Hook: Bash command (stdin: full command text)
Hook->>npx: spawn process, pipe stdin
npx->>npm: fetch package (on cache miss)
npm-->>npx: package download
npx->>npx: parse stdin for --no-verify / -n flags
alt Flag detected
npx-->>Hook: exit code 2 (blocked)
Hook-->>Agent: command blocked
else No flag
npx-->>Hook: exit code 0 (allowed)
Hook->>Shell: execute command
Shell-->>Agent: result
end
Last reviewed commit: "feat: add block-no-v..." |
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "npx block-no-verify@1.1.2" | ||
| } | ||
| ], |
There was a problem hiding this comment.
Missing
timeout may block all Bash commands indefinitely
npx block-no-verify@1.1.2 runs before every Bash command via the PreToolUse hook. If the npm registry is unreachable, DNS resolution stalls, or the package download hangs, the hook will block indefinitely and freeze every single shell operation in the session — there is no safety valve.
Compare with the insaits-security hook directly below, which sets "timeout": 15. Given this hook is even higher-priority (first in the list) and similarly unconditional, it should carry a timeout as well.
| "hooks": [ | |
| { | |
| "type": "command", | |
| "command": "npx block-no-verify@1.1.2" | |
| } | |
| ], | |
| { | |
| "type": "command", | |
| "command": "npx block-no-verify@1.1.2", | |
| "timeout": 10 | |
| } |
| { | ||
| "command": "npx block-no-verify@1.1.2", | ||
| "event": "beforeShellExecution", | ||
| "description": "Block git hook-bypass flag to protect pre-commit, commit-msg, and pre-push hooks from being skipped" | ||
| }, |
There was a problem hiding this comment.
No timeout — can hang all shell executions
Same issue as hooks/hooks.json: npx block-no-verify@1.1.2 is the first beforeShellExecution hook and has no timeout. If npm is unavailable (offline CI, restricted network, cold npm cache), this hook will stall indefinitely and block every shell command Cursor tries to run for the entire session.
| "matcher": "Bash", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "npx block-no-verify@1.1.2" | ||
| } | ||
| ], | ||
| "description": "Block git hook-bypass flag to protect pre-commit, commit-msg, and pre-push hooks from being skipped" | ||
| }, |
There was a problem hiding this comment.
No opt-out mechanism — bypasses the established flags pattern
Every other hook in this file uses the run-with-flags.js / run-with-flags-shell.sh wrapper with a feature-flag string (e.g., "standard,strict", "minimal,standard,strict"). This wrapper pattern lets users disable individual hooks by setting ECC feature flags. The new entry calls npx block-no-verify@1.1.2 directly, completely bypassing that system.
This means the hook is unconditionally applied to all users of the plugin regardless of their chosen ECC profile, with no documented way to opt out. Consider wrapping it the same way other hooks are wrapped, so it respects the existing flag/profile system.
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "npx block-no-verify@1.1.2" |
There was a problem hiding this comment.
Supply-chain risk: external package runs on every command, authored by the PR submitter
The PR description explicitly states: "Disclosure: I am the author and maintainer of block-no-verify." Merging this hook means every user of everything-claude-code will execute a package maintained by the PR author before every Bash command, with stdin containing the full command text.
Concrete risks to consider:
- Elevated trust surface: A compromised npm account (
tupe12334) or a malicious republish of1.1.2could run arbitrary code with access to the command being executed by Claude Code. npxre-fetches on cache miss: Even with a pinned version,npxhits the registry on first run per machine, so users on fresh environments silently download and execute this package.- Reads stdin on every command: The package design (per its docs) reads stdin containing the full shell command. A malicious version could exfiltrate every command issued by the AI agent.
The package's purpose is legitimate, but pulling an external npm package authored by the PR submitter into a pre-command security hook is a significant trust ask. Consider either vendoring the detection logic locally (the --no-verify flag pattern is trivial to match), or at minimum documenting this dependency and its trust assumptions clearly in the README.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@hooks/hooks.json`:
- Line 10: The pre-commit hook command "npx block-no-verify@1.1.2" is
interactive on cold caches; update the hooks.json entry to append the
non-interactive flag by changing the command value for the hook that currently
contains "npx block-no-verify@1.1.2" to include "--yes" (i.e., "npx
block-no-verify@1.1.2 --yes") so CI and non-interactive environments won't be
blocked by prompts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 49ab9219-3b13-4554-b734-95f952d3caac
📒 Files selected for processing (2)
.cursor/hooks.jsonhooks/hooks.json
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "npx block-no-verify@1.1.2" |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
payload='{"command":"git commit --no-verify"}'
echo "== without --yes (cold cache) =="
cache1="$(mktemp -d)"
set +e
printf '%s' "$payload" | npm_config_cache="$cache1" npx block-no-verify@1.1.2 >/tmp/bnv-out-1 2>/tmp/bnv-err-1
code1=$?
set -e
echo "exit_code=$code1"
sed -n '1,20p' /tmp/bnv-err-1
echo "== with --yes (cold cache) =="
cache2="$(mktemp -d)"
set +e
printf '%s' "$payload" | npm_config_cache="$cache2" npx --yes block-no-verify@1.1.2 >/tmp/bnv-out-2 2>/tmp/bnv-err-2
code2=$?
set -e
echo "exit_code=$code2"
sed -n '1,20p' /tmp/bnv-err-2Repository: affaan-m/everything-claude-code
Length of output: 436
🏁 Script executed:
grep -n "npx" hooks/hooks.jsonRepository: affaan-m/everything-claude-code
Length of output: 128
🏁 Script executed:
fd -t f '\.(json|sh|yaml|yml)$' -x grep -l "npx" {} \;Repository: affaan-m/everything-claude-code
Length of output: 139
🏁 Script executed:
cat -n hooks/hooks.jsonRepository: affaan-m/everything-claude-code
Length of output: 11901
Add --yes flag to make the npx command non-interactive.
Line 10 uses npx without --yes, which produces installation warnings on cold package caches and can interfere with non-interactive hook execution in CI environments.
Suggested fix
- "command": "npx block-no-verify@1.1.2"
+ "command": "npx --yes block-no-verify@1.1.2"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "command": "npx block-no-verify@1.1.2" | |
| "command": "npx --yes block-no-verify@1.1.2" |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hooks/hooks.json` at line 10, The pre-commit hook command "npx
block-no-verify@1.1.2" is interactive on cold caches; update the hooks.json
entry to append the non-interactive flag by changing the command value for the
hook that currently contains "npx block-no-verify@1.1.2" to include "--yes"
(i.e., "npx block-no-verify@1.1.2 --yes") so CI and non-interactive environments
won't be blocked by prompts.
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="hooks/hooks.json">
<violation number="1" location="hooks/hooks.json:10">
P2: Security enforcement hook depends on runtime `npx` execution of a third-party package, introducing avoidable supply-chain and availability risk versus repo-local enforcement scripts.</violation>
</file>
<file name=".cursor/hooks.json">
<violation number="1" location=".cursor/hooks.json:19">
P1: Using `npx` to execute an external package in `beforeShellExecution` introduces avoidable supply-chain and availability risk on a critical hook path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| ], | ||
| "beforeShellExecution": [ | ||
| { | ||
| "command": "npx block-no-verify@1.1.2", |
There was a problem hiding this comment.
P1: Using npx to execute an external package in beforeShellExecution introduces avoidable supply-chain and availability risk on a critical hook path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .cursor/hooks.json, line 19:
<comment>Using `npx` to execute an external package in `beforeShellExecution` introduces avoidable supply-chain and availability risk on a critical hook path.</comment>
<file context>
@@ -15,6 +15,11 @@
],
"beforeShellExecution": [
+ {
+ "command": "npx block-no-verify@1.1.2",
+ "event": "beforeShellExecution",
+ "description": "Block git hook-bypass flag to protect pre-commit, commit-msg, and pre-push hooks from being skipped"
</file context>
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "npx block-no-verify@1.1.2" |
There was a problem hiding this comment.
P2: Security enforcement hook depends on runtime npx execution of a third-party package, introducing avoidable supply-chain and availability risk versus repo-local enforcement scripts.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/hooks.json, line 10:
<comment>Security enforcement hook depends on runtime `npx` execution of a third-party package, introducing avoidable supply-chain and availability risk versus repo-local enforcement scripts.</comment>
<file context>
@@ -2,6 +2,16 @@
+ "hooks": [
+ {
+ "type": "command",
+ "command": "npx block-no-verify@1.1.2"
+ }
+ ],
</file context>
What Changed
Added
block-no-verify@1.1.2as a hook entry in two files:hooks/hooks.json— new first PreToolUseBashhook runningnpx block-no-verify@1.1.2.cursor/hooks.json— new firstbeforeShellExecutionhook runningnpx block-no-verify@1.1.2Why This Change
ECC already has an excellent security stack: dev-server blocking, git push reminders, secret scanning, quality gates. But there's one remaining bypass vector: the git hook-skip flag silently disables pre-commit, commit-msg, and pre-push hooks entirely.
Claude Code, Codex, and Cursor agents will reach for this flag when a hook blocks them. Adding
block-no-verify@1.1.2closes this gap without any custom logic — the package reads stdin, detects the flag pattern (all variants), and exits 2 to block the command.This is the enforcement layer to complement the existing
pre:bash:git-push-reminder.Testing Done
Type of Change
feat:New featureSecurity & Quality Checklist
Documentation
No README changes needed — the hook is self-describing via its
descriptionfield.Closes #648
Disclosure: I am the author and maintainer of
block-no-verify.Summary by cubic
Add
block-no-verify@1.1.2hooks for Claude Code and Cursor to block the git--no-verifyflag and protectpre-commit,commit-msg, andpre-pushhooks. Closes #648 by enforcing our security checks during local shell commands.hooks/hooks.jsonrunningnpx block-no-verify@1.1.2.beforeShellExecutionhook in.cursor/hooks.jsonrunningnpx block-no-verify@1.1.2.Written for commit 2478df1. Summary will update on new commits.
Summary by CodeRabbit