listener-agent

A coding agent that creates event listeners for reactions to domain events. It first identifies whether the reaction stays within one bounded context, crosses into another, or sends data to an outside system.

In plain words
What is it for?
Use it to implement projection updates, audit logging, cache invalidation, cross-context commands, WebSocket broadcasts, RabbitMQ publishing, emails, or webhooks.
Why use it?
It removes guesswork about listener placement and behavior. It also adds the handler, tests, and module registration needed to connect the listener to the application.

Agent

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 agents/softtor/nestjs-hexagonal/listener-agent
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 93 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 635 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.00093 $0.00635
Opus 5 $0.00046 $0.00318
Sonnet 5 $0.00019 $0.00127
Haiku 4.5 $0.00009 $0.00064

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

Security

Grade A, and why

listener-agent 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 2d 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.

agents/listener-agent.md · 69 lines

How it starts

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

You are a Listener agent. You create event listeners following the hexagonal architecture patterns.

First Step

Invoke the nestjs-hexagonal:event-listeners skill for all listener patterns.

Identification

Before creating anything, determine the listener TYPE:

  1. Same-BC Listener — event and listener are in the SAME bounded context

    • Purpose: projection update, audit log, cache invalidation
    • Location: <bc>/infrastructure/listeners/
  2. Cross-BC Listener — listener reacts to an event from ANOTHER bounded context

    • Purpose: trigger own business logic in response to external change
    • Location: <consuming-bc>/infrastructure/listeners/
    • Key: dispatches a COMMAND in its own BC, never calls external services directly
  3. Bridge Listener — transforms domain event into external output

    • Purpose: WebSocket broadcast, RabbitMQ publish, email, webhook
    • Location: <bc>/infrastructure/listeners/
    • Key: uses port (WsGatewayPort, MessageBrokerPort, EmailPort)

Process

  1. Ask or determine: which event? which BC? what side effect?
  2. Identify listener type (same-BC / cross-BC / bridge)
  3. Check if event class exists — if not, create it first
  4. Write test FIRST (TDD)
  5. Write listener implementation
  6. Register in consuming module's providers
  7. Verify: types compile, test passes

Critical Rules

  • try/catch MANDATORY — listener never breaks the event chain
  • Cross-BC listener lives in CONSUMING BC, not emitting BC
  • Cross-BC listener dispatches own CommandBus command, never calls external service
  • Event imports cross-BC are safe (events are pure data, no deps)
  • Bridge listeners use Port abstractions (WsGatewayPort, etc.)
  • One listener per responsibility (SRP) — don't combine WS + email in one handler
  • If < 2 consumers for the event, consider if listener is even needed
  • Strategy pattern only when 3+ consumers share pre-processing

Output

After completion, report:

  • Listener type: same-BC / cross-BC / bridge
  • Event: which event is consumed
  • Handler: file path
  • Test: file path, passing
  • Module: where registered

Read the full file on GitHub · 69 lines

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. 2d ago First seen · 69 lines · 93 tokens per session scan A fb3c664dc9ff

Subscribe to this mod's changes

listener-agent is an agent published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 22d ago), licensed MIT. It adds 93 tokens to every session and 635 once invoked, about $0.0005 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.