This prompt is for data platform engineers who need to produce a rigorous, machine-readable mapping specification from source table schemas to CDC event payloads. The core job-to-be-done is translating a relational schema into a complete set of event types (insert, update, delete), payload structures, tombstone handling rules, and ordering guarantees that downstream consumers can rely on. Use this when you are designing a new CDC feed, onboarding a new source table into an existing event stream, or auditing an existing mapping for correctness gaps.
Prompt
Change Data Capture Schema Mapping Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Change Data Capture schema mapping prompt.
The ideal user brings the source DDL, known access patterns, and the target event envelope format (e.g., Debezium, CloudEvents, a proprietary contract). The prompt requires [SOURCE_SCHEMA] as DDL or a structured table description, [TARGET_ENVELOPE] to define the wrapper format, and [CONSUMER_REQUIREMENTS] that specify ordering needs, tombstone expectations, and any denormalization rules. Do not use this prompt for simple table-to-table ETL mappings, for designing the CDC infrastructure itself, or when the source schema is unknown or purely hypothetical. It is also inappropriate when the consumer contract is already fixed and you only need a mechanical translation script rather than a design review.
Before running this prompt, ensure you have resolved upstream decisions about the CDC tool (Debezium, Maxwell, custom WAL reader) and the message broker (Kafka, Pulsar, Kinesis). The prompt assumes a log-based CDC approach with at-least-once delivery semantics. If your system uses trigger-based or polling CDC, you must adapt the ordering guarantee section manually. After generating the mapping specification, validate it against the eval checks described in the full playbook: completeness of change event coverage, correct primary key propagation, tombstone format for deletes, and ordering column inclusion. For high-risk data paths involving financial ledgers or compliance-bound records, always run the output through a peer review and a consumer compatibility test before production deployment.
Use Case Fit
Where the Change Data Capture schema mapping prompt delivers reliable, production-ready output—and where it introduces unacceptable risk. Use these cards to decide whether this prompt fits your current pipeline before committing engineering time.
Good Fit: Greenfield Source-to-Target Mapping
Use when: you have a known source schema (PostgreSQL, MySQL) and need to define the initial CDC event payloads for a new pipeline. Guardrail: the prompt excels at structured enumeration of INSERT, UPDATE, and DELETE event shapes when the source catalog is well-defined. Always provide the complete DDL as input.
Bad Fit: Undocumented or Inferred Schemas
Avoid when: the source schema is undocumented, reverse-engineered from logs, or inferred from application code. Risk: the model will hallucinate plausible column names and types, producing a mapping that looks correct but silently drops or misrepresents fields. Guardrail: require a verified DDL dump as a mandatory input; if unavailable, this prompt should not be used.
Required Input: Complete Source DDL
What to watch: missing primary keys, unique constraints, or foreign key relationships in the provided DDL. Guardrail: the prompt's output quality depends entirely on constraint visibility. If the DDL lacks primary keys, the model cannot correctly define tombstone keys or deduplication logic. Validate that the input DDL includes all constraints before running the mapping.
Operational Risk: Ordering and Exactly-Once Semantics
What to watch: the prompt may produce a schema mapping that assumes total order or exactly-once delivery without explicit instruction. Guardrail: always include a [DELIVERY_SEMANTICS] constraint in the prompt (e.g., at-least-once with deduplication) and review the output for missing sequence numbers, transaction boundaries, or idempotency keys before deploying to production.
Bad Fit: Binary or Proprietary Payload Formats
Avoid when: the source system emits binary-encoded changes (e.g., MySQL binlog raw format, Oracle REDO) without a defined intermediate representation. Risk: the model cannot reason about opaque binary schemas and will generate generic, incorrect field mappings. Guardrail: use this prompt only after the source format has been decoded into a known relational schema or Avro/Protobuf definition.
Good Fit: Compliance-Audited Schema Evolution
Use when: you need to document the mapping between source tables and CDC topics for a compliance or data governance review. Guardrail: the structured output format (event types, payload schemas, tombstone rules) serves as auditable evidence of the pipeline contract. Pair the output with a human review step before signing off on the mapping for regulated data.
Copy-Ready Prompt Template
A reusable prompt template for generating a structured CDC schema mapping specification from source table definitions.
This prompt template is designed to produce a complete change data capture (CDC) mapping specification. It takes source table schemas, business context, and operational constraints as input and outputs a structured document detailing event types, payload schemas, tombstone handling, and ordering guarantees. The template uses square-bracket placeholders that you must replace with your specific source system details before execution.
textYou are a data platform architect specializing in change data capture (CDC) system design. Your task is to produce a rigorous CDC schema mapping specification from a set of source table definitions. ## INPUT Source System: [SOURCE_SYSTEM_NAME] Source Tables and DDL: [SOURCE_TABLE_DDL] Business Context: [BUSINESS_CONTEXT] ## CONSTRAINTS - Target event format: [EVENT_FORMAT, e.g., Avro, Protobuf, JSON] - Schema registry: [SCHEMA_REGISTRY_URL_OR_PATTERN] - Ordering guarantee required: [ORDERING_GUARANTEE, e.g., per-partition, global] - Tombstone strategy: [TOMBSTONE_STRATEGY, e.g., null payload, dedicated header] - Downstream consumers: [CONSUMER_LIST_AND_TYPES] - Retention policy: [RETENTION_POLICY] ## OUTPUT_SCHEMA Produce a JSON object with the following structure: { "source_system": "string", "mappings": [ { "source_table": "string", "event_types": [ { "type": "insert|update|delete|read", "topic_name": "string", "key_schema": { "fields": [{"name": "string", "type": "string", "source_column": "string"}] }, "payload_schema": { "fields": [{"name": "string", "type": "string", "source_column": "string", "transformation": "string|null"}] }, "tombstone_handling": "string", "ordering_guarantee": "string" } ], "primary_key_columns": ["string"], "capture_mode": "string", "filter_condition": "string|null" } ], "global_ordering_strategy": "string", "schema_evolution_policy": "string", "unmapped_tables": ["string"], "risks_and_recommendations": ["string"] } ## INSTRUCTIONS 1. For each source table, identify all columns that should be included in the event payload. 2. Determine the appropriate key schema using primary key columns or a business key if specified. 3. Map source column types to the target event format types. Document any type conversions. 4. For each table, define event types for INSERT, UPDATE, and DELETE operations. Include READ events only if explicitly requested. 5. Specify tombstone handling for DELETE events according to the provided strategy. 6. Document the ordering guarantee that can be achieved given the source system capabilities. 7. Identify any source tables that cannot be mapped and explain why. 8. Flag risks related to schema evolution, large payloads, or type compatibility. ## EXAMPLES [FEW_SHOT_EXAMPLES] ## RISK_LEVEL [RISK_LEVEL, e.g., low, medium, high]
To adapt this template, replace each bracketed placeholder with concrete values from your environment. The [SOURCE_TABLE_DDL] placeholder should contain the full DDL for all tables under consideration. The [FEW_SHOT_EXAMPLES] placeholder is optional but strongly recommended for production use—include one or two complete mapping examples that demonstrate your organization's conventions for topic naming, schema structure, and type mappings. The [RISK_LEVEL] field should be set to high if the source system is a system of record with financial, healthcare, or compliance data; in such cases, always route the output through human review before applying the mapping to a live CDC pipeline.
Before using this prompt in production, validate the output against your schema registry's compatibility rules and test it with a representative sample of source data. Common failure modes include missing columns in the payload schema, incorrect type mappings for temporal or decimal types, and incomplete tombstone specifications that could cause downstream consumers to misinterpret deleted records. Run the output through an automated schema validator and a peer review step before committing it to your CDC configuration.
Prompt Variables
Required inputs for the Change Data Capture Schema Mapping Prompt. Each placeholder must be resolved before the prompt is assembled. Validation notes describe what makes the input safe and complete.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SOURCE_SCHEMA_DDL] | Complete DDL for all source tables to be captured, including columns, types, constraints, and primary keys | CREATE TABLE orders (id UUID PRIMARY KEY, status VARCHAR(20), updated_at TIMESTAMPTZ); | Parse check: valid DDL syntax. Must include primary key for every table. Null allowed: false. If DDL is unavailable, provide equivalent schema description with column-level detail. |
[CDC_CAPTURE_MODE] | Specifies the capture method: log-based, trigger-based, query-based, or timestamp-delta | log-based (PostgreSQL logical replication) | Enum check: must be one of log-based, trigger-based, query-based, timestamp-delta. Affects event type availability and ordering guarantees. Null allowed: false. |
[TARGET_EVENT_TYPES] | List of change event types the mapping must produce: insert, update, delete, snapshot, or tombstone | ["insert", "update", "delete", "tombstone"] | Enum check per element: insert, update, delete, snapshot, tombstone. At least one required. If tombstone is included, [TOMBSTONE_STRATEGY] must also be provided. Null allowed: false. |
[PAYLOAD_FORMAT] | Target serialization format for event payloads: JSON, Avro, Protobuf, or custom schema registry format | Avro with Confluent Schema Registry | Enum check: JSON, Avro, Protobuf, custom. If custom, [PAYLOAD_SCHEMA_REGISTRY_URL] or schema definition must be provided. Null allowed: false. |
[ORDERING_GUARANTEE] | Required ordering semantics: per-key total order, partition-level order, global total order, or at-least-once with no order | per-key total order | Enum check: per-key-total-order, partition-level-order, global-total-order, at-least-once-unordered. Must be compatible with [CDC_CAPTURE_MODE]. Log-based can support per-key total order; query-based typically cannot. Null allowed: false. |
[TOMBSTONE_STRATEGY] | How deletes are represented: null-value tombstone, explicit tombstone event type, soft-delete flag, or no tombstone | null-value tombstone per Kafka convention | Required if [TARGET_EVENT_TYPES] includes tombstone or delete. Enum check: null-value-tombstone, explicit-event-type, soft-delete-flag, none. Must align with [PAYLOAD_FORMAT] capabilities. Null allowed: true only if no delete events needed. |
[COLUMN_TRANSFORM_RULES] | Column-level transformation rules: rename, type cast, default value, omit, or hash for sensitive columns | {"orders.user_email": "hash-sha256", "orders.status": "passthrough", "orders.internal_note": "omit"} | Parse check: valid JSON object mapping source_column -> transform. Transforms must be one of passthrough, rename:[new_name], cast:[target_type], default:[value], omit, hash-[algorithm]. Every source column must be accounted for or explicitly omitted. Null allowed: false. |
[SCHEMA_EVOLUTION_POLICY] | Rules for handling source schema changes: forward-compatible only, full compatibility, or no compatibility enforcement | forward-compatible: add optional fields only, no rename or remove | Enum check: forward-compatible, full-compatible, backward-compatible, none. Must specify whether schema registry enforces compatibility or mapping handles it. Null allowed: false. |
Implementation Harness Notes
How to wire the CDC schema mapping prompt into a reliable data platform workflow.
This prompt is designed to be a deterministic step in a schema management pipeline, not a one-off chat interaction. The primary integration point is a CI/CD check that runs whenever a source table DDL changes or a new CDC connector is configured. The application harness should capture the source DDL, existing event envelope schema, and any consumer contracts as structured inputs, then feed them into the prompt through a templating layer that enforces strict JSON output parsing.
The implementation must include a validation layer that parses the model's JSON output and checks for structural completeness before the mapping is accepted. At minimum, validate that every source table column is accounted for in at least one event type (insert, update, delete), that tombstone events are explicitly defined for hard-delete scenarios, and that the declared ordering guarantees (e.g., per-key ordering via partition columns) match the source system's actual capabilities. If the output fails structural validation, the harness should retry once with the validation errors appended as additional [CONSTRAINTS] in the prompt context. After two failures, escalate to a human reviewer through a ticketing system rather than silently accepting an incomplete mapping.
For production deployment, log every generated mapping alongside the input schema version hash, model version, and validation results. This creates an audit trail that connects CDC payload schemas back to the exact source schema state that produced them. When source schemas evolve, re-run the prompt against the new DDL and use a diff against the previous mapping to detect breaking changes in the event payload. Wire this diff into your schema registry's compatibility checks so that downstream consumers are alerted before incompatible CDC events reach their topics. Avoid using this prompt for real-time schema inference at event ingestion time—the latency and non-determinism of LLM calls make them unsuitable for hot-path CDC pipelines.
Expected Output Contract
Defines the required fields, types, and validation rules for the CDC schema mapping output. Use this contract to validate the model's response before integrating it into a downstream pipeline or review process.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
source_table | string | Must match a table name provided in [SOURCE_SCHEMA]. Case-sensitive exact match required. | |
target_topic | string | Must be a non-empty string following the naming convention in [TOPIC_NAMING_CONVENTION]. Regex: ^[a-z][a-z0-9_.-]*$. | |
event_types | array of strings | Must be a non-empty array containing only 'create', 'update', 'delete', or 'read'. No duplicates allowed. | |
payload_schema | JSON Schema object | Must be a valid JSON Schema draft-07 object. Each field must have a 'type' and 'description'. Must include all columns from the source table unless explicitly excluded in [EXCLUDED_COLUMNS]. | |
key_schema | JSON Schema object | Must be a valid JSON Schema draft-07 object. Must include the primary key column(s) from the source table. Must be a subset of the payload_schema properties. | |
tombstone_strategy | string | Must be one of: 'null_payload', 'dedicated_tombstone_field', or 'header_flag'. If 'header_flag' is selected, the 'tombstone_field_name' must also be provided. | |
ordering_guarantee | string | Must be one of: 'key', 'partition', or 'global'. If 'global' is selected, a 'partition_count' of 1 must be set in [TOPOLOGY_CONFIG]. | |
schema_evolution_policy | string | Must be one of: 'backward_compatible', 'forward_compatible', or 'full_compatible'. If 'backward_compatible' or 'full_compatible' is selected, a 'default_value_map' must be provided for any new fields added to the payload_schema. |
Common Failure Modes
When mapping source schemas to CDC event payloads, these are the failure modes that surface first in production. Each card identifies a specific risk and the guardrail that prevents it.
Missing Tombstone Events for Hard Deletes
What to watch: The mapping omits tombstone or null-payload events when a source row is deleted. Downstream consumers never learn about the deletion and retain stale data indefinitely. Guardrail: Require an explicit tombstone event definition for every source table that supports hard deletes. Validate the mapping against a deletion scenario in the eval harness before accepting the output.
Incomplete Change Event Type Coverage
What to watch: The mapping defines INSERT and UPDATE events but misses edge cases like TRUNCATE, partition drops, or schema migrations that also change state. Consumers miss data changes and drift from the source of truth. Guardrail: Include a completeness checklist in the prompt constraints that enumerates all DML and DDL operations the source supports. Run a coverage eval that flags any operation without a corresponding event type.
Payload Schema Drift from Source Columns
What to watch: The generated payload schema includes columns that don't exist in the source, omits columns that do, or uses mismatched data types. This produces serialization failures at runtime or silent data corruption. Guardrail: Add a schema reconciliation step that diffs the generated payload schema against the actual source catalog metadata. Flag every column mismatch as a blocking validation failure before the mapping is accepted.
Ambiguous Ordering Guarantees
What to watch: The mapping doesn't specify the ordering column or sequence mechanism, leaving consumers to guess whether events are ordered by commit timestamp, log position, or something else. Out-of-order processing produces incorrect downstream state. Guardrail: Require the mapping to declare an explicit ordering field with its source, type, and monotonicity guarantee. Test with a reorder scenario in eval to confirm the model understands ordering semantics.
Primary Key Collapse Across Partitions
What to watch: The mapping uses only the source primary key as the event key, but the source table is partitioned and the same key can appear in multiple partitions. Events from different partitions overwrite each other in the consumer. Guardrail: Require the mapping to include partition or shard context in the event key when the source uses horizontal partitioning. Validate with a multi-partition test case that checks for key collisions.
Large Object or Blob Column Inclusion
What to watch: The mapping includes large object columns (BLOBs, CLOBs, large JSON documents) in the full payload without size limits or alternative handling. This bloats event sizes, saturates the message bus, and causes consumer timeouts. Guardrail: Add a constraint that columns exceeding a configurable size threshold must use a reference pattern (e.g., a storage location pointer) rather than inline inclusion. Validate with a payload size check in the eval harness.
Evaluation Rubric
Use this rubric to test the quality of a generated CDC schema mapping before shipping it into a production pipeline. Each criterion targets a specific failure mode common in AI-generated data platform specifications.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Event Type Completeness | Mapping covers INSERT, UPDATE, and DELETE for every source table listed in [SOURCE_SCHEMA]. | Missing event type for a table present in the input schema. | Parse output JSON. Extract all unique (table, event_type) pairs. Assert set equality against the Cartesian product of tables from [SOURCE_SCHEMA] and {INSERT, UPDATE, DELETE}. |
Payload Schema Field Coverage | Every non-generated column in [SOURCE_SCHEMA] appears in the corresponding INSERT and UPDATE payload schemas. | A source column is omitted from the payload schema without explicit justification in the exclusions list. | For each table, diff the column list from [SOURCE_SCHEMA] against the fields in the payload schema. Flag any missing columns not listed in a dedicated 'excluded_columns' field. |
Primary Key Presence | Every event payload includes the source table's primary key column(s) as defined in [SOURCE_SCHEMA]. | Primary key field is missing or renamed without a mapping rule in the metadata. | Extract primary key constraint from [SOURCE_SCHEMA] DDL. Assert that each payload schema contains a field with a matching name and type. |
Tombstone Event Specification | DELETE events include a defined tombstone payload structure, typically containing only the primary key and a deletion marker. | DELETE payload includes full row data or omits the primary key. | Inspect the DELETE event schema for each table. Assert that it contains only the primary key fields and a boolean or timestamp deletion marker. Fail if any non-key data fields are present. |
Ordering Guarantee Declaration | Output includes an explicit ordering guarantee statement (e.g., 'per-partition-key' or 'global') and the corresponding ordering column. | Ordering guarantee is missing, ambiguous, or references a column not present in the source schema. | Check for a top-level 'ordering' key. Assert it contains 'scope' and 'column' fields. Verify the column exists in at least one source table. |
Data Type Mapping Accuracy | All source column types are mapped to a valid, specified target type in the payload schema using a defined mapping table. | A source type is mapped to 'string' generically, or an unrecognized type is present without a custom mapping rule. | For each column, look up the source type in the output's 'type_mappings' section. Assert a mapping exists. Spot-check 3 mappings against a known reference (e.g., PostgreSQL to Avro). |
Before-Image Inclusion Rule | UPDATE events include a 'before' field only if [INCLUDE_BEFORE_IMAGE] is set to true. The field must contain the full previous row schema. | Before-image is present when the flag is false, or missing when the flag is true. | Check the value of [INCLUDE_BEFORE_IMAGE]. Assert that the presence of the 'before' field in the UPDATE payload schema strictly matches this boolean value. |
Schema Registry Compatibility | Output includes a compatibility mode declaration (BACKWARD, FORWARD, FULL) and the generated schema passes a structural check for that mode. | The declared compatibility mode contradicts the schema structure (e.g., adding a non-optional field declared as BACKWARD compatible). | If a compatibility mode is declared, run a structural diff between a baseline schema and the generated schema. Assert that the diff does not violate the rules of the declared mode. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single source table and a known target event type. Remove ordering-guarantee and tombstone-handling sections. Focus on getting a correct payload schema for insert, update, and delete events from one table.
Simplify the output schema to just the event type enum and the payload JSON structure. Skip the full mapping specification with partition keys and sequence numbers.
Watch for
- Missing delete event handling (only mapping inserts and updates)
- Payload fields that don't match the actual source column types
- No validation that every source column appears in at least one event type payload

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us