Slack Detailed Notifications Verifier
All-in-one hook covering send, detailed, slack, notifications. Includes structured workflows, validation checks, and reusable patterns for automation.
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
| Aspect | Details |
|---|---|
| Message Format | Slack Block Kit with header and section blocks |
| Events Tracked | SessionStart and Stop lifecycle events |
| Duration Tracking | Timestamp saved at start, duration calculated at stop |
| System Metrics | Process memory usage captured from OS process stats |
| Authentication | SLACK_WEBHOOK_URL environment variable (Incoming Webhook) |
| Failure Handling | Silent 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
| Parameter | Type | Default | Description |
|---|---|---|---|
SLACK_WEBHOOK_URL | string | (required) | Slack Incoming Webhook URL from your workspace app configuration |
channel_override | string | (none) | Override the default webhook channel for notifications |
include_memory | boolean | true | Whether to capture and report process memory usage at session end |
temp_file | string | ~/.claude/session_start.tmp | Path for the temporary file storing the session start timestamp |
username_override | string | Claude Code | Display name for the bot user in Slack messages |
Best Practices
-
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.
-
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.
-
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.
-
Handle the temp file race condition - If you run multiple Claude Code sessions from the same user account, they share the
session_start.tmpfile. The last session to start overwrites the timestamp, causing incorrect duration for earlier sessions. Use distinct temp file names per session to avoid this. -
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
-
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.
-
Duration shows Unknown for completed sessions - The
session_start.tmpfile 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 withmkdir -p ~/.claudeto resolve. -
Memory usage shows N/A on Linux containers - The
ps -o rss=command may not work correctly in containerized environments where/procis restricted. In Docker containers, usecat /proc/$$/status | grep VmRSSas an alternative memory measurement command.
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.