Home

Claude Code Hooks

· SI THU AUNG

The problem

Every time I leave Claude Code working in a terminal tab while I do something else, I run into two problems:

  1. Claude asks for my permission to run a command, and auto-accepting everything it suggests isn’t something I like to do.
  2. It finishes working and goes idle.

To solve these little things, I found Claude hooks, which can notify me. https://code.claude.com/docs/en/hooks

So I set it up to play a sound every time Claude needs my attention. Here’s what I did.

// cat ~/.claude/settings.json
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "hooks": {
    "PermissionRequest": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "afplay ~/Sounds/request-permission.mp3",
            "async": true
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "afplay ~/Sounds/task-completed.mp3",
            "async": true
          }
        ]
      }
    ]
  },
  .....
}