/claude-kit:kafka-config-drivenfrom Claude Kit SDLC
Config-driven Kafka consumer/producer patterns for Python services: topic-to-handler routing, idempotent producers, SASL_SSL+GSSAPI Kerberos auth, and eventbridge wrapper.
Ships in Claude Kit SDLC. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Config-driven Kafka consumer and producer implementation patterns derived from production Python/FastAPI services.
services/kafka/ with consumer/producer splitservices/kafka/ with consumer/ and producer/ subdirectories.services/kafka/consumer/config.py and producer config in services/kafka/producer/config.py.services/kafka/constants.py.service_name, deserialization_format, consumer_config, topics_configurations, optional async_kafka, and optional custom_commit_offset.topics_configurations as { topic_name: { "tasks": [handler_fn] } } for per-message processing or { topic_name: { "batch_tasks": [handler_fn] } } for batch processing.enable_auto_commit: False in consumer_config for manual offset management.custom_commit_offset: "pre" to commit before processing (at-most-once) or omit/set "post" for after-processing commit (at-least-once).bootstrap_servers) and confluent-kafka (dot keys like bootstrap.servers) config styles.KAFKA_COMMON_PRODUCER_CONFIG with service_name and producer_config containing bootstrap_servers, enable_idempotence: True, and acks: "all" for exactly-once semantics.retries and socket.timeout.ms in producer_config for resilience.compression_type: "gzip" to reduce network overhead.eventbridge.emitter.AsyncEventEmitter in a Singleton class AsyncEventBridge to manage producer lifecycle.get_event_emitter() method to lazily initialize the AsyncEventEmitter with producer settings.AsyncEventEmitter API methods like add_event_to_queue(topics, partition_value, event, event_meta, serialization_format, hash_flag, callback, headers) and emit_events() to queue and flush events.get_consumer_config()[CONSUMER_NAME] where CONSUMER_NAME comes from environment or config.kafka.KafkaConsumer (as SyncKafkaConsumer) with explicit auth params, subscribe to topics, poll in a loop, dispatch to handlers from topics_configurations[topic]["tasks"] or accumulate for ["batch_tasks"], then manually call consumer.commit() after handlers succeed.eventbridge.consumer.setup_and_start_consumer(settings) which handles the poll/dispatch/commit loop internally.asyncio.gather(consumer, healthz, readyz).ssl.create_default_context(cafile=CA_PEM_PATH), load client cert with load_cert_chain(certfile=CERT_PEM, keyfile=KEY_FILE).check_hostname=False and verify_mode=ssl.CERT_NONE for internal networks with self-signed CAs. This is insecure for production — prefer adding your internal CA to the system trust store and enabling full TLS verification, or use properly-issued certificates with correct SANs.security_protocol: "SASL_SSL", sasl_mechanism: "GSSAPI", sasl_kerberos_service_name: "kafka", and ssl_context.chmod 0o600.krb5.conf to strip includedir, inject KDC hosts from config, switch ccache from KEYRING to FILE, set KRB5_CONFIG env var, and run kinit -kt <keytab> <principal>.docker_config.loaded_config -> constants.py (offset reset, session timeout, topic names) -> consumer/config.py (the config map) -> consumer.py (bootstrap).auto_offset_reset (earliest/latest) from constants; set enable_auto_commit: False and manually commit after successful processing.deserialization_format or KAFKA_SERIALIZATION_FORMAT (typically "JSON") to control message deserialization.kafka.errors.CommitFailedError after batch processing; log and continue (partition reassigned, messages will be reprocessed).# services/kafka/constants.py
from config.docker_config import loaded_config
KAFKA_OFFSET_RESET_STRATEGY = "earliest"
KAFKA_SESSION_TIMEOUT_IN_MS = 30000
KAFKA_SERIALIZATION_FORMAT = "JSON"
CONSUMER_TOPIC = "my-topic"
# services/kafka/consumer/config.py
from services.kafka.constants import KAFKA_OFFSET_RESET_STRATEGY, KAFKA_SERIALIZATION_FORMAT
from my_module.handlers import process_message
def get_consumer_config():
return {
"my_consumer": {
"service_name": "my_service",
"deserialization_format": KAFKA_SERIALIZATION_FORMAT,
"consumer_config": {
"bootstrap_servers": loaded_config.KAFKA_BROKERS,
"group_id": "my_consumer_group",
"auto_offset_reset": KAFKA_OFFSET_RESET_STRATEGY,
"enable_auto_commit": False,
"session_timeout_ms": 30000,
},
"topics_configurations": {
"my-topic": {"tasks": [process_message]}
},
"async_kafka": True,
"custom_commit_offset": "pre",
}
}
# services/kafka/consumer/consumer.py (async pattern, eventbridge)
import asyncio
from eventbridge.consumer import setup_and_start_consumer
from services.kafka.consumer.config import get_consumer_config
async def main():
consumer_name = "my_consumer"
config = get_consumer_config()[consumer_name]
await setup_and_start_consumer(config)
# services/kafka/producer/config.py
KAFKA_COMMON_PRODUCER_CONFIG = {
"service_name": "my_service",
"producer_config": {
"bootstrap_servers": loaded_config.KAFKA_BROKERS,
"enable_idempotence": True,
"acks": "all",
},
}
# services/kafka/producer/producer.py (eventbridge wrapper)
from eventbridge.emitter import AsyncEventEmitter
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]
class AsyncEventBridge(metaclass=Singleton):
async def get_event_emitter(self):
if not hasattr(self, "event_emitter"):
from services.kafka.producer.config import KAFKA_COMMON_PRODUCER_CONFIG
self.event_emitter = AsyncEventEmitter(KAFKA_COMMON_PRODUCER_CONFIG)
return self.event_emitter
# entrypoint.py (SASL_SSL + GSSAPI setup)
import os
import ssl
import base64
import subprocess
from pathlib import Path
def _write_certificates():
cert_dir = Path("/tmp/kafka_certs")
cert_dir.mkdir(exist_ok=True, mode=0o700)
# Restore PEM from env (space-separated -> newline-separated)
pem_content = os.environ["KAFKA_CA_PEM"].replace(" ", "\n")
(cert_dir / "ca.pem").write_text(pem_content)
(cert_dir / "ca.pem").chmod(0o600)
keytab = base64.b64decode(os.environ["KAFKA_KEYTAB_B64"])
(cert_dir / "kafka.keytab").write_bytes(keytab)
(cert_dir / "kafka.keytab").chmod(0o600)
def _setup_kerberos():
krb5_conf = Path("/tmp/krb5.conf")
# Read, strip includedir, inject KDC hosts, write to krb5_conf
# (see references/config-and-sasl-kerberos.md for full logic)
os.environ["KRB5_CONFIG"] = str(krb5_conf)
subprocess.run(["kinit", "-kt", "/tmp/kafka_certs/kafka.keytab", "<REDACTED>"], check=True)
def start_consumer():
_write_certificates()
_setup_kerberos()
from services.kafka.consumer.consumer import main
asyncio.run(main())
Design decisions one level above the config maps: what to key events by, where poison messages go, and how multi-service workflows run over the log. Per the conventions above, the consumer layer stays a thin router — everything in this section lives in topic design and in the application handlers that topics_configurations dispatches to.
Retry/DLQ is deliberately NOT wired at the consumer layer (see "Config flow and offset management" above); this is what the application handlers should do instead.
<topic>.dlq with failure metadata — exception summary, handler name, source topic/partition/offset, attempt count, timestamp — then return normally so the consumer commits and the partition keeps flowing. One poison message must never stall every entity queued behind it.# my_module/handlers.py — retry and DLQ live here, not in the consumer layer
import asyncio
from services.kafka.producer.producer import AsyncEventBridge
MAX_ATTEMPTS = 3
DLQ_TOPIC = "my-topic.dlq"
async def process_message(message):
for attempt in range(1, MAX_ATTEMPTS + 1):
try:
await handle(message) # idempotent: redelivery and DLQ replay are both safe
return
except TransientDownstreamError as exc:
if attempt == MAX_ATTEMPTS:
await send_to_dlq(message, exc, attempt)
return # handler "succeeds" so the consumer commits and the partition keeps flowing
await asyncio.sleep(2 ** attempt)
async def send_to_dlq(message, exc, attempts):
emitter = await AsyncEventBridge().get_event_emitter()
await emitter.add_event_to_queue(
topics=[DLQ_TOPIC],
partition_value=message.key, # preserve the key so replay keeps its ordering scope
event={
"payload": message.value,
"error": repr(exc),
"source": {"topic": message.topic, "partition": message.partition, "offset": message.offset},
"attempts": attempts,
},
serialization_format="JSON",
)
await emitter.emit_events()
temporal-developer skill.enable_auto_commit: True for critical data pipelines; manual commit after successful processing prevents data loss on rebalance.CommitFailedError; log and continue because partition reassignment means messages will be reprocessed.check_hostname=False, verify_mode=ssl.CERT_NONE) in production; this allows man-in-the-middle attacks. Some patterns use this for internal networks with self-signed CAs, but production should use proper CA trust or properly-issued certificates.README.md (opens in a new tab)references/config-and-sasl-kerberos.md (opens in a new tab)references/consumer-producer-patterns.md (opens in a new tab)references/htn-apache-kafka-crash-course.md (opens in a new tab)references/repo-evidence.md (opens in a new tab)references/troubleshooting-and-patterns.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
127 skills in this plugin
/accessibility-reviewUI accessibility (WCAG) review — keyboard operability, focus, ARIA semantics, color contrast, touch targets. Returns prioritized fixes. Distinct from performance/visual review./alembic-migrationsAlembic migration setup and patterns for async SQLAlchemy — async engine + run_sync in env.py, autogenerate, RLS/multi-tenant migrations. Use for alembic init, writing migrations, or debugging migration errors./anthropic-vertex-integrationClaude on Vertex AI via the AnthropicVertex SDK — lazy ADC client init, env-based project/region resolution, async helpers, backoff retry. Use when calling Claude via GCP Vertex AI (not direct Anthropic API).npx claudepluginhub ajyadav013/claude-kit --plugin claude-kitOther plugins' skills for the same job