Claude Code Integration
Integrate Ping with Claude Code to get push notifications when Claude finishes tasks or needs approval for deploy commands.
Use Cases
- Long-running tasks - Get notified when Claude finishes a big refactor
- Background agents - Fire off a task and get pinged when it's done
- Deploy approvals - Approve deployments from your phone before they run
- Security alerts - Get notified when Claude runs potentially risky commands
Quick Setup
- Create a channel for Claude Code notifications in the Ping app
- Copy your webhook token
- Add to your project's
.claude/settings.json:
JSON
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "export PING_WEBHOOK_TOKEN=YOUR_TOKEN && python3 \"$CLAUDE_PROJECT_DIR/.claude/hooks/deploy-approval.py\"",
"timeout": 310
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 \"$CLAUDE_PROJECT_DIR/.claude/hooks/ping-notify.py\"",
"timeout": 10
}
]
}
]
}
}- Copy the hook scripts to your
.claude/hooks/directory (available in the Ping repository)
Deploy Approval Flow
When enabled, the deploy approval hook:
- Detects deploy commands (
git push,railway up,vercel deploy, etc.) - Sends a notification to your phone with Approve/Reject buttons
- Waits up to 5 minutes for your response
- If approved: runs the command
- If rejected: blocks the command
This uses Ping's callback polling API - no external server or ngrok required.
Available Hooks
| Hook | Event | Description |
|---|---|---|
ping-notify.py | Stop | Notification when Claude finishes working |
ping-notify.py | SessionEnd | Notification when session terminates |
ping-notify.py | Notification | Alert when Claude needs input |
deploy-approval.py | PreToolUse | Self-contained deploy approval (polls Ping for response) |
Minimal Completion Hook
For simple "Claude finished" notifications:
#!/usr/bin/env python3
import os
import sys
import json
import urllib.request
def send_notification():
token = os.environ.get('PING_WEBHOOK_TOKEN')
if not token:
return
payload = json.dumps({
'title': 'Claude Finished',
'body': 'Claude Code completed working on your task'
}).encode()
req = urllib.request.Request(
f'https://ping-api-production.up.railway.app/v1/send/{token}',
data=payload,
headers={'Content-Type': 'application/json'}
)
try:
urllib.request.urlopen(req, timeout=5)
except Exception:
pass
if __name__ == '__main__':
send_notification()For detailed documentation, see the Claude Code Hooks Guide in the Ping repository.