본문 바로가기
2026~/클로드

클로드 코드 기초 공부하기 (W. Mac) 3. Hook 이용해서 클로드 알림 만들기

by chaemj97 2026. 3. 16.
728x90
반응형

아직 클로드코드 기초라 잘못된 내용이 있을 수 있습니다.

댓글로 알려주시면 수정하겠습니다. 감사합니다


https://code.claude.com/docs/ko/hooks-guide

 

hooks를 사용하여 워크플로우 자동화 - Claude Code Docs

Claude Code가 파일을 편집하거나 작업을 완료하거나 입력이 필요할 때 자동으로 셸 명령을 실행합니다. 코드 형식 지정, 알림 전송, 명령 검증 및 프로젝트 규칙 적용.

code.claude.com

 

 

알림

  • 작업이 완료되었을 때
  • 에러가 났을때
  • 나의 입력이 필요할 때

# 1. terminal-notifier 설치
brew install terminal-notifier

# 2. 훅 스크립트 생성
mkdir -p ~/.claude/hooks


cat << 'EOF' > ~/.claude/hooks/notify-done.sh
#!/bin/bash
/opt/homebrew/bin/terminal-notifier -title "Claude Code" -message "😊 주인님!! 작업이 완료되었습니다!" -sound Ping -execute "open -a 'Visual Studio Code'"
EOF

cat << 'EOF' > ~/.claude/hooks/notify-error.sh
#!/bin/bash
/opt/homebrew/bin/terminal-notifier -title "Claude Code" -message "🚨 주인님!! 문제가 생겼습니다!" -sound Ping -execute "open -a 'Visual Studio Code'"
EOF

cat << 'EOF' > ~/.claude/hooks/notify-idle.sh
#!/bin/bash
/opt/homebrew/bin/terminal-notifier -title "Claude Code" -message "🙏 주인님!! 주인님이 필요합니다!" -sound Ping -execute "open -a 'Visual Studio Code'"
EOF

cat << 'EOF' > ~/.claude/hooks/notify-forgotten.sh
#!/bin/bash
/opt/homebrew/bin/terminal-notifier -title "Claude Code" -message "🥺 주인님 절 잊으셨나요..?" -sound Glass
EOF

chmod +x ~/.claude/hooks/notify-done.sh
chmod +x ~/.claude/hooks/notify-error.sh
chmod +x ~/.claude/hooks/notify-idle.sh
chmod +x ~/.claude/hooks/notify-forgotten.sh

cat << 'EOF' > ~/.claude/settings.json
{
  "hooks": {
    "Stop": [
      {
        "hooks": [{"type": "command", "command": "~/.claude/hooks/notify-done.sh"}]
      }
    ],
    "PostToolUseFailure": [
      {
        "matcher": "",
        "hooks": [{"type": "command", "command": "~/.claude/hooks/notify-error.sh"}]
      }
    ],
    "Notification": [
      {
        "matcher": "permission_prompt",
        "hooks": [{"type": "command", "command": "~/.claude/hooks/notify-idle.sh"}]
      },
      {
        "matcher": "idle_prompt",
        "hooks": [{"type": "command", "command": "~/.claude/hooks/notify-forgotten.sh"}]
      }
    ]
  }
}
EOF

 

알림 날려보기

# 작업완료
~/.claude/hooks/notify-done.sh

# 에러
~/.claude/hooks/notify-error.sh

# 내가 필요
~/.claude/hooks/notify-idle.sh

## 한번에 확인
~/.claude/hooks/notify-done.sh && sleep 2 && ~/.claude/hooks/notify-error.sh && sleep 2 && ~/.claude/hooks/notify-idle.sh

 

728x90
반응형

댓글