Skip to content

forcedotcom/sf-skills / plugins/builder/integration/skills/integration-connectivity-generate

integration-connectivity-generate

Verified

Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use integration-connectivity-connected-app-configure), Apex-only logic (use platform-apex-generate), data import/export (use platform-data-manage), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use integration-eventing-cdc-configure).

FileKindSize
README.mdmarkdown3.5 KB
SKILL.mdskill md8.8 KB
assets/callouts/callout-retry-handler.clsother6.0 KB
assets/callouts/http-response-handler.clsother8.5 KB
assets/callouts/rest-queueable-callout.clsother8.8 KB
assets/callouts/rest-sync-callout.clsother7.4 KB
assets/cdc/cdc-handler.clsother8.4 KB
assets/cdc/cdc-subscriber-trigger.triggerother5.3 KB
assets/endpoint-security/example.cspTrustedSite-meta.xmlconfig1.8 KB
assets/endpoint-security/example.remoteSite-meta.xmlconfig1.3 KB
assets/external-credentials/jwt-external-credential.externalCredential-meta.xmlconfig3.2 KB
assets/external-credentials/oauth-external-credential.externalCredential-meta.xmlconfig3.0 KB
assets/external-services/external-service-operations.mdmarkdown5.5 KB
assets/external-services/openapi-registration.externalServiceRegistration-meta.xmlconfig4.8 KB
assets/named-credentials/certificate-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/custom-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/oauth-client-credentials.namedCredential-meta.xmlconfig1.8 KB
assets/named-credentials/oauth-jwt-bearer.namedCredential-meta.xmlconfig2.2 KB
assets/platform-events/event-publisher.clsother6.4 KB
assets/platform-events/event-subscriber-action.clsother9.5 KB
assets/platform-events/event-subscriber-trigger.triggerother3.9 KB
assets/platform-events/platform-event-definition.object-meta.xmlconfig3.7 KB
assets/soap/soap-callout-service.clsother6.4 KB
assets/soap/wsdl2apex-guide.mdmarkdown6.2 KB
references/callout-patterns.mdmarkdown21.8 KB
references/cdc-guide.mdmarkdown8.2 KB
references/cli-reference.mdmarkdown2.9 KB
references/event-driven-architecture-guide.mdmarkdown10.1 KB
references/event-patterns.mdmarkdown27.2 KB
references/external-services-guide.mdmarkdown8.4 KB
references/messaging-api-v2.mdmarkdown17.9 KB
references/named-credentials-automation.mdmarkdown6.2 KB
references/named-credentials-guide.mdmarkdown7.1 KB
references/platform-events-guide.mdmarkdown6.6 KB
references/rest-callout-patterns.mdmarkdown8.8 KB
references/scoring-rubric.mdmarkdown2.4 KB
references/security-best-practices.mdmarkdown5.9 KB
scripts/README.mdmarkdown2.9 KB
scripts/configure-named-credential.shexecutablescript9.2 KB
scripts/set-api-credential.shexecutablescript4.9 KB
scripts/suggest_credential_setup.pyscript9.3 KB
scripts/templates/setup-credentials-with-csp.shexecutablescript5.9 KB
scripts/validate_integration.pyscript13.4 KB

references/cdc-guide.md

View on GitHub
<!-- Parent: integration-connectivity-generate/SKILL.md -->
# Change Data Capture (CDC) Guide

## Overview

Change Data Capture publishes change events for Salesforce records, enabling near real-time data synchronization with external systems.

## How CDC Works

```text
┌─────────────────────────────────────────────────────────────────┐
│  CHANGE DATA CAPTURE FLOW                                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  1. Record Created/Updated/Deleted in Salesforce                │
│     ↓                                                           │
│  2. Salesforce generates Change Event                           │
│     ↓                                                           │
│  3. Event published to {{Object}}ChangeEvent channel            │
│     ↓                                                           │
│  4. Apex Trigger or External Subscriber receives event          │
│     ↓                                                           │
│  5. Process event (sync, audit, notify)                         │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
```

## CDC vs Platform Events

| Feature | CDC | Platform Events |
|---------|-----|-----------------|
| Trigger | Automatic on DML | Manual publish |
| Schema | Predefined (object fields) | Custom defined |
| Use Case | Data sync/replication | Custom messaging |
| Control | Limited | Full control |

## Enabling CDC

### Via Setup

1. Go to **Setup → Integrations → Change Data Capture**
2. Select objects to enable
3. Save

### Supported Objects

- Most Standard objects (Account, Contact, Opportunity, etc.)
- Custom objects
- Some system objects (User, Group, etc.)

## Event Channel Names

| Object Type | Channel Name |
|-------------|--------------|
| Standard | `AccountChangeEvent`, `ContactChangeEvent` |
| Custom | `My_Object__ChangeEvent` (append ChangeEvent) |

## Change Event Structure

### ChangeEventHeader

```apex
EventBus.ChangeEventHeader header = event.ChangeEventHeader;

// Available methods
header.getChangeType();       // CREATE, UPDATE, DELETE, UNDELETE
header.getChangedFields();    // List of changed field API names
header.getRecordIds();        // Affected record IDs
header.getEntityName();       // Object API name
header.getCommitNumber();     // Transaction sequence
header.getCommitTimestamp();  // When change occurred
header.getTransactionKey();   // Unique transaction ID
```

