Feature request: recommended PreToolUse hooks for command validation
Problem
Claude Code executes shell commands that fail frequently — wrong flags, missing binaries, bad syntax, unreachable targets. Each failure poisons the context window and triggers retries, compounding token cost.
We parsed a real Claude Code transcript: 152 command failures in one session. Every retry carried the error forward.
Proposed solution
Support recommended or default PreToolUse hooks that validate commands before execution. A pre-execution gate that returns allow or deny before the command reaches the shell.
Existing implementation
Check already ships as a PreToolUse hook for Claude Code. One config change:
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash|PowerShell",
"hooks": [{
"type": "command",
"command": "npx",
"args": ["@golproductions/check"]
}]
}]
},
"env": { "GOL_CLIENT_ID": "your_key" }
}
Results
- Without Check: 152 failed commands in one session
- With Check: 2 failed commands in 6 hours of heavy usage (blog rewrites, deployments, npm publishes, VS Code extension builds)
- Reduction: 98.7%
Sub-100ms validation. $0.0068 AUD per check. Local binary existence checks run instantly with zero API cost.
Why this matters for Claude Code
Every blocked invalid command is a retry that never happens. Every avoided retry is tokens the user keeps. Pre-execution validation makes Claude Code feel more reliable without changing the model.
Links
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