Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
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
  • 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

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Subscriber

ASecurity

Define a Protean subscriber - a domain element that consumes messages from external message brokers and acts as an anti-corruption layer at the domain boundary. Subscribers listen to named broker streams, receive raw dict payloads (not typed domain events), and translate external data into domain operations. Unlike event handlers which react to internal domain events, subscribers react to messages arriving from outside the bounded context via external message brokers. Use when you need to con...

45 stars
0 votes
0 copies
0 views
Added 9/20/2026
developmentpythongoreact

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add proteanhq/protean --skill subscriber --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Subscriber?

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

Security grade badge for Subscriber
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/proteanhq-subscriber/badge)](https://www.skillsdirectory.com/skills/proteanhq-subscriber)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: subscriber
description: Define a Protean subscriber - a domain element that consumes messages from external message brokers and acts as an anti-corruption layer at the domain boundary. Subscribers listen to named broker streams, receive raw dict payloads (not typed domain events), and translate external data into domain operations. Unlike event handlers which react to internal domain events, subscribers react to messages arriving from outside the bounded context via external message brokers. Use when you need to consume external webhook messages, process messages from an external broker, integrate with an external system via messaging, translate external events into domain commands, build an anti-corruption layer, or when the user asks to "create a subscriber", "add a webhook handler", "consume external events", "listen to a broker stream", "integrate with an external service", or "add an anti-corruption layer".
license: Apache-2.0
compatibility: Requires Python 3.11+, protean framework
metadata:
  author: proteanhq
  version: "0.1"
  category: element
---

# Subscriber

## How subscribers differ from event handlers

| Aspect | Event Handler | Subscriber |
|--------|--------------|------------|
| **Decorator** | `@domain.event_handler` | `@domain.subscriber` |
| **Message source** | Internal event store | External message broker |
| **Association** | `part_of` an aggregate | `stream` on a broker |
| **Payload type** | Typed domain event objects | Raw `dict` payloads |
| **Dispatch** | `@handle(EventClass)` per event type | Single `__call__(payload)` for all messages |
| **Processing config** | `event_processing` | `message_processing` |
| **Use case** | React to domain changes within bounded context | Consume messages from external systems |

## Basic structure

```python
from protean import Domain
from protean.fields import Float, Identifier, String

domain = Domain()
domain.config["message_processing"] = "sync"

@domain.aggregate
class Payment:
    order_id: Identifier(required=True)
    amount: Float(required=True)
    status: String(default="PENDING")

    def confirm(self):
        self.status = "CONFIRMED"

@domain.subscriber(stream="payment_gateway")
class PaymentConfirmationSubscriber:
    def __call__(self, payload: dict) -> None:
        order_id = payload["order_id"]
        repo = domain.repository_for(Payment)
        payment = repo._dao.find_by(order_id=order_id)
        payment.confirm()
        repo.add(payment)
```

## Key rules

1. **stream is required** - Every subscriber must specify a stream: `@domain.subscriber(stream="payment_gateway")`
2. **Implement __call__** - Subscribers receive messages via `__call__(self, payload: dict)`, not `@handle`
3. **Payload is always a raw dict** - External broker messages arrive as plain Python dicts, not typed events
4. **broker defaults to "default"** - Optionally specify broker: `@domain.subscriber(stream="...", broker="my_broker")`
5. **Use message_processing for sync mode** - `domain.config["message_processing"] = "sync"` (NOT `event_processing`)
6. **No return values** - Subscribers follow fire-and-forget, return values are discarded
7. **One subscriber per stream** - Each subscriber class handles all messages on its stream
8. **Anti-corruption layer** - Translate external schemas into domain language at the subscriber boundary

## Subscriber options

| Option | Purpose | Required |
|--------|---------|----------|
| `stream` | Name of the external broker stream to consume | Yes |
| `broker` | Broker name (defaults to `"default"`) | No |

## Quick example: Multiple subscribers

```python
@domain.subscriber(stream="payment_gateway")
class PaymentWebhookSubscriber:
    def __call__(self, payload: dict) -> None:
        if payload["status"] == "SUCCESS":
            order = domain.repository_for(Order).get(payload["order_id"])
            order.mark_paid()
            domain.repository_for(Order).add(order)

@domain.subscriber(stream="shipping_updates", broker="default")
class ShippingUpdateSubscriber:
    def __call__(self, payload: dict) -> None:
        order = domain.repository_for(Order).get(payload["order_id"])
        order.mark_shipped(payload["tracking_number"])
        domain.repository_for(Order).add(order)
```

## Quick example: Anti-corruption layer

```python
@domain.subscriber(stream="erp_user_events")
class ERPUserSubscriber:
    """Translates external ERP format into domain commands."""

    def __call__(self, payload: dict) -> None:
        if payload.get("event_type") == "user.created":
            data = payload["data"]
            command = RegisterCustomer(
                customer_id=data["userId"],
                name=f"{data['firstName']} {data['lastName']}",
                email=data["emailAddress"],
            )
            domain.process(command)
```

## Error handling

Override `handle_error` classmethod for custom error recovery during async processing:

```python
@domain.subscriber(stream="inventory_updates")
class InventorySubscriber:
    def __call__(self, payload: dict) -> None:
        # ... processing logic ...
        pass

    @classmethod
    def handle_error(cls, exc: Exception, message: dict) -> None:
        logger.error("Inventory update failed: %s", exc)
```

## Common mistakes

### Missing stream parameter

```python
@domain.subscriber  # Wrong! Missing stream
class MySubscriber:
    def __call__(self, payload: dict) -> None:
        pass
```

Instead: Always specify stream

```python
@domain.subscriber(stream="my_external_stream")  # Correct!
class MySubscriber:
    def __call__(self, payload: dict) -> None:
        pass
```

### Using @handle decorator

```python
@domain.subscriber(stream="payment_gateway")
class PaymentSubscriber:
    @handle(PaymentReceived)  # Wrong! Subscribers don't use @handle
    def on_payment(self, event):
        pass
```

Instead: Use `__call__` with raw dict payload

### Using event_processing config

```python
domain.config["event_processing"] = "sync"  # Wrong config for subscribers!
```

Instead: Use `message_processing`

```python
domain.config["message_processing"] = "sync"  # Correct!
```

### Expecting typed event objects

```python
def __call__(self, event: PaymentConfirmed) -> None:  # Wrong type!
    order_id = event.order_id
```

Instead: Always expect `dict`

```python
def __call__(self, payload: dict) -> None:  # Correct!
    order_id = payload["order_id"]
```

## Detailed references

### Core Concepts
- [Basic Subscriber](references/basic-subscriber.md) - Simple single-stream subscriber
- [Anti-corruption Layer](references/anti-corruption-layer.md) - Translating external schemas into domain commands
- [Error Handling](references/error-handling.md) - Custom error recovery with handle_error
- [Anti-patterns](references/anti-patterns.md) - Common mistakes and how to avoid them

### Complete Examples
- [Simple Subscriber](assets/subscriber_simple.py) - Basic payment confirmation subscriber
- [Domain Interaction](assets/subscriber_domain_interaction.py) - Subscriber updating aggregates through repositories
- [Multiple Streams](assets/subscriber_multiple_streams.py) - Multiple subscribers on different streams
- [Error Handling](assets/subscriber_error_handling.py) - Custom handle_error classmethod
- [Anti-corruption Layer](assets/subscriber_anti_corruption.py) - Translating external events to domain commands

### Related Skills
- `event-handler` - Compare/contrast: event handlers consume internal domain events, subscribers consume external broker messages
- `aggregate` - Subscribers often load and update aggregates through repositories
- `command` - Subscribers commonly translate external messages into domain commands
- `command-handler` - Subscribers often dispatch commands for processing

Attribution

proteanhqproteanhq
View sourceMore from proteanhq →
SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

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

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →