Arquivo do dia

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

Slava Sazhin 25 de setembro de 2026 2 min de leitura

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.

Os arquivos

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

Os arquivos do dia são para assinantes pagos: qualquer plano libera todos. Já é assinante? Então entre.

Ver os planos

Este artigo valeu o seu tempo?

Leia também

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.

Andy Avramenko 25 de setembro de 2026 · 2 min de leitura

Dê ao Claude um computador só dele

Sua própria máquina Linux com o Claude Code, trabalhando 24 horas por dia enquanto seu notebook está fechado. A partir de $3.49 por mês.

Fale com a equipe do Combobulating