Patterns for Apache Kafka including topic topology design, partition sizing, message schemas (Avro/Protobuf/JSON), producer configurations (at-least-once, exactly-once), and consumer group management.
Ships in claude-skills-collection. 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.
None: SKILL.md is the whole skill.
orders.created, payments.processed, inventory.updatedpartitions = débit_cible_MB/s ÷ débit_par_partition_MB/s (typiquement 10–20 MB/s par partition)max(producteurs_parallèles, consommateurs_parallèles) partitionsretention.ms=604800000 = 7j), size-based (retention.bytes), ou compaction pour les changelogs (KTable)# Créer un topic avec 12 partitions, réplication 3, rétention 7 jours
kafka-topics.sh --bootstrap-server broker:9092 \
--create --topic orders.created \
--partitions 12 --replication-factor 3 \
--config retention.ms=604800000
# Lister / décrire
kafka-topics.sh --bootstrap-server broker:9092 --describe --topic orders.created
BACKWARD par défautevent_id (UUID), event_type, occurred_at (ISO-8601), source, correlation_id// Avro schema — orders.created
{
"type": "record",
"name": "OrderCreated",
"namespace": "com.example.orders",
"fields": [
{"name": "event_id", "type": "string"},
{"name": "order_id", "type": "string"},
{"name": "customer_id", "type": "string"},
{"name": "amount_cents", "type": "long"},
{"name": "occurred_at", "type": {"type": "long", "logicalType": "timestamp-millis"}}
]
}
Choisir les garanties selon le besoin :
| Cas | acks | enable.idempotence | transactional.id |
|---|---|---|---|
| Fire-and-forget (logs) | 0 | false | — |
| At-least-once (défaut) | all | false | — |
| Exactly-once | all | true | txn-{service}-{instance} |
// Producer Java — exactly-once
Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "broker:9092");
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
props.put(ProducerConfig.ACKS_CONFIG, "all");
props.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "txn-orders-1");
props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "lz4");
props.put(ProducerConfig.LINGER_MS_CONFIG, 5); // batching
props.put(ProducerConfig.BATCH_SIZE_CONFIG, 65536); // 64 KB
KafkaProducer<String, OrderCreated> producer = new KafkaProducer<>(props);
producer.initTransactions();
producer.beginTransaction();
producer.send(new ProducerRecord<>("orders.created", order.getId(), event));
producer.commitTransaction();
max.poll.records : réduire si le traitement par batch est lent (défaut 500)session.timeout.ms > temps max de traitement d'un batch// Consumer Java — commit manuel
props.put(ConsumerConfig.GROUP_ID_CONFIG, "orders-billing-service");
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 100);
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
while (true) {
ConsumerRecords<String, OrderCreated> records = consumer.poll(Duration.ofMillis(500));
for (ConsumerRecord<String, OrderCreated> record : records) {
process(record.value());
}
consumer.commitSync(); // après traitement complet
}
Dead Letter Topic (DLT) — isoler les messages non traitables :
topic-principal → traitement → erreur → topic-principal.DLT
Saga choreography — chaque service publie des events, les autres réagissent :
orders.created → payment-service → payments.processed → inventory-service → inventory.reserved
↘ payments.failed → orders.cancelled
CDC avec Debezium — capturer les changements base de données :
// connector config (Postgres)
{
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"database.hostname": "postgres",
"database.dbname": "mydb",
"table.include.list": "public.orders",
"topic.prefix": "cdc"
}
Claim Check — payload > 1 MB : stocker dans S3/Blob, publier seulement la référence :
{"event_id": "...", "payload_ref": "s3://bucket/events/abc123.json"}
StreamsBuilder builder = new StreamsBuilder();
// Comptage par client sur fenêtre de 1h (hopping)
KStream<String, OrderCreated> orders = builder.stream("orders.created");
orders
.groupByKey()
.windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofHours(1)))
.count(Materialized.as("orders-per-customer"))
.toStream()
.to("orders.count-per-customer-1h");
// Stream-Table join
KTable<String, CustomerProfile> profiles = builder.table("customers.profiles");
orders.join(profiles,
(order, profile) -> enrich(order, profile),
Joined.with(Serdes.String(), orderSerde, profileSerde))
.to("orders.enriched");
Configuration minimale pour EOS dans Kafka Streams :
props.put(StreamsConfig.PROCESSING_GUARANTEE_CONFIG, StreamsConfig.EXACTLY_ONCE_V2);
props.put(StreamsConfig.REPLICATION_FACTOR_CONFIG, 3);
props.put(StreamsConfig.NUM_STANDBY_REPLICAS_CONFIG, 1);
Pour les consumers en boucle read-process-write :
isolation.level=read_committed côté consumersendOffsetsToTransaction()Métriques critiques à surveiller :
| Métrique | Outil | Seuil d'alerte |
|---|---|---|
kafka.consumer.lag | JMX / Prometheus | > 10 000 msgs |
under-replicated-partitions | Kafka MBean | > 0 |
records-error-rate | Kafka MBean | > 0 |
| Latence end-to-end | OpenTelemetry | > SLA défini |
# Consumer lag via CLI
kafka-consumer-groups.sh --bootstrap-server broker:9092 \
--describe --group orders-billing-service
# Reset offset en cas d'incident (dry-run)
kafka-consumer-groups.sh --bootstrap-server broker:9092 \
--group orders-billing-service --topic orders.created \
--reset-offsets --to-earliest --dry-run
| Besoin | Choix |
|---|---|
| Traitement stateless simple | Consumer KafkaConsumer |
| Aggregation / join / windowing | Kafka Streams ou ksqlDB |
| SQL déclaratif sur streams | ksqlDB |
| CDC depuis base relationnelle | Debezium + Kafka Connect |
| Garantie exactement-une-fois | EOS (EXACTLY_ONCE_V2) |
| Payload volumineux (> 1 MB) | Claim Check pattern |
enable.auto.commit=false.group.id stricts par environnement.topic.DLT.max.poll.interval.ms trop court ou traitement trop lent. Augmenter max.poll.interval.ms ou réduire max.poll.records.kafka-schema-registry-test-compatibility.acks=1 sur topics critiques : perte de données si le leader crashe avant réplication. Utiliser acks=all + min.insync.replicas=2.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/claude-skills-collection:data-kafka-patternsfrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests".Other plugins' skills for the same job