$npx -y skills add forcedotcom/sf-skills --skill integration-eventing-cdc-configureUse to enable Salesforce Change Data Capture (CDC) on a standard or custom object, configure a custom event channel, set a filter expression, or add enrichment fields. TRIGGER broadly on any of: 'enable CDC', 'enable Change Data Capture', 'turn on CDC', 'subscribe X to change eve
| 1 | # Managing Change Data Capture Enablement |
| 2 | |
| 3 | Generate the metadata that subscribes Salesforce objects to Change Data Capture: `PlatformEventChannelMember` files for the default `ChangeEvents` channel or a custom channel, and `PlatformEventChannel` files for new custom channels. Covers enrichment fields, filter expressions, and the canonical naming and value formats that the Metadata API actually accepts (which differ from values that appear in many internal test fixtures and code-search hits). |
| 4 | |
| 5 | ## Scope |
| 6 | |
| 7 | - **In scope**: Generating `PlatformEventChannelMember` and `PlatformEventChannel` metadata for CDC. Subscribing standard objects, custom objects, or both. Configuring enrichment fields. Configuring filter expressions. Defining custom data channels. |
| 8 | - **Out of scope**: Publishing custom platform events (PE) — that's a different metadata type (`PlatformEvent`). Pub/Sub API or external Kafka/Bayeux configuration. Pricing/limits guidance — refer the user to the [CDC Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/). Programmatic event-bus subscribers in Apex. |
| 9 | |
| 10 | --- |
| 11 | |
| 12 | ## Clarifying Questions |
| 13 | |
| 14 | Before generating, confirm with the user if not already clear: |
| 15 | |
| 16 | - Which entity (or entities) need CDC enablement? Standard, custom, or both? |
| 17 | - Default channel (`ChangeEvents`) or a custom channel? If custom, what's the channel label? |
| 18 | - Any enrichment fields needed? (Lookup IDs that the consumer needs even when they didn't change.) |
| 19 | - Any filter expression needed? (A SOQL-WHERE-clause body that gates which change events emit.) |
| 20 | |
| 21 | --- |
| 22 | |
| 23 | ## Required Inputs |
| 24 | |
| 25 | Gather or infer before proceeding: |
| 26 | |
| 27 | - **Source entity API name(s)** — e.g. `Account`, `Lead`, `Order__c`. The skill internally translates this to the **ChangeEvent entity name** (see Workflow step 2). |
| 28 | - **Channel** — either `ChangeEvents` (default) or the developer name of a custom channel ending in `__chn`. |
| 29 | - **Enrichment fields (optional)** — list of field API names on the source object whose values should be included in every change event. |
| 30 | - **Filter expression (optional)** — a predicate over fields on the change event payload (e.g. `Status__c != null`). |
| 31 | |
| 32 | Defaults unless specified: |
| 33 | - Channel: `ChangeEvents` (the default CDC channel — no path prefix). |
| 34 | - Enrichment fields: none. |
| 35 | - Filter expression: none. |
| 36 | |
| 37 | If the user provides a clear, complete request, generate immediately without unnecessary back-and-forth. |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ## Workflow |
| 42 | |
| 43 | All steps are sequential. Do not skip or reorder. |
| 44 | |
| 45 | **Before generating anything, know the only valid CDC metadata types:** CDC is expressed entirely through `PlatformEventChannelMember` (one per subscribed entity) and `PlatformEventChannel` (only for custom channels). Do NOT use `<ChangeDataCapture>`, `.changeDataCapture-meta.xml`, `changeDataCapture/` directories, `EnableChangeDataCapture`, or `ManagedEventSubscription` — these are not in scope for CDC. If you find yourself writing any of them, stop and use a `PlatformEventChannelMember` file instead. |
| 46 | |
| 47 | 1. **Identify the channel** — if the user names a custom channel, you'll generate a `PlatformEventChannel` file (see step 4). Otherwise use the literal value `ChangeEvents` for the default channel. |
| 48 | |
| 49 | 2. **Translate source entity to ChangeEvent entity name** — `<selectedEntity>` is the **ChangeEvent** type, NOT the source object: |
| 50 | |
| 51 | | Source object | `<selectedEntity>` value | |
| 52 | |---|---| |
| 53 | | `Account` | `AccountChangeEvent` | |
| 54 | | `Lead` | `LeadChangeEvent` | |
| 55 | | `Contact` | `ContactChangeEvent` | |
| 56 | | `Order__c` (custom) | `Order__ChangeEvent` | |
| 57 | | `MyThing__c` (custom) | `MyThing__ChangeEvent` | |
| 58 | |
| 59 | For standard objects: append `ChangeEvent`. For custom objects: replace the trailing `__c` with `__ChangeEvent` (the double-underscore is preserved). |
| 60 | |
| 61 | 3. **Generate the channel-member file** — one file per `(entity, channel)` pair. **The filename and fullName always use a SINGLE underscore between the entity stem and ` |