File of the day

A Claude Code hook that lets read-only commands run without asking

Slava Sazhin 25 September 2026 2 min read

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

read_only.py 5 KB
how-to-install.md 2 KB

Files of the day are for paying subscribers: any plan opens every one. Already subscribed? Then sign in.

See the plans

Was this article worth your time?

Read next

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.

Contact the Combobulating team