go-kafka-consumer-reliability
Standardizes robust, fault-tolerant Kafka consumer patterns for Go services.
Install
mkdir -p .claude/skills/go-kafka-consumer-reliability && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15487" && unzip -o skill.zip -d .claude/skills/go-kafka-consumer-reliability && rm skill.zipInstalls to .claude/skills/go-kafka-consumer-reliability
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when creating, modifying, reviewing, or debugging Go services that consume Kafka, especially projection/read-model consumers, segmentio/kafka-go readers, DLQ handling, retries, offset commits, consumer groups, or idempotent event processing.Key capabilities
- →Ensure at-least-once processing for Kafka messages.
- →Implement idempotent sinks for database-backed projections.
- →Configure bounded retries for transient failures.
- →Quarantine invalid or terminally failed messages to a DLQ.
- →Expose metrics and structured logs for operational visibility.
How it works
The skill outlines a standard for Go Kafka consumers, requiring specific semantics like at-least-once processing and idempotent sinks, and provides an implementation checklist for configuring consumer groups, handling failures, and exposing metrics.
Inputs & outputs
When to use go-kafka-consumer-reliability
- →Implementing idempotent Kafka sinks
- →Configuring DLQ handling
- →Managing consumer offsets
- →Debugging Go Kafka consumer issues
About this skill
Go Kafka Consumer Reliability
This skill captures the default reliability standard for Go Kafka consumers in this repo. Apply it when a service consumes Kafka, whether the work is a new service or a change to an existing consumer.
Required Semantics
Kafka consumers must provide:
- At-least-once processing - commit offsets only after processing is durably complete, or after a terminal failure is successfully quarantined to DLQ.
- Idempotent sinks - repeated delivery of the same event must be safe. For database-backed projections, use a processed-event guard table and perform the guard insert and projection writes in the same transaction.
- Bounded retries - transient failures get retry/backoff that respects context cancellation. Retries must not loop forever or block shutdown.
- DLQ quarantine - invalid, poison, or terminally failed messages go to an explicit DLQ topic before their source offset is committed.
- Operational visibility - expose metrics and structured logs for normal processing and every failure path.
Implementation Checklist
- Configure consumer group, source topic, DLQ topic, retry attempts, retry backoff, and fetch/flush timing in
cmd/server/config.go. - Surface those values in Kubernetes ConfigMaps and compose/CI env where the service runs.
- Use
segmentio/kafka-gowith manual offset commits for consumers that mutate state. - Process a message to durable completion before calling
CommitMessages. - If processing fails with a terminal error, publish a DLQ record first, then commit the source message.
- If DLQ publish fails, do not commit the source message; leave it eligible for redelivery.
- Keep conversion/parsing logic testable as pure helpers where possible.
- Keep repository/projection writes thin and transactional.
- For projections, prevent stale or out-of-order events from regressing read models when event timestamps or versions make that possible.
- Ensure shutdown cancels fetch, retry, processing, flush, and DLQ operations cleanly.
DLQ Envelope
DLQ records should include enough context to debug and replay safely:
- source topic, partition, offset
- source key, value, headers, and timestamp
- consumer group
- error class, such as
decode,validate,process,flush, orunknown - error message
- failed timestamp
Prefer a small shared package such as go/pkg/kafkaconsumer for DLQ publishing and retry helpers when two or more services need the pattern.
Metrics
Add service-specific Prometheus metrics for:
- messages processed by outcome
- processing duration
- retry attempts and retry exhaustion
- offset commit success/failure
- duplicate/idempotency skips
- invalid or unsupported events
- DLQ publish success/failure
- batch flush success/failure and last successful flush timestamp when batching
Use bounded labels such as outcome, error class, event type, and consumer group. Do not label metrics with order IDs, message keys, offsets, or raw error strings.
Tests
Add focused tests for the reliability contract:
- DLQ publisher preserves source record details and returns writer errors.
- Retry helper eventually succeeds, stops after the configured limit, and respects context cancellation.
- Consumer commits only after successful processing.
- Consumer publishes to DLQ and commits for terminal failures.
- Consumer does not commit when DLQ publish fails.
- Repository/projection writes are idempotent for duplicate events.
- Projection writes avoid stale summary/read-model updates when ordering matters.
Run the narrow Go package tests first, then the relevant preflight before committing.
When not to use it
- →When the service does not consume Kafka.
- →When the work is not a new service or a change to an existing consumer.
- →When the application is not written in Go.
Limitations
- →Applies to Go services consuming Kafka.
- →Requires manual implementation of the checklist items.
- →Focuses on reliability, not performance optimization.
How it compares
This skill provides a structured, opinionated standard for building reliable Go Kafka consumers, ensuring consistent implementation of critical patterns like DLQ and idempotency, unlike ad-hoc development.
Compared to similar skills
go-kafka-consumer-reliability side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| go-kafka-consumer-reliability (this skill) | 0 | 3mo | No flags | Advanced |
| go-lambda-error-handling | 0 | 4mo | No flags | Advanced |
| golang-context | 0 | 2mo | Review | Intermediate |
| architecture-patterns | 55 | 2mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
go-lambda-error-handling
primolabs-org
A skill for handling errors in Go microservices on AWS Lambda.
golang-context
samber
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, c
architecture-patterns
wshobson
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use when architecting complex backend systems or refactoring existing applications for better maintainability.
workflow-orchestration-patterns
wshobson
Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.
golang-pro
sickn33
Master Go 1.21+ with modern patterns, advanced concurrency, performance optimization, and production-ready microservices. Expert in the latest Go ecosystem including generics, workspaces, and cutting-edge frameworks. Use PROACTIVELY for Go development, architecture design, or performance optimization.
go-concurrency-patterns
wshobson
Master Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.