event-listeners

event-listeners is a skill for Claude Code, Codex from Softtor/nestjs-hexagonal. It costs 75 tokens per session (3,297 once invoked), scanned A, original, MIT.

A guide for creating event listeners that react to domain events, such as updating a projection, invalidating a cache, sending an email, or publishing a message. It explains where listeners belong and when they are unnecessary.

In plain words
What is it for?
Use it when designing or implementing listeners for projections, audits, caches, cross-context commands, WebSocket broadcasts, RabbitMQ messages, emails, or webhooks.
Why use it?
It helps avoid putting side effects in the wrong layer or creating extra listener code for simple cases. It distinguishes reactions inside one bounded context, between contexts, and outside the application.

Skill for Claude CodeCodex

Part of the nestjs-hexagonal plugin — 10 skills, 8 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/softtor/nestjs-hexagonal/event-listeners
Any agent
npx skills add Softtor/nestjs-hexagonal --skill event-listeners
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal

Made for: Claude Code, Codex.

Or install nestjs-hexagonal, the plugin that ships this one along with the rest of its 10 skills, 8 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for event-listeners

README.md
[![agentmods](https://agentmods.dev/badge/skills/softtor/nestjs-hexagonal/event-listeners.svg)](https://agentmods.dev/skills/softtor/nestjs-hexagonal/event-listeners)
Your own site
<a href="https://agentmods.dev/skills/softtor/nestjs-hexagonal/event-listeners"><img src="https://agentmods.dev/badge/skills/softtor/nestjs-hexagonal/event-listeners.svg" alt="Measured on agentmods" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,297 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00075 $0.03297
Opus 5 $0.00037 $0.01648
Sonnet 5 $0.00015 $0.00659
Haiku 4.5 $0.00007 $0.00330

Measured 4d ago against content hash 2bcd8ae4e332, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

event-listeners scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/event-listeners/SKILL.md · 445 lines

How it starts

The opening of the file, as written. The whole thing — 445 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Event Listeners

Domain events emitted via entity.commit() flow through the NestJS CQRS EventBus. Listeners are @EventsHandler classes that react to these events. Multiple handlers for the same event run in parallel via Promise.allSettled — if one fails, others continue.

This skill covers WHERE listeners live, WHAT they do, and WHEN you actually need one.


Decision Tree

Do you need to react to a domain event?
│
├─ Is it a side effect within the SAME bounded context?
│  └─ YES → Same-BC Listener (see Section 1)
│     Examples: update Redis projection, write audit log, invalidate cache
│
├─ Does ANOTHER bounded context need to react?
│  └─ YES → Cross-BC Listener (see Section 2)
│     Examples: Billing creates invoice when Order is created
│
├─ Does the event need to leave the process?
│  └─ YES → Bridge Listener (see Section 3)
│     Examples: WebSocket broadcast, RabbitMQ publish, send email, call webhook
│
└─ Is the side effect simple and only 1 consumer exists?
   └─ YES → Consider putting it in the command handler directly (no listener needed)

When NOT to Create a Listener (anti-over-engineering)

Situation Do this instead
Only 1 side effect, simple and synchronous Put it in the command handler after entity.commit()
Side effect is part of the core business transaction Keep it in the use case / handler — not a separate listener
< 2 consumers for the event Question whether you need the event at all
Event payload identical to what listener would emit Emit directly from handler, skip intermediate event

Principle: Events are for decoupling. If there's nothing to decouple, don't add the indirection.


Section 1: Same-BC Listener

Lives in <bc>/infrastructure/listeners/. Reacts to events from its OWN bounded context.

// infrastructure/listeners/order-created-projection.handler.ts
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
import { Inject, Logger } from '@nestjs/common';

import { OrderCreatedEvent } from '../../domain/events/order-created.event';
import { REDIS_READ_MODEL_TOKEN } from '../../application/ports/read-model.port';
import type { ReadModelPort } from '../../application/ports/read-model.port';

@EventsHandler(OrderCreatedEvent)
export class OrderCreatedProjectionHandler implements IEventHandler<OrderCreatedEvent> {
  private readonly logger = new Logger(OrderCreatedProjectionHandler.name);

  constructor(
    @Inject(REDIS_READ_MODEL_TOKEN)
    private readonly readModel: ReadModelPort,
  ) {}

  async handle(event: OrderCreatedEvent): Promise<void> {
    try {
      await this.readModel.upsert(`order:${event.aggregateId}`, {
        id: event.aggregateId,
        total: event.total,
        status: event.status,
        organizationId: event.organizationId,
        updatedAt: event.occurredOn.toISOString(),
      });
    } catch (error) {
      // Log but never re-throw — don't break the event chain
      this.logger.error(`[OrderCreatedProjection] Failed:`, error);
    }
  }
}

Read the full file on GitHub · 445 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 445 lines · 75 tokens per session scan A 2bcd8ae4e332

Subscribe to this mod's changes

event-listeners is a skill published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 24d ago), licensed MIT. It adds 75 tokens to every session and 3,297 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

new-skill

Scaffold a new brooks-lint analysis skill so it passes npm run validate and npm run evals on the first try — generates skills/{name}/SKILL.md (with the mandatory "Do NOT trigger for:" clause and a Process section citing guide step ranges) plus skills/{name}/{name}-guide.md (sequentially numbered steps), then appends…

hyhmrright/brooks-lint · 145 tokens

release

Cut a brooks-lint release: set the version in package.json, propagate it across all four plugin manifests and every version-bearing text file (README badges, docs site metadata), write the CHANGELOG entry, validate, then commit, push, tag, and publish the GitHub release. Triggers when the maintainer asks to "release"…

hyhmrright/brooks-lint · 135 tokens

brooks-audit

Architecture audit that maps module dependencies, checks layering integrity, and flags structural decay across a codebase, drawing on twelve classic engineering books. Triggers when: user asks to audit architecture, review folder/module structure, check for circular imports, understand how the codebase is organized…

hyhmrright/brooks-lint · 143 tokens

brooks-sweep

Full-sweep mode: runs a unified analysis across all quality dimensions — code decay, architecture, tech debt, and test quality — then applies fixes directly to the codebase. Safe changes are auto-applied; risky changes are confirmed before execution. Drawing on twelve classic engineering books. Triggers when: user…

hyhmrright/brooks-lint · 178 tokens

brooks-debt

Tech debt assessment that identifies, classifies, and prioritizes maintainability problems — helping teams build a refactoring roadmap — drawing on twelve classic engineering books. Triggers when: user asks about tech debt, refactoring priorities, what to clean up first, or asks "why is this so hard to change?", "what…

hyhmrright/brooks-lint · 131 tokens

brooks-review

PR code review that surfaces decay risks, design smells, and maintainability issues with concrete Symptom → Source → Consequence → Remedy findings, drawing on twelve classic engineering books. Triggers when: user asks to review code, check a PR, shares a diff or pastes code asking "does this look right?" / "any issues…

hyhmrright/brooks-lint · 172 tokens