Discord Detailed Trigger
Comprehensive hook designed for send, detailed, discord, notifications. Includes structured workflows, validation checks, and reusable patterns for automation.
Discord Detailed Trigger
Sends rich Discord embed notifications with session information, duration tracking, and project context when Claude Code sessions start and stop.
When to Use This Hook
Attach this hook when you need to:
- Track Claude Code session activity across your team with rich Discord notifications including project name, duration, and memory usage
- Monitor remote or long-running coding sessions by receiving start and completion alerts in a shared Discord channel
- Build a team activity feed showing who is working on which projects and for how long using Discord as the notification hub
Consider alternatives when:
- Your team uses Slack as the primary communication platform and would benefit from Slack-native formatting with Block Kit
- You need persistent session analytics with querying and filtering capabilities that exceed what Discord message history provides
Quick Start
Configuration
name: discord-detailed-trigger type: hook trigger: SessionStart, Stop category: automation
Example Trigger
claude # Session starts, hook fires: # Discord embed sent: "Claude Code Session Started" # On exit: # Discord embed sent: "Claude Code Session Completed"
Example Output
Discord Notification Sent:
Embed: Claude Code Session Started
Fields:
Project: my-web-app
Time: 14:23:07
Date: 2026-03-15
[On session end]
Discord Notification Sent:
Embed: Claude Code Session Completed
Fields:
Project: my-web-app
Duration: 47m 23s
Memory Used: 128MB
Finished: 15:10:30
Date: 2026-03-15
Core Concepts
Discord Notification Overview
| Aspect | Details |
|---|---|
| Notification Method | Discord Webhook API with rich embed formatting |
| Events Tracked | SessionStart (session begins) and Stop (session ends) |
| Data Captured | Project directory, timestamps, session duration, memory usage |
| Duration Tracking | Start time saved to ~/.claude/session_start.tmp for duration calculation |
| Embed Colors | Blue (3447003) for session start, Green (5763719) for session completion |
| Requirement | DISCORD_WEBHOOK_URL environment variable must be set |
Notification Workflow
Session Start
|
v
[Save timestamp to ~/.claude/session_start.tmp]
|
v
[Build embed JSON with project info]
|
v
[POST to DISCORD_WEBHOOK_URL] --> Discord Channel
|
... (coding session) ...
|
Session Stop
|
v
[Calculate duration from saved timestamp]
|
v
[Capture memory usage from process stats]
|
v
[Build completion embed with all metrics]
|
v
[POST to DISCORD_WEBHOOK_URL] --> Discord Channel
|
v
[Cleanup: remove session_start.tmp]
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
DISCORD_WEBHOOK_URL | string | (required) | Full Discord webhook URL created from Server Settings > Integrations > Webhooks |
embed_color_start | integer | 3447003 | Decimal color code for the session start embed sidebar |
embed_color_stop | integer | 5763719 | Decimal color code for the session completion embed sidebar |
include_memory | boolean | true | Whether to capture and report process memory usage in the completion embed |
temp_file_path | string | ~/.claude/session_start.tmp | Location for the temporary file storing session start timestamp |
Best Practices
-
Create a dedicated Discord channel for notifications - Separate Claude Code notifications from general team chat to keep the activity feed clean and searchable. Name the channel something descriptive like
#claude-sessionsso team members can subscribe or mute based on their interest level. -
Use thread-aware webhooks for busy teams - In teams with many developers, individual session notifications can overwhelm a channel. Consider configuring Discord's thread feature or using a bot that groups notifications by developer to maintain readability.
-
Protect your webhook URL as a secret - Discord webhook URLs grant posting access to your channel without authentication. Store the URL in a secure environment variable and never commit it to version control. Rotate the webhook if it is accidentally exposed.
-
Monitor the temp file for stale sessions - If Claude Code crashes without triggering the Stop hook, the
session_start.tmpfile persists with a stale timestamp. The next session will calculate an incorrect duration. Consider adding a SessionStart cleanup step that detects and removes stale temp files older than 24 hours. -
Customize embed colors for visual scanning - The default blue and green colors work well, but teams working across multiple projects can assign different color codes per project. This makes it easy to visually scan the Discord channel and identify which project each notification belongs to.
Common Issues
-
No notifications appearing in Discord - Verify the
DISCORD_WEBHOOK_URLenvironment variable is set correctly by runningecho $DISCORD_WEBHOOK_URLin your terminal. Ensure the URL starts withhttps://discord.com/api/webhooks/and that the webhook has not been deleted from the Discord server settings. -
Duration shows as Unknown on session end - This happens when the
session_start.tmpfile is missing, typically because the SessionStart hook failed silently or the file was cleaned up by another process. Check that~/.claude/directory exists and is writable, and verify the SessionStart hook runs without errors. -
Memory usage reports N/A - The memory calculation uses
ps -o rss=which may behave differently across operating systems. On some Linux distributions, the process ID may not match the expected shell process. Test the memory command manually to confirm it returns a value on your system.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Pre-Commit Security Scanner
Pre-commit hook that scans staged files for hardcoded secrets, API keys, passwords, and sensitive data patterns before allowing commits.
Agents Md Watcher
Streamline your workflow with this automatically, loads, agents, configuration. Includes structured workflows, validation checks, and reusable patterns for automation.
Automated Build Inspector
Boost productivity using this automatically, trigger, build, processes. Includes structured workflows, validation checks, and reusable patterns for automation.