### Change Types

| Type | Description | Event Contains |
|------|-------------|----------------|
| CREATE | New record | All field values |
| UPDATE | Record modified | Changed field values only |
| DELETE | Record deleted | Record IDs only |
| UNDELETE | Restored from bin | All field values |
| GAP_* | Events missed | Affected record IDs |
| GAP_OVERFLOW | Too many changes | Entity name |

### Field Values

- **Changed fields**: Contain new values
- **Unchanged fields**: Null
- Use `getChangedFields()` to know what changed

## Subscribing to CDC

### Apex Trigger

```apex
trigger AccountCDC on AccountChangeEvent (after insert) {
    for (AccountChangeEvent event : Trigger.new) {
        EventBus.ChangeEventHeader header = event.ChangeEventHeader;

        String changeType = header.getChangeType();
        List<String> changedFields = header.getChangedFields();
        List<String> recordIds = header.getRecordIds();

        switch on changeType {
            when 'CREATE' {
                // Handle new records
            }
            when 'UPDATE' {
                // Handle updates
            }
            when 'DELETE' {
                // Handle deletions
            }
        }
    }

    // Set checkpoint
    EventBus.TriggerContext.currentContext().setResumeCheckpoint(
        Trigger.new[Trigger.new.size()-1].ReplayId
    );
}
```

### External (CometD)

```text
Channel: /data/AccountChangeEvent
```

## Handling Specific Changes

### Filter by Changed Fields

```apex
// Only process if important fields changed
Set<String> importantFields = new Set<String>{'Status__c', 'Amount__c'};
List<String> changedFields = header.getChangedFields();

Boolean relevant = false;
for (String field : changedFields) {
    if (importantFields.contains(field)) {
        relevant = true;
        break;
    }
}

if (!relevant) return;
```

### Get New Values

```apex
// Access field values from event (UPDATE: only changed fields have values)
if (changedFields.contains('Status__c')) {
    String newStatus = event.Status__c;
    // Process status change
}
```

## Gap Events

Gap events indicate missed events:

### Types

| Event | Meaning | Action |
|-------|---------|--------|
| GAP_CREATE | Missed creates | Query and sync records |
| GAP_UPDATE | Missed updates | Query current state |
| GAP_DELETE | Missed deletes | Reconcile with source |
| GAP_UNDELETE | Missed restores | Query and sync |
| GAP_OVERFLOW | Too many changes | Full sync required |

### Handling Gaps

```apex
when 'GAP_CREATE', 'GAP_UPDATE', 'GAP_DELETE', 'GAP_UNDELETE' {
    // Query current state and sync
    List<Account> records = [
        SELECT Id, Name, Status__c
        FROM Account
        WHERE Id IN :header.getRecordIds()
    ];
    syncToExternalSystem(records);
}
when 'GAP_OVERFLOW' {
    // Trigger full sync batch job
    Database.executeBatch(new FullSyncBatch());
}
```

## Replay and Durability

### Retention

CDC events retained for **3 days** (72 hours).

### Replay ID

Each event has unique ReplayId for tracking:

```apex
String replayId = event.ReplayId;
```

### Resume Checkpoint

Critical for durability:

```apex
// Always set checkpoint at end of trigger
EventBus.TriggerContext.currentContext().setResumeCheckpoint(lastReplayId);
```

If trigger fails after checkpoint, processing resumes from that point.

## External Sync Pattern

```apex
public class AccountCDCHandler {

    public static void syncToExternal(AccountChangeEvent event) {
        EventBus.ChangeEventHeader header = event.ChangeEventHeader;

        Map<String, Object> payload = new Map<String, Object>{
            'recordIds' => header.getRecordIds(),
            'operation' => header.getChangeType(),
            'timestamp' => header.getCommitTimestamp(),
            'changedFields' => header.getChangedFields()
        };

        // Add field values for CREATE/UPDATE
        if (header.getChangeType() != 'DELETE') {
            payload.put('name', event.Name);
            payload.put('accountNumber', event.AccountNumber);
            // Add relevant fields
        }

        // Queue async callout
        System.enqueueJob(new ExternalSyncJob(payload));
    }
}
```

## Best Practices

### DO

1. **Set resume checkpoint** in every trigger
2. **Filter by relevant fields** to reduce noise
3. **Handle all change types** including GAPs
4. **Process idempotently** (events may replay)
5. **Use async** for external callouts
6. **Log changes** for debugging

### DON'T

1. **Don't throw exceptions** - catch and log
2. **Don't ignore GAP events** - they indicate data loss
3. **Don't assume single record** - batch DML creates multi-record events
4. **Don't block on external calls** - use Queueable

## Monitoring

### Event Delivery

Check for failures in:
- Setup → Platform Events → Monitor
- Debug logs for triggers

### Common Issues

| Issue | Cause | Solution |
|-------|-------|----------|
| Missing events | No CDC enabled | Enable in Setup |
| Duplicate processing | No idempotency | Check transactionKey |
| GAP events | Processing too slow | Optimize trigger, scale out |
| Timeout | Heavy processing | Move to async |

## Limits

| Limit | Value |
|-------|-------|
| Objects per org | 100 |
| Events per 15 minutes | Varies by edition |
| Event retention | 3 days (72 hours) |
| Replay window | 3 days |
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall