Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Hook Event Architecture

ASecurity

Design hook-based event systems for ADW observability. Use when implementing real-time event broadcasting, creating hook pipelines, or building agent activity monitoring.

13 stars
0 votes
0 copies
0 views
Added 2/9/2026
devopspythonsqldatabaseperformancedocumentation

Works with

claude codecli

Security Analysis

A100/100

Scanned 2/12/2026

$npx -y skills add melodic-software/claude-code-plugins --skill hook-event-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Hook Event Architecture?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Hook Event Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/melodic-software-hook-event-architecture/badge)](https://www.skillsdirectory.com/skills/melodic-software-hook-event-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: hook-event-architecture
description: Design hook-based event systems for ADW observability. Use when implementing real-time event broadcasting, creating hook pipelines, or building agent activity monitoring.
allowed-tools: Read, Grep, Glob
---

# Hook Event Architecture

Design hook-based event systems for capturing and broadcasting agent activities in AI Developer Workflows.

## MANDATORY: docs-management Delegation

> **Documentation Verification:** This skill references Claude Code hook events and configuration
> that may change between releases. Before implementing, invoke `hook-management` skill to verify
> current event types and hook configuration patterns.

**Verification Checkpoint:**

- [ ] Did I invoke `hook-management` for current event types?
- [ ] Did official documentation confirm the event schema?
- [ ] Is my implementation based on official docs?

## When to Use

- Implementing real-time event broadcasting
- Building observability infrastructure
- Creating swimlane visualizations
- Logging agent activities to database
- Generating AI-powered event summaries

## Prerequisites

- Understanding of Claude Code hooks (@hook-event-patterns.md)
- Familiarity with WebSocket patterns (@websocket-architecture.md)
- Access to Claude Agent SDK for full implementation

## SDK Requirement

> **Implementation Note**: Full hook event architecture requires Claude Agent SDK with custom tooling. This skill provides design patterns and specifications.

## Event Types

> **Documentation Verification:** The event types listed here are Claude Code internal types that may change between releases. For authoritative current event types, query the `hook-management` skill which delegates to `docs-management` for official documentation.

ADW systems capture these event types:

| Event Type | Icon | Source | Payload |
| --- | --- | --- | --- |
| `PreToolUse` | 🪝 | Hook | Tool name, inputs, session |
| `PostToolUse` | 🪝 | Hook | Tool name, outputs, duration |
| `TextBlock` | 💬 | Agent | Response text, tokens |
| `ToolUseBlock` | 🛠️ | Agent | Tool invocation record |
| `ThinkingBlock` | 🧠 | Agent | Extended thinking content |
| `StepStart` | ⚙️ | System | Step name, inputs |
| `StepEnd` | ⚙️ | System | Step name, outputs, duration |

## Architecture Design Process

### Step 1: Define Event Schema

Create Pydantic models for events:

```python
class ADWEvent(BaseModel):
    type: str                    # Event type from table
    adw_id: str                  # 8-char correlation ID
    step: str                    # Current step name
    timestamp: datetime
    payload: dict                # Type-specific data
    summary: str | None          # AI-generated summary
```

### Step 2: Configure Hook Triggers

Set up Claude Code hooks:

```json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": ".*",
      "command": "python hooks/pre_tool.py"
    }],
    "PostToolUse": [{
      "matcher": ".*",
      "command": "python hooks/post_tool.py"
    }]
  }
}
```

### Step 3: Design Event Pipeline

```text
Agent Execution
      │
      ├── PreToolUse ──► Hook Script ──┬── Log to DB
      │                                ├── Summarize (Haiku)
      ▼                                └── Broadcast (WebSocket)
Tool Execution
      │
      ├── PostToolUse ──► Hook Script ──┬── Log to DB
      │                                  ├── Summarize (Haiku)
      ▼                                  └── Broadcast (WebSocket)
Continue...
```

### Step 4: Implement Summarization

AI-generated event summaries using Haiku:

```python
async def summarize_event(event: ADWEvent) -> str:
    prompt = f"""Summarize in 15 words or less:
    Event: {event.type}
    Tool: {event.payload.get('tool_name', 'N/A')}
    Data: {str(event.payload)[:500]}
    """
    return await claude.complete(prompt, model="haiku")
```

### Step 5: Design Broadcast Pattern

Event distribution to clients:

```python
class EventBroadcaster:
    def __init__(self, ws_manager, db_client):
        self.ws = ws_manager
        self.db = db_client

    async def broadcast(self, event: ADWEvent):
        # Log to database first
        await self.db.log_event(event)

        # Broadcast to WebSocket clients
        await self.ws.broadcast(event.dict())
```

## Hook Script Templates

### PreToolUse Hook

```python
#!/usr/bin/env python
import sys, json, asyncio
from adw_modules import broadcast, summarize

async def main():
    data = json.load(sys.stdin)

    event = {
        "type": "PreToolUse",
        "adw_id": data.get("adw_id"),
        "step": data.get("step"),
        "payload": {
            "tool_name": data["tool_name"],
            "tool_input": data["tool_input"]
        }
    }

    event["summary"] = await summarize(event)
    await broadcast(event)

if __name__ == "__main__":
    asyncio.run(main())
```

### PostToolUse Hook

```python
#!/usr/bin/env python
import sys, json, asyncio
from adw_modules import broadcast, summarize

async def main():
    data = json.load(sys.stdin)

    event = {
        "type": "PostToolUse",
        "adw_id": data.get("adw_id"),
        "step": data.get("step"),
        "payload": {
            "tool_name": data["tool_name"],
            "tool_output": data.get("tool_output", "")[:1000],
            "duration_ms": data.get("duration_ms", 0)
        }
    }

    event["summary"] = await summarize(event)
    await broadcast(event)

if __name__ == "__main__":
    asyncio.run(main())
```

## Output Format

When designing hook event architecture:

```markdown
## Hook Event Architecture Design

### Event Types

| Type | Trigger | Payload Schema |
| --- | --- | --- |
| [type] | [when triggered] | [fields] |

### Hook Configuration

```json
[hooks.json configuration]
```

### Event Pipeline

```text
[ASCII diagram of flow]
```

### Summarization Strategy

[How Haiku generates summaries]

### Broadcasting Pattern

[WebSocket or other broadcast mechanism]

### Database Schema

```sql
[Event logging tables]
```

### Implementation Checklist

- [ ] [Step 1]
- [ ] [Step 2]
...

``` <!-- markdownlint-disable-line MD040 -->

## Design Checklist

- [ ] Event types defined with payloads
- [ ] Hook configuration specified
- [ ] Event pipeline documented
- [ ] Summarization prompt designed
- [ ] Broadcast mechanism chosen
- [ ] Database schema defined
- [ ] Error handling considered
- [ ] Performance implications assessed

## Anti-Patterns

| Anti-Pattern | Problem | Solution |
| --- | --- | --- |
| Sync broadcasting | Blocks agent execution | Async dispatch |
| No correlation ID | Can't trace workflows | Use adw_id |
| Raw payload logging | Token waste | Truncate large data |
| Missing summaries | Hard to scan | Always summarize |
| No error handling | Silent failures | Log and recover |

## Cross-References

- @hook-event-patterns.md - Event type details
- @websocket-architecture.md - Broadcasting patterns
- @production-patterns.md - Database logging
- @adw-framework.md - ADW overview

## Version History

- **v1.0.0** (2026-01-01): Initial release (Lesson 14)

---

## Last Updated

**Date:** 2026-01-01
**Model:** claude-opus-4-5-20251101

Attribution

melodic-softwaremelodic-software
View sourceSee grades on GitHubMore from melodic-software →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Terraform Module Library

Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.

401991 votes

sematext-otel

Wire a service's OpenTelemetry output to Sematext Cloud. Walks through region, App-type, instrumentation flow (managed OTLP endpoint vs Sematext Agent), and signal selection (traces/metrics/logs), then produces the exact env-var block and points at a runnable reference example in this repo. Invoke when instrumenting a new app for Sematext.

01 votes

Deployment Patterns

Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up deployment infrastructure or planning releases.

2699140 votes

Babysit

Watch a pull request or review cycle until it is ready to merge. Use when asked to babysit, monitor, or keep checking PR comments, reviews, and CI until all actionable issues are resolved.

971540 votes

V7 Roster

Interact with the Paperclip control plane API for task coordination and governance. Use when checking assignments, updating issue status, posting comments, delegating work, managing routines, or calling Paperclip API endpoints.

953190 votes
View all in devops →