CClaude Code Catalog
All Hooks

Agent Observability Logger

NotificationIntermediateHook Type: notification

Agent Observability Logger captures every tool invocation, notification, and session event into a structured JSONL log file. Each entry includes the timestamp, tool name, input summary, output status, and token usage. This creates a complete audit trail that helps you understand what Claude did during a session, debug unexpected behavior, track patterns over time, and satisfy compliance requirements. Logs rotate daily and can be forwarded to any observability platform.

loggingauditobservabilitydebuggingcompliance

Hook Code

#!/bin/bash # Agent Observability Logger Hook # Logs all Claude Code actions to structured JSONL LOG_DIR="${HOME}/.claude/logs" LOG_FILE="$LOG_DIR/agent-$(date +%Y-%m-%d).jsonl" mkdir -p "$LOG_DIR" TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") SESSION_ID="${CLAUDE_SESSION_ID:-unknown}" # Build structured log entry LOG_ENTRY=$(jq -n --arg ts "$TIMESTAMP" --arg session "$SESSION_ID" --arg tool "$TOOL_NAME" --arg event "$EVENT_TYPE" --arg input "$TOOL_INPUT" --arg output "$TOOL_OUTPUT" '{ timestamp: $ts, session_id: $session, tool: $tool, event: $event, input_preview: ($input | if length > 200 then .[:200] + "..." else . end), output_preview: ($output | if length > 200 then .[:200] + "..." else . end) }') echo "$LOG_ENTRY" >> "$LOG_FILE" # Rotate logs older than 30 days find "$LOG_DIR" -name "agent-*.jsonl" -mtime +30 -delete 2>/dev/null exit 0

Add this hook to your Claude Code settings or .claude/settings.json to activate.

Terminal Preview

Agent Observability Logger

About Agent Observability Logger

Claude Code hooks let you run custom shell commands automatically in response to specific events during Claude's operation. Agent Observability Logger is a Notification hook at the Intermediate level that automates tasks at key moments in your development workflow, reducing manual steps and enforcing consistency across your team.

Related Hooks