handler-go

Implements Go domain and integration event handlers with mediator registration and idempotency patterns.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill handler-go-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: handler-go
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/handler/go
Command: npx skills add https://github.com/gabriellst/codm --skill handler-go-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing event handlers in a Go DDD/CQRS codebase involves subtle conventions — choosing the right mediator interface, registering handlers correctly in module.go, and surviving outbox retries — and mistakes silently break event delivery or create duplicate state. ## Core Features & Use Cases - Domain event handlers: Implements the DomainEventHandler interface for internal side effects like logging or publishing integration events via the ExternalMediator. - Integration event handlers: Implements the IntegrationEventHandler interface to consume cross-service events and delegate to use cases. - Registration and safety rules: Enforces fx.Invoke registration in module.go, compile-time interface checks, idempotency guards, and error-swallowing rules for non-critical handlers. - Use Case: When a video.uploaded integration event arrives from another service, generate an EnqueueTranscodingJobHandler that unmarshals the wire payload, calls the StartTranscodingJob use case, and registers with the ExternalMediator. ## Quick Start Ask the agent to create a Go event handler for a specific domain or integration event in a bounded context, following the handler skill conventions.

Frequently Asked Questions about handler-go

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a domain event handler in Go?

Implement the mediator.DomainEventHandler interface with EventName() returning the event constant and Handle() unmarshaling the payload via types.UnmarshalDomainEvent. Add a compile-time interface check and register the handler with the InternalMediator in module.go.

How do I consume an integration event from another service in Go?

Implement the IntegrationEventHandler interface, unmarshal the event with UnmarshalIntegrationEvent using the wire type from contracts-go, and delegate to a use case. Register it with the ExternalMediator via ext.Register in module.go.

What is the difference between InternalMediator and ExternalMediator registration?

InternalMediator delivers domain events raised within the same bounded context, while ExternalMediator delivers integration events arriving from other services. Registering an integration handler with the InternalMediator means it never receives events.

Why must Go event handlers be idempotent?

The outbox can re-deliver an event on retry, so a handler may run multiple times for the same event. Guard state-changing operations by checking whether the entity already exists and returning nil to skip duplicates.

Should a failing handler return an error or swallow it?

Critical handlers affecting data consistency should return the error so the outbox retries. Non-critical handlers like notifications should log the error with slog and return nil so they do not block the event chain.