S

Slack Detailed Notifications Verifier

All-in-one hook covering send, detailed, slack, notifications. Includes structured workflows, validation checks, and reusable patterns for automation.

HookClipticsautomationv1.0.0MIT
0 views0 copies

Slack Detailed Notifications Verifier

Sends rich Slack Block Kit notifications with session lifecycle tracking, duration metrics, and system diagnostics when sessions start and stop.

When to Use This Hook

Attach this hook when you need to:

  • Track Claude Code session activity across your engineering team with structured Slack messages using Block Kit formatting
  • Monitor session durations and resource consumption to identify patterns in development productivity and tool usage
  • Maintain a searchable Slack history of all coding sessions with project attribution for team visibility and coordination

Consider alternatives when:

  • Your team primarily uses Discord or Microsoft Teams and would benefit from native notification formatting on those platforms
  • You need real-time streaming updates during sessions rather than point-in-time start and stop notifications

Quick Start

Configuration

name: slack-detailed-notifications-verifier type: hook trigger: SessionStart, Stop category: automation

Example Trigger

claude # Session starts: # Slack Block Kit message sent to configured channel # On exit: # Completion message with duration and memory stats

Example Output

Slack Message - Session Started:
Header: Claude Code Session Started
Fields:
  Project: my-web-app
  Time: 14:23:07
  Date: 2026-03-15

Slack Message - Session Completed:
Header: 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

Slack Integration Overview

AspectDetails
Message FormatSlack Block Kit with header and section blocks
Events TrackedSessionStart and Stop lifecycle events
Duration TrackingTimestamp saved at start, duration calculated at stop
System MetricsProcess memory usage captured from OS process stats
AuthenticationSLACK_WEBHOOK_URL environment variable (Incoming Webhook)
Failure HandlingSilent retry with error message to stderr on delivery failure

Notification Lifecycle Workflow

Session Start
    |
    v
[Check SLACK_WEBHOOK_URL set?] --No--> [Print warning, skip]
    |
   Yes
    |
    v
[Save epoch timestamp to ~/.claude/session_start.tmp]
    |
    v
[Build Block Kit JSON: header + section fields]
    |
    v
[POST to Slack webhook] --> Slack Channel
    |
    ... (coding session) ...
    |
Session Stop
    |
    v
[Read start timestamp, calculate duration]
    |
    v
[Capture memory usage via ps command]
    |
    v
[Build completion Block Kit JSON with all metrics]
    |
    v
[POST to Slack webhook] --> Slack Channel
    |
    v
[Remove session_start.tmp]

Configuration

ParameterTypeDefaultDescription
SLACK_WEBHOOK_URLstring(required)Slack Incoming Webhook URL from your workspace app configuration
channel_overridestring(none)Override the default webhook channel for notifications
include_memorybooleantrueWhether to capture and report process memory usage at session end
temp_filestring~/.claude/session_start.tmpPath for the temporary file storing the session start timestamp
username_overridestringClaude CodeDisplay name for the bot user in Slack messages

Best Practices

  1. Create a dedicated Slack app for webhook management - Rather than using a legacy webhook, create a proper Slack app with an Incoming Webhook scope. This provides better visibility into webhook usage, allows icon and name customization, and integrates with Slack app management tools.

  2. Pin the channel for easy session history access - Pin the notification channel in your Slack workspace sidebar so team members can quickly check recent session activity without searching. The structured Block Kit format makes these messages easy to scan for specific projects or time ranges.

  3. Use the duration data for sprint retrospectives - Aggregate session durations by project and developer over a sprint period to understand time allocation patterns. This data can inform planning by revealing which projects consume the most hands-on coding time.

  4. Handle the temp file race condition - If you run multiple Claude Code sessions from the same user account, they share the session_start.tmp file. The last session to start overwrites the timestamp, causing incorrect duration for earlier sessions. Use distinct temp file names per session to avoid this.

  5. Test the webhook URL before relying on it - Run a manual curl command to POST a test message to your webhook URL before configuring the hook. This verifies the URL is correct, the channel exists, and the webhook has permission to post, avoiding silent failures during actual sessions.

Common Issues

  1. Slack messages not appearing in the expected channel - Verify the webhook URL is correct and the associated Slack app is installed in the target workspace. Check that the webhook default channel has not been archived or deleted. Test with a manual curl POST to confirm delivery.

  2. Duration shows Unknown for completed sessions - The session_start.tmp file was not created or was deleted between session start and stop. This typically happens when the SessionStart hook fails silently due to a missing ~/.claude/ directory. Create the directory with mkdir -p ~/.claude to resolve.

  3. Memory usage shows N/A on Linux containers - The ps -o rss= command may not work correctly in containerized environments where /proc is restricted. In Docker containers, use cat /proc/$$/status | grep VmRSS as an alternative memory measurement command.

Community

Reviews

Write a review

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

Similar Templates