D

Discord Detailed Trigger

Comprehensive hook designed for send, detailed, discord, notifications. Includes structured workflows, validation checks, and reusable patterns for automation.

HookClipticsautomationv1.0.0MIT
0 views0 copies

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

AspectDetails
Notification MethodDiscord Webhook API with rich embed formatting
Events TrackedSessionStart (session begins) and Stop (session ends)
Data CapturedProject directory, timestamps, session duration, memory usage
Duration TrackingStart time saved to ~/.claude/session_start.tmp for duration calculation
Embed ColorsBlue (3447003) for session start, Green (5763719) for session completion
RequirementDISCORD_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

ParameterTypeDefaultDescription
DISCORD_WEBHOOK_URLstring(required)Full Discord webhook URL created from Server Settings > Integrations > Webhooks
embed_color_startinteger3447003Decimal color code for the session start embed sidebar
embed_color_stopinteger5763719Decimal color code for the session completion embed sidebar
include_memorybooleantrueWhether to capture and report process memory usage in the completion embed
temp_file_pathstring~/.claude/session_start.tmpLocation for the temporary file storing session start timestamp

Best Practices

  1. 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-sessions so team members can subscribe or mute based on their interest level.

  2. 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.

  3. 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.

  4. Monitor the temp file for stale sessions - If Claude Code crashes without triggering the Stop hook, the session_start.tmp file 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.

  5. 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

  1. No notifications appearing in Discord - Verify the DISCORD_WEBHOOK_URL environment variable is set correctly by running echo $DISCORD_WEBHOOK_URL in your terminal. Ensure the URL starts with https://discord.com/api/webhooks/ and that the webhook has not been deleted from the Discord server settings.

  2. Duration shows as Unknown on session end - This happens when the session_start.tmp file 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.

  3. 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.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates