ivanshamaev/de-agent-skills/cdc-debezium

Claude Code and agent skill by ivanshamaev/de-agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Change Data Capture with Debezium — PostgreSQL/MySQL/Oracle CDC connectors, change event structure (before/after/op/source), snapshot modes, Kafka Connect deployment, SMT transformations, outbox pattern, Iceberg/Delta sink integration, idempotency guarantees

Install

npx vskill@latest install ivanshamaev/de-agent-skills/cdc-debezium

SKILL.md

The same SKILL.md was published earlier as ivanshamaev/de-agent-skills/cdc-debezium.

CDC Pipelines with Debezium

When to Use

Activate this skill when the task involves:

  • Setting up Debezium connectors for PostgreSQL, MySQL, or Oracle
  • Interpreting or transforming CDC change events (insert/update/delete/truncate)
  • Designing CDC pipelines: database → Kafka → data lake / warehouse
  • Implementing the Outbox pattern for transactional CDC
  • Troubleshooting replication lag, snapshot failures, or schema evolution
  • Integrating CDC streams with Apache Flink, Spark Structured Streaming, or dbt

Core Architecture

┌──────────────────────────────────────────────────────────────┐
│ Source Database │
│ ┌─────────────┐ WAL / binlog / redo log │
│ │ PostgreSQL │──────────────────────┐ │
│ │ MySQL │ ▼ │
│ │ Oracle │ ┌───────────────────────┐ │
│ └─────────────┘ │ Kafka Connect Worker │ │
│ │ ┌─────────────────┐ │ │
│ │ │ Debezium Source │ │ │
│ │ │ Connector │ │ │
│ │ └────────┬────────┘ │ │
│ └───────────│───────────┘ │
│ ▼ │
│ ┌───────────────────────┐ │
│ │ Kafka Topic │ │
│ │ <prefix>.<db>.<tbl> │ │
│ └───────────┬───────────┘ │
│ ▼ │
│ ┌──────────────────────────────┐ │
│ │ Consumers │ │
│ │ • Kafka Connect Sink │ │
│ │ • Apache Flink / Spark │ │
│ │ • ksqlDB / Kafka Streams │ │
│ └──────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘

Debezium reads database transaction logs (WAL for PostgreSQL, binlog for MySQL), not the tables themselves — zero query load on the source.


Change Event Structure

Every Debezium event is a Kafka message with a structured envelope:

json
{
"schema": { ... },
"payload": {
"before": {
"id": 1001,
"name": "Alice",
"email": "alice@example.com",
"updated_at": 1700000000000
},
"after": {
"id": 1001,
"name": "Alice Smith",
"email": "alice@example.com",
"updated_at": 1700001000000
},
"source": {
"version": "2.5.0.Final",
"connector": "postgresql",
"name": "pgserver1",
"ts_ms": 1700001000123,
"snapshot": "false",
"db": "mydb",
"sequence": "[\"24023119\",\"24023255\"]",
"schema": "public",
"table": "customers",
"txId": 756,
"lsn": 24023255,
"xmin": null
},
"op": "u",
"ts_ms": 1700001000456,
"transaction": {
"id": "756:24023255",
"total_order": 1,
"data_collection_order": 1
}
}
}
Operation Types
opMeaningbeforeafter
cINSERT (create)nullrow state
uUPDATEprevious statenew state
dDELETEprevious statenull
rREAD (snapshot)nullrow state
tTRUNCATEnullnull
Tombstone Events

After a d (delete) event, Debezium emits a tombstone — a message with null value and the same key — enabling Kafka log compaction to eventually remove the record.


PostgreSQL Connector

Prerequisites
sql
-- postgresql.conf: must be set before Debezium can connect
ALTER SYSTEM SET wal_level = 'logical';
ALTER SYSTEM SET max_replication_slots = 10;
ALTER SYSTEM SET max_wal_senders = 10;
-- Create dedicated Debezium user
CREATE ROLE debezium WITH LOGIN PASSWORD 'secret' REPLICATION;
GRANT CONNECT ON DATABASE mydb TO debezium;
GRANT USAGE ON SCHEMA public TO debezium;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO debezium;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO debezium;
-- Create publication (pgoutput plugin — no extra extension needed)
CREATE PUBLICATION dbz_pub FOR TABLE customers, orders, products;
-- Or capture all tables:
CREATE PUBLICATION dbz_pub FOR ALL TABLES;

Restart PostgreSQL after changing wal_level.

Connector Configuration
json
{
"name": "pg-customers-connector",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"database.hostname": "postgres-host",
"database.port": "5432",
"database.user": "debezium",
"database.password": "secret",
"database.dbname": "mydb",
"topic.prefix": "pgserver1",
"plugin.name": "pgoutput",
"publication.name": "dbz_pub",
"slot.name": "debezium_slot",
"table.include.list": "public.customers,public.orders",
"snapshot.mode": "initial",
"snapshot.locking.mode": "minimal",
"heartbeat.interval.ms": "30000",
"heartbeat.topics.prefix": "__debezium-heartbeat",
"key.converter": "io.confluent.kafka.serializers.KafkaAvroSerializer",
"key.converter.schema.registry.url": "http://schema-registry:8081",
"value.converter": "io.confluent.kafka.serializers.KafkaAvroSerializer",
"value.converter.schema.registry.url": "http://schema-registry:8081",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.drop.tombstones": "false",
"transforms.unwrap.delete.handling.mode": "rewrite",
"transforms.unwrap.add.fields": "op,table,lsn,source.ts_ms",
"transforms.unwrap.add.headers": "db",
"errors.tolerance": "all",
"errors.deadletterqueue.topic.name": "dlq.pgserver1.customers",
"errors.deadletterqueue.topic.replication.factor": "3",
"errors.deadletterqueue.context.headers.enable": "true"
}
}
Snapshot Modes (PostgreSQL)
ModeDescriptionWhen to Use
initialSnapshot on first start only; then streamDefault — new deployments
initial_onlySnapshot then stop — no streamingOne-time historical load
no_dataSkip snapshot, start streaming from nowAppend-only use cases
alwaysSnapshot on every connector restartDev/testing only
exportedConsistent snapshot without table locks (PG 15+)Large tables in production
incrementalRe-snapshot selected tables without stoppingAdd new tables mid-stream
Replication Slot Monitoring
sql
-- Check lag: drop-behind LSN distance
SELECT
slot_name,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS lag_size,
active,
database
FROM pg_replication_slots
WHERE slot_type = 'logical';
-- Alert if lag_size > 5GB — Debezium consumer is too slow

MySQL Connector

Prerequisites
ini
# my.cnf — server-id must be unique across all replicas
server-id = 12345
log_bin = mysql-bin
binlog_format = ROW
binlog_row_image = FULL
expire_logs_days = 7
gtid_mode = ON # recommended
enforce_gtid_consistency = ON
sql
CREATE USER 'debezium'@'%' IDENTIFIED BY 'secret';
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT
ON *.* TO 'debezium'@'%';
FLUSH PRIVILEGES;
Connector Configuration
json
{
"name": "mysql-orders-connector",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"tasks.max": "1",
"database.hostname": "mysql-host",
"database.port": "3306",
"database.user": "debezium",
"database.password": "secret",
"database.server.id": "12345",
"topic.prefix": "mysqlserver1",
"database.include.list": "shop",
"table.include.list": "shop.orders,shop.order_items",
"snapshot.mode": "initial",
"snapshot.locking.mode": "minimal",
"include.schema.changes": "true",
"schema.history.internal.kafka.topic": "schema-changes.shop",
"schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
"key.converter": "io.confluent.kafka.serializers.KafkaAvroSerializer",
"key.converter.schema.registry.url": "http://schema-registry:8081",
"value.converter": "io.confluent.kafka.serializers.KafkaAvroSerializer",
"value.converter.schema.registry.url": "http://schema-registry:8081",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.drop.tombstones": "false",
"transforms.unwrap.delete.handling.mode": "rewrite",
"transforms.unwrap.add.fields": "op,table,source.ts_ms"
}
}

MySQL requires schema.history.internal.kafka.topic — a durable log of all DDL changes. Never delete this topic.


Single Message Transforms (SMTs)

ExtractNewRecordState — Flattening Events

Without SMT, downstream consumers receive the full before/after/source envelope. ExtractNewRecordState flattens it:

Before SMT:

json
{"payload": {"before": null, "after": {"id": 1, "name": "Alice"}, "op": "c"}}

After SMT:

json
{"id": 1, "name": "Alice", "__op": "c", "__table": "customers", "__source_ts_ms": 1700001000123}
Field Masking for PII
json
"transforms": "mask_email",
"transforms.mask_email.type": "org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.mask_email.fields": "email,phone",
"transforms.mask_email.replacement": "***"
Routing to Per-Table Topics
json
"transforms": "route",
"transforms.route.type": "io.debezium.transforms.ByLogicalTableRouter",
"transforms.route.topic.regex": "pgserver1\\.public\\.(.*)",
"transforms.route.topic.replacement": "cdc.raw.$1"

Kafka Connect Deployment

Docker Compose (Standalone)
yaml
version: "3.8"
services:
kafka:
image: confluentinc/cp-kafka:7.6.0
environment:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:9093"
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
CLUSTER_ID: "MkU3OEVBNTcwNTJENDM2Qk"
schema-registry:
image: confluentinc/cp-schema-registry:7.6.0
environment:
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: kafka:9092
SCHEMA_REGISTRY_HOST_NAME: schema-registry
ports:
- "8081:8081"
kafka-connect:
image: debezium/connect:2.5
environment:
BOOTSTRAP_SERVERS: kafka:9092
GROUP_ID: debezium-connect-cluster
CONFIG_STORAGE_TOPIC: connect-configs
OFFSET_STORAGE_TOPIC: connect-offsets
STATUS_STORAGE_TOPIC: connect-statuses
CONFIG_STORAGE_REPLICATION_FACTOR: 1
OFFSET_STORAGE_REPLICATION_FACTOR: 1
STATUS_STORAGE_REPLICATION_FACTOR: 1
CONNECT_KEY_CONVERTER: io.confluent.kafka.serializers.KafkaAvroSerializer
CONNECT_VALUE_CONVERTER: io.confluent.kafka.serializers.KafkaAvroSerializer
CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
ports:
- "8083:8083"
depends_on:
- kafka
- schema-registry
Connector Lifecycle via REST API
bash
# Deploy connector
curl -s -X POST http://localhost:8083/connectors \
-H "Content-Type: application/json" \
-d @pg-customers-connector.json
# Check status
curl -s http://localhost:8083/connectors/pg-customers-connector/status | jq
# Pause / Resume (drains without losing offset)
curl -X PUT http://localhost:8083/connectors/pg-customers-connector/pause
curl -X PUT http://localhost:8083/connectors/pg-customers-connector/resume

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ivanshamaev/de-agent-skills/cdc-debezium/badge)](https://verified-skill.com/skills/ivanshamaev/de-agent-skills/cdc-debezium)

Something wrong with this skill or its page? Tell us.