Session Status
Reports current Claude Code session elapsed time.
Mechanism
A SessionStart hook writes $(date +%s) to a file inside the plugin directory and exports CLAUDE_SESSION_FILE via CLAUDE_ENV_FILE. The session ID is stable across compaction, so the timestamp survives context resets. A SessionEnd hook cleans up.
Usage
Run this to get session elapsed time:
bash
start=$(cat "$CLAUDE_SESSION_FILE" 2>/dev/null)
if [ -n "$start" ]; then
now=$(date +%s)
elapsed=$((now - start))
hours=$((elapsed / 3600))
minutes=$(((elapsed % 3600) / 60))
started=$(date -r "$start" "+%H:%M" 2>/dev/null || date -d "@$start" "+%H:%M" 2>/dev/null)
if [ $hours -gt 0 ]; then
echo "Session: ${hours}h ${minutes}m (started at ${started})"
else
echo "Session: ${minutes}m (started at ${started})"
fi
else
echo "Session file not found - hook may not be configured"
fi
Output Format
Display to user:
code
Session: 2h 15m (started at 14:30)
If file missing, inform: session tracking hook not configured.