Purrfect AI Labs

Video 01

You're babysitting Claude Code: the 3 settings

A sound when Claude needs you, a timer for every turn, and a status line with your limits. Five minutes to set up. Tested with Claude Code 2.1.

1 The timer script

Save it as ~/.claude/turn-time.sh. On Linux, use the paplay line from the comment instead of afplay.

Save it as C:\Users\YOUR-NAME\.claude\turn-time-windows.sh. Claude Code runs hooks in Git Bash on Windows, so it is a shell script here too.

After every answer it shows took 6m 12s, adds one line to ~/.claude/turns.csv (date, seconds), and plays a sound only when the turn took longer than 30 seconds.

~/.claude/turn-time.shDownload
#!/bin/sh
# Stop hook: how long the last turn took (macOS / Linux). Video: "You're babysitting Claude Code" by Purrfect AI Labs.
# Needs the UserPromptSubmit hook that writes the start time: date +%s > /tmp/turn_start
t=$(( $(date +%s) - $(cat /tmp/turn_start) ))
echo "$(date '+%F %T'),$t" >> ~/.claude/turns.csv
# the ding only for turns longer than 30 s (macOS sound; on Linux use: paplay /usr/share/sounds/freedesktop/stereo/complete.oga &)
[ "$t" -gt 30 ] && afplay /System/Library/Sounds/Glass.aiff &
printf '{"systemMessage": "took %dm %ds"}' $((t/60)) $((t%60))
~/.claude/turn-time-windows.shDownload
#!/bin/sh
# Stop hook: how long the last turn took (Windows: Claude Code runs hooks in Git Bash).
# Needs the UserPromptSubmit hook that writes the start time: date +%s > /tmp/turn_start
t=$(( $(date +%s) - $(cat /tmp/turn_start) ))
echo "$(date '+%F %T'),$t" >> ~/.claude/turns.csv
# the ding only for turns longer than 30 s
[ "$t" -gt 30 ] && powershell.exe -NoProfile -c "[Media.SoundPlayer]::new('C:\Windows\Media\notify.wav').PlaySync()" &
printf '{"systemMessage": "took %dm %ds"}' $((t/60)) $((t%60))

2 The hooks

Open ~/.claude/settings.json (it applies to every project) and add the "hooks" part. If your file already has a "hooks" part, add the three events into it.

~/.claude/settings.jsonDownload
{
  "hooks": {
    "Notification": [
      { "hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Ping.aiff &" }] }
    ],
    "UserPromptSubmit": [
      { "hooks": [{ "type": "command", "command": "date +%s > /tmp/turn_start" }] }
    ],
    "Stop": [
      { "hooks": [{ "type": "command", "command": "sh ~/.claude/turn-time.sh" }] }
    ]
  }
}
~/.claude/settings.jsonDownload
{
  "hooks": {
    "Notification": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "powershell.exe -NoProfile -c \"[Media.SoundPlayer]::new('C:\\Windows\\Media\\Windows Notify System Generic.wav').PlaySync()\" &"
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "date +%s > /tmp/turn_start"
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "sh ~/.claude/turn-time-windows.sh"
          }
        ]
      }
    ]
  }
}

Type /hooks in Claude Code to see that they are active.

The trick almost everybody gets wrong: Claude Code does not show plain text from a Stop hook. Print JSON with a "systemMessage" instead. The timer script does this.

3 The status line

Type this in Claude Code. Claude writes the script and adds statusLine to your settings.

/statusline show model, context %, cost and the 5-hour limit

Turn it off

"disableAllHooks": true in settings.json turns every hook off. /statusline delete removes the status line.

Docs: hooks · status line