Fixing a faulty hook
Now wire one up yourself. The editor holds a half-finished PreToolUse hook in .claude/settings.json that's meant to block reads of the .env file, but two things are wrong:
- The matcher only watches
Read, soGrepcould still leak the file's contents - The
commandfield is empty
Fix both in the editor, then press Check to validate your JSON and the hook's shape, so you can keep adjusting until every check passes.
Hints
A matcher can watch several tools at once with the pipe character, as in
Read|Grep.The
commandis the script Claude Code runs when the hook fires, so it can't be left empty. A minimal blocker is enough here — for exampleexit 2, which tells Claude Code to block the read.
Latihan ini merupakan bagian dari kursus
Claude Code in Action
Latihan interaktif langsung
Ubah teori menjadi aksi dengan salah satu latihan interaktif kami
Mulai latihan