📲

Auto-notify Slack/Discord when using Claude Code on Mobile

に公開

Recently, mobile vibe coding with Claude Code has been trending. I also use my iPad or iPhone to remotely connect to my home PC for vibe coding.

However, when vibe coding on mobile, what I want to know is when the AI completes its work.

On PC, there are various options like system notifications, audio alerts, etc., but with mobile remote connection, it’s challenging.

So I want to send notifications to Discord/Slack when tasks are completed!

Setting up Webhooks

First, let’s prepare to receive notifications.

For Discord

  1. Open the Discord server where you want to send notifications
  2. Click “Server Settings” from the menu
  3. Go to “Integrations” → “Webhooks”
  4. Create a “New Webhook”
  5. Set a name (e.g., “Claude Code”) and select a channel
  6. “Copy Webhook URL”

For Slack

  1. In your Slack workspace, go to “Apps” → “Add Apps”
  2. Search for and add “Incoming Webhooks”
  3. Select the channel where you want to send notifications
  4. Click “Add Incoming Webhook Integration”
  5. Copy the Webhook URL

Creating the notification script

1. Create folder

Navigate to your working folder and create a folder to save the script (optional)

mkdir -p scripts/claude-code/

2. Create notification script

For Discord notifications

cat > scripts/claude-code/notify-completion-with-message.sh << 'EOF'
#!/bin/bash
MESSAGE="$1"
curl -H "Content-Type: application/json" -X POST -d "{\"content\":\"${MESSAGE}\"}" "https://discord.com/api/webhooks/YOUR_WEBHOOK_URL_HERE"
EOF

Replace YOUR_WEBHOOK_URL_HERE with the Webhook URL you obtained.

For Slack notifications

cat > scripts/claude-code/notify-completion-slack.sh << 'EOF'
#!/bin/bash
MESSAGE="$1"
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${MESSAGE}\"}" "https://hooks.slack.com/services/YOUR_SLACK_WEBHOOK_URL_HERE"
EOF

Discord and Slack basically work the same way, with just slight differences in the Webhook URL and JSON format. You can choose based on the tools your team uses.

Script-based “workaround”

Actually, this method doesn’t directly permit curl commands, but instead creates script files and permits those scripts. This way, approval prompts won’t appear during auto-accept.

Permission settings in Claude Code

This is the key point.

  1. After starting Claude Code, type /allowed-tools
  2. Select “1. Add a new rule…”
  3. Enter the following:
Bash(scripts/claude-code/notify-completion-with-message.sh*)

Now this script can be executed without approval.

CLAUDE.md instruction settings

Create a CLAUDE.md file in your project’s root directory and add the following instruction. This will make Claude Code automatically send notifications when tasks are completed.

# End-of-task instructions

- When completing a task, always execute the following:
  `bash scripts/claude-code/notify-completion-with-message.sh "description of completed task"`

Just adding this one line will make Claude Code automatically send notifications to Discord every time it finishes work.

Testing it out

Give some work instructions and enable auto-accept. After the work is completed, notifications will be sent to Discord.

It was a surprisingly simple solution, but these small improvements accumulate to make daily work much more comfortable.

Discussion