
Change Data Capture Configuration
OfficialFreeEasily configure Salesforce Change Data Capture for your objects.
Free · Opens the source repo
What Change Data Capture Configuration does
The Change Data Capture Configuration skill simplifies the process of enabling Change Data Capture (CDC) for standard and custom Salesforce objects. This skill is essential for developers and system integrators who need to ensure that changes in Salesforce data are accurately captured and sent to downstream systems. By generating the necessary metadata files, this skill facilitates the subscription of Salesforce objects to CDC, allowing for efficient data synchronization and event-driven architectures.
Using this skill, you can create PlatformEventChannelMember files that subscribe specific entities to the default ChangeEvents channel or a custom channel. It also supports the configuration of enrichment fields, which allow additional context to be included in change events, and filter expressions to control which events are emitted based on specific criteria. This flexibility is crucial for tailoring the data flow to meet the needs of various applications and integrations.
The skill operates purely through instructions and does not require a runtime environment, making it lightweight and easy to integrate into existing workflows. It guides users through the necessary steps to define the channel, translate source entity names to their corresponding ChangeEvent names, and generate the appropriate metadata files. This ensures compliance with Salesforce's Metadata API requirements, avoiding common pitfalls associated with naming conventions and file structures.
This skill is particularly useful when working with Salesforce environments that rely on real-time data updates and require a robust mechanism for data change notifications. It is designed for developers who are familiar with Salesforce's metadata structure and need a reliable way to implement CDC without manual errors.
When to use it
Use this skill when you need to enable CDC for Salesforce objects and configure custom event channels or filter expressions.
When not to use it
This skill is not suitable for publishing platform events or for integrating with external systems via Pub/Sub API or similar methods.
What you can build with it
Enable CDC for Standard Objects
Quickly enable Change Data Capture for standard Salesforce objects like Account or Lead, ensuring real-time updates.
Configure Custom Event Channels
Create and configure custom event channels to suit specific integration needs, enhancing data flow management.
Set Filter Expressions for Change Events
Use filter expressions to control which change events are emitted based on specific criteria, optimizing data handling.
How to install Change Data Capture Configuration
View source1. Install with the skills CLI
npx skills add forcedotcom/sf-skills/integration-eventing-cdc-configure --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by forcedotcomManaging Change Data Capture Enablement
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).
Scope
- In scope: Generating
PlatformEventChannelMemberandPlatformEventChannelmetadata for CDC. Subscribing standard objects, custom objects, or both. Configuring enrichment fields. Configuring filter expressions. Defining custom data channels. - 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. Programmatic event-bus subscribers in Apex.
Clarifying Questions
Before generating, confirm with the user if not already clear:
- Which entity (or entities) need CDC enablement? Standard, custom, or both?
- Default channel (
ChangeEvents) or a custom channel? If custom, what's the channel label? - Any enrichment fields needed? (Lookup IDs that the consumer needs even when they didn't change.)
- Any filter expression needed? (A SOQL-WHERE-clause body that gates which change events emit.)
Required Inputs
Gather or infer before proceeding:
- 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). - Channel — either
ChangeEvents(default) or the developer name of a custom channel ending in__chn. - Enrichment fields (optional) — list of field API names on the source object whose values should be included in every change event.
- Filter expression (optional) — a predicate over fields on the change event payload (e.g.
Status__c != null).
Defaults unless specified:
- Channel:
ChangeEvents(the default CDC channel — no path prefix). - Enrichment fields: none.
- Filter expression: none.
If the user provides a clear, complete request, generate immediately without unnecessary back-and-forth.
Workflow
All steps are sequential. Do not skip or reorder.
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.
-
Identify the channel — if the user names a custom channel, you'll generate a
PlatformEventChannelfile (see step 4). Otherwise use the literal valueChangeEventsfor the default channel. -
Translate source entity to ChangeEvent entity name —
<selectedEntity>is the ChangeEvent type, NOT the source object:Source object <selectedEntity>valueAccountAccountChangeEventLeadLeadChangeEventContactContactChangeEventOrder__c(custom)Order__ChangeEventMyThing__c(custom)MyThing__ChangeEventFor standard objects: append
ChangeEvent. For custom objects: replace the trailing__cwith__ChangeEvent(the double-underscore is preserved). -
Generate the channel-member file — one file per
(entity, channel)pair. The filename and fullName always use a SINGLE underscore between the entity stem andChangeEvent— this is independent of howselectedEntityis formatted in the XML body. For custom objects, drop the__cfrom the source name when forming the filename:Source object Filename (and fullName) <selectedEntity>(in XML)AccountAccount_ChangeEvent.platformEventChannelMember-meta.xmlAccountChangeEventLeadLead_ChangeEvent.platformEventChannelMember-meta.xmlLeadChangeEventOrder__cOrder_ChangeEvent.platformEventChannelMember-meta.xml(NOTOrder__ChangeEvent)Order__ChangeEventMyThing__cMyThing_ChangeEvent.platformEventChannelMember-meta.xml(NOTMyThing__ChangeEvent)MyThing__ChangeEventThe custom-object case is the easiest place to slip — the filename uses single underscore, the
selectedEntitykeeps its double underscore. Readassets/PlatformEventChannelMember-template.xmlas the structural template. -
For a custom channel, generate a
PlatformEventChannelfile — required if any member references a non-default channel. Derive a DeveloperName from the user's label: strip spaces and non-alphanumeric characters, convert to CamelCase, then always append the literal suffix__chn. The filename and the channel's<eventChannel>reference must use this exact form, otherwise the deploy fails withInvalid channel name:User says DeveloperName Filename Partner SyncPartnerSync__chnPartnerSync__chn.platformEventChannel-meta.xml(NOTPartner_Sync...orPartnerSync...)Order UpdatesOrderUpdates__chnOrderUpdates__chn.platformEventChannel-meta.xmldata syncDataSync__chnDataSync__chn.platformEventChannel-meta.xmlMembers on this channel reference it by the same DeveloperName:
<eventChannel>PartnerSync__chn</eventChannel>. Readassets/PlatformEventChannel-template.xml. -
Add enrichment fields if requested — repeat the
<enrichedFields><name>FIELD_API_NAME</name></enrichedFields>block for each field. The name must be a single-hop API name on the source entity — verified working with: standard lookup IDs (OwnerId,ParentId), custom lookup fields (MyLookup__c), and custom non-relationship fields (Region__c,Status__c). Relationship traversals likeOwner.NameorParent.Account.Industryare rejected by deploy with "The selected field, X.Y, isn't valid". -
Add a filter expression if requested — wrap the predicate in
<filterExpression>...</filterExpression>. The body is a WHERE-clause body without theWHEREkeyword (e.g.Status__c != null, notWHERE Status__c != null). For supported operators, field types, and pitfalls, readreferences/filter-expressions.md.
Rules / Constraints
| Constraint | Rationale |
|---|---|
<selectedEntity> is the ChangeEvent type name, not the source object name | The Metadata API binds the member to a ChangeEvent entity — passing Account directly fails with "invalid event in selectedEntity". |
Member fullName uses single underscore: Account_ChangeEvent | The double-underscore form (Account__ChangeEvent) is parsed as <namespace>__<name> and rejected: "Cannot create a new component with the namespace: Account". |
Default channel value is exactly ChangeEvents — no path prefix | Older fixtures and some docs show data/ChangeEvents; the deploy returns "Unable to find the specified channel" for that value. |
| Enrichment field names are single-hop API names on the source entity | Standard (OwnerId), custom lookup (MyLookup__c), and custom non-relationship (Region__c) all validate. Traversals like Owner.Name are rejected: "The selected field, X.Y, isn't valid". |
<filterExpression> body has no WHERE keyword | Deploy returns "filter expression has syntax errors: unexpected token: 'WHERE'". |
Filter cannot reference IsDeleted or do relationship traversal (Owner.Username) | Deploy rejects with "field is invalid". |
DateTime fields support only equality in filters (=, !=) — not < / > | Deploy returns "Only equality operators are supported for this field type or value". Use a named date literal: LastModifiedDate = TODAY. |
| Filter RHS must be a literal — no field-to-field comparison | BillingCity = ShippingCity returns "unexpected token: 'ShippingCity'". |
Compound fields (e.g. BillingAddress) require dotted component access in filter | BillingAddress.City = 'X' deploys; flat BillingCity is rejected as "field is invalid"; raw BillingAddress is rejected as "has to be used with a component field". Note this is the OPPOSITE of <enrichedFields>, which uses flat names. |
Custom channel filename ends with __chn before the meta-xml suffix | Salesforce's MDAPI naming convention; mismatch causes deploy ambiguity. |
Custom channel XML must include <channelType>data</channelType> | Without data, the channel is rejected for CDC (other types exist for streaming/event channels). |
| Source custom objects must already exist (or be deployed in the same transaction) | The ChangeEvent entity for Foo__c doesn't exist until Foo__c does; member deploy fails otherwise. |
Never generate a PlatformEventChannel file for the default ChangeEvents channel | The default channel is system-provided. Reference it via <eventChannel>ChangeEvents</eventChannel> on members, but only custom (__chn) channels need a channel-meta file. |
PlatformEventChannelMember accepts ONLY four elements: <enrichedFields>, <eventChannel>, <filterExpression>, <selectedEntity> | Adding <description>, <isActive>, <masterLabel>, or any other element fails XML schema validation: "Element {...} invalid at this location". Stick to the four documented elements. |
PlatformEventChannel accepts ONLY two elements: <channelType> and <label> | Adding <masterLabel>, <description>, etc. produces "Element {...}masterLabel invalid at this location in type PlatformEventChannel". Use <label>, not <masterLabel>. |
Generated metadata files only — never run sf project deploy start from this skill | This skill produces artifacts; deployment is a separate lifecycle concern. |
Gotchas
| Issue | Resolution |
|---|---|
Unable to find the specified channel | Set <eventChannel>ChangeEvents</eventChannel> (no data/ prefix). |
The PlatformEventChannelMember can't be created because it references an invalid event in the "selectedEntity" field | Use the ChangeEvent name, not the source object: AccountChangeEvent, not Account. |
Cannot create a new component with the namespace: <Object> | Rename the file to use a single underscore: Account_ChangeEvent..., not Account__ChangeEvent.... |
The selected field, X.Y, isn't valid (in <enrichedFields>) | Replace Owner.Name with OwnerId. CDC enriches the lookup automatically; only single-hop field API names validate. |
filter expression has syntax errors: unexpected token: 'WHERE' | Remove the WHERE keyword. The body is the predicate only. |
The BillingCity field in the filter expression is invalid (or any flat Address component) | Use the compound dotted form: BillingAddress.City, not BillingCity. See references/filter-expressions.md for the full compound-field matrix. |
| Custom-object member fails with "ChangeEvent doesn't exist" | The source object isn't deployed yet. Ensure the Foo__c object metadata is in the same deploy or already in the org. |
DUPLICATE_VALUE on second deploy | The member is already subscribed. Either delete first or skip — CDC doesn't support upsert on members directly. |
sf infra error (TypeInferenceError, DeployMetadata): Could not infer a metadata type for a .changeDataCapture-meta.xml file | That file extension and metadata type don't exist. Replace the changeDataCapture/<Entity>.changeDataCapture-meta.xml file with a platformEventChannelMembers/<Entity>_ChangeEvent.platformEventChannelMember-meta.xml file. |
User says "subscribe Order__c" but means standard Order | Confirm — OrderChangeEvent (standard) and Order__ChangeEvent (custom) are different entities. |
Output Expectations
Deliverables:
- One
force-app/.../platformEventChannelMembers/<Entity>_ChangeEvent.platformEventChannelMember-meta.xmlper subscribed entity. - One
force-app/.../platformEventChannels/<DevName>__chn.platformEventChannel-meta.xmlper custom channel (if any).
File structure follows the templates in assets/.
After receiving the generated files, the user can verify them with sf project deploy start --dry-run -d <path> --target-org <alias> before deploying. If a dry-run surfaces an unfamiliar error, references/deploy-troubleshooting.md maps the common deploy errors to their metadata-side fixes.
Cross-Skill Integration
| Need | Delegate to |
|---|---|
| Generate the source custom object | platform-custom-object-generate skill |
| Generate custom fields referenced by enrichment or filter | platform-custom-field-generate skill |
| Build a permission set for users who consume change events | platform-permission-set-generate skill |
Reference File Index
| File | When to read |
|---|---|
assets/PlatformEventChannelMember-template.xml | Step 3 — starting structure for a channel member |
assets/PlatformEventChannel-template.xml | Step 4 — starting structure for a custom channel |
references/filter-expressions.md | Step 6 — for the supported operators and field-type matrix when writing a filter expression |
references/deploy-troubleshooting.md | When a user reports a dry-run deploy error and asks for help diagnosing it |
Frequently asked questions about Change Data Capture Configuration
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
