File of the day
A Claude Code hook that lets read-only commands run without asking
Slava Sazhin 25 September 2026 2 min read 0 views
A PreToolUse hook that lets Claude Code run grep, cat, ls and git log without a permission prompt and leaves every other command to you. One script.
Today's file is a hook for Claude Code. Before every grep, ls or git log Claude Code stops to ask for permission, and by the twentieth time you press yes without reading. The hook answers for commands that only read, so the questions left on your screen are about commands that change something.
How it decides
It splits the command at ;, &&, ||, | and & the way the shell does, so a separator inside quotes stays part of the word. The command passes only when every part is on a closed list: about forty programs such as grep, cat, ls and head, plus git subcommands that only read, such as log, diff and status.
Anything it is unsure of goes to you as before: a write to a file, $(...), a heredoc, a variable assignment, a program called by its path, and sed, find, awk or xargs, which can run other programs. It also catches options that turn a reader into a writer, such as sort -o or git log --output.
What to change
The lists are at the top of the file. Add your own read programs to READ_ONLY and git subcommands to GIT_READ_ONLY. Before you add one, check whether it has an option that writes a file or runs a command, and if it does, put that option in DANGEROUS_OPTIONS.
Install
The script goes into ~/.claude/hooks/ and one block goes into ~/.claude/settings.json. You need python3 and jq. The commands, the block and a two-line check are in the note below.
The files
Files of the day are for paying subscribers: any plan opens every one. Already subscribed? Then sign in.
See the plansWas this article worth your time?
Read next
File of the day
A Claude Code subagent that collects data and leaves the conclusions to you
A Claude Code subagent that runs queries, appends each result with its source to a shared file and answers in a line or two. Conclusions stay with you.
Context Will Not Create Itself
The bank asked for its annual KYB. Why the agent uploaded the documents rather than me, and why it writes a diary entry after every task.
File of the day
A Claude Code subagent that finds code without eating your context
A Claude Code subagent that searches unfamiliar code in its own context and hands back only paths and line numbers. One file, a minute to install.
Give Claude a computer of its own
Your own Linux machine with Claude Code on it, working around the clock while your laptop is shut. From $3.49 a month.