Full Byte Developer.

Add notification and formatting hooks to Claude Code

Choose the right hook event, preserve existing settings and check that the action actually runs.

Originally posted · Published here · 1 source

Claude Code hooks run commands at specified events. The official guide uses Notification for desktop alerts and PostToolUse for formatting after an edit. [1]

Add an alert without replacing settings

In ~/.claude/settings.json, merge a Notification event into the existing hooks object. The guide supplies separate macOS, Linux and Windows examples. On macOS it uses osascript; Linux uses notify-send. [1]

Use the permission_prompt matcher when you want approval alerts rather than every notification. Open /hooks inside Claude Code and check that the event appears. Then trigger a permission request and confirm you receive the alert. [1]

Scope the formatter

The guide uses a PostToolUse event with the Edit|Write matcher. Its example reads the edited path from the hook input and runs Prettier. It requires jq. [1]

Before enabling automatic formatting, check which files your formatter supports and how its command handles paths containing spaces. Try a disposable file and inspect the diff.

Hooks execute commands with your environment's permissions. Read commands copied from another repository before putting them in settings. [1]

Keep this guide

By Full Byte Developer

Original post: Instagram post

Filed under Claude Code

Sources

Next in this stack