/salesforce-pack:salesforce-reference-architecturefrom salesforce-pack
Provides production-ready architecture patterns for Salesforce integrations using jsforce, SFDX, and event-driven sync. Covers Node.js integration app structure, SFDX metadata projects, and sync models.
Ships in salesforce-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Production-ready architecture patterns for Salesforce integrations, covering Node.js integration apps, SFDX metadata projects, and event-driven sync architectures.
my-sf-integration/
├── src/
│ ├── salesforce/
│ │ ├── connection.ts # Singleton jsforce connection with auto-refresh
│ │ ├── types.ts # Typed sObject interfaces (Account, Contact, etc.)
│ │ ├── queries.ts # SOQL query builders
│ │ ├── mutations.ts # Create/update/delete operations
│ │ └── events.ts # CDC and Platform Event subscribers
│ ├── services/
│ │ ├── account-sync.ts # Business logic for Account sync
│ │ ├── contact-sync.ts # Business logic for Contact sync
│ │ └── opportunity-sync.ts # Pipeline/forecast sync
│ ├── api/
│ │ ├── routes.ts # Express/Fastify routes
│ │ └── health.ts # Health check with SF connectivity
│ ├── jobs/
│ │ ├── full-sync.ts # Scheduled full data sync
│ │ └── incremental-sync.ts # CDC-based incremental sync
│ └── index.ts
├── tests/
│ ├── unit/ # Mocked jsforce tests
│ └── integration/ # Live sandbox tests
├── config/
│ ├── default.json # Shared config
│ └── production.json # Production overrides
└── package.json
my-sf-app/
├── force-app/main/default/
│ ├── classes/ # Apex classes
│ │ ├── AccountTriggerHandler.cls
│ │ ├── ContactService.cls
│ │ └── IntegrationService.cls
│ ├── triggers/ # Apex triggers
│ │ └── AccountTrigger.trigger
│ ├── lwc/ # Lightning Web Components
│ │ └── accountList/
│ ├── objects/ # Custom object metadata
│ │ └── Integration_Log__c/
│ ├── permissionsets/
│ │ └── Integration_API_Access.permissionset-meta.xml
│ └── flows/ # Screen/record-triggered flows
├── scripts/apex/ # Anonymous Apex scripts
├── config/
│ └── project-scratch-def.json
└── sfdx-project.json
┌─────────────┐ SOQL Query ┌─────────────┐
│ Your App │ ──────────────────▶ │ Salesforce │
│ (cron job) │ SELECT ... WHERE │ Org │
│ │ ◀────────────────── │ │
│ │ JSON Records │ │
└─────────────┘ └─────────────┘
Pros: Simple, works with any edition
Cons: Latency (polling interval), wastes API calls on empty polls
Use: Small data volumes, non-real-time requirements
┌─────────────┐ ┌─────────────┐
│ Your App │ ◀─── CDC Events ─── │ Salesforce │
│ (listener) │ /data/Change* │ Org │
│ │ │ │
│ │ ── REST API ───────▶ │ │
│ │ Write-back │ │
└─────────────┘ └─────────────┘
Pros: Real-time, no wasted API calls, scalable
Cons: Requires Enterprise+, CDC setup, event replay handling
Use: Real-time sync, high-volume changes
┌─────────────┐ SQL Queries ┌─────────────┐
│ Your App │ ──────────────────▶ │ Postgres │
│ │ ◀────────────────── │ (Heroku DB) │
└─────────────┘ └──────┬───────┘
│
Heroku Connect
(automatic sync)
│
┌──────▼───────┐
│ Salesforce │
│ Org │
└─────────────┘
Pros: Zero API calls from your app, automatic bi-directional sync
Cons: Heroku cost, 10-min sync delay, limited to standard objects
Use: Heavy read/write, SQL-friendly teams
| Decision | Recommendation | Rationale |
|---|---|---|
| Connection management | Singleton with auto-refresh | 1 connection per process, handles token expiry |
| SOQL queries | Typed query builders | Prevents field name typos, enables refactoring |
| Bulk operations | Bulk API 2.0 for 10K+, Collections for <200 | Optimizes API call consumption |
| Error handling | Map SF error codes to domain errors | INVALID_FIELD → SchemaError, etc. |
| Real-time sync | CDC over polling | No wasted API calls, sub-second latency |
| Data mapping | Explicit field mapping layer | Decouples app schema from SF schema |
| Testing | Mock jsforce in unit tests | Fast tests without org dependency |
// src/salesforce/mappers.ts
// Decouple your app's domain model from Salesforce field names
interface AppContact {
id: string;
firstName: string;
lastName: string;
email: string;
companyId: string;
}
function fromSalesforceContact(sf: any): AppContact {
return {
id: sf.Id,
firstName: sf.FirstName || '',
lastName: sf.LastName,
email: sf.Email || '',
companyId: sf.AccountId || '',
};
}
function toSalesforceContact(app: Partial<AppContact>): Record<string, any> {
const sf: Record<string, any> = {};
if (app.firstName !== undefined) sf.FirstName = app.firstName;
if (app.lastName !== undefined) sf.LastName = app.lastName;
if (app.email !== undefined) sf.Email = app.email;
if (app.companyId !== undefined) sf.AccountId = app.companyId;
return sf;
}
| Issue | Cause | Solution |
|---|---|---|
| Tight coupling to SF schema | Direct field access | Add mapping layer |
| N+1 queries | Loop with individual queries | Use relationship SOQL or Collections |
| Stale cache | TTL too long | Use CDC events to invalidate |
| Event loss | No replay tracking | Persist last replayId |
For multi-environment setup, see salesforce-multi-env-setup.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub flight505/skill-forge --plugin salesforce-pack30 skills in this plugin
/salesforce-advanced-troubleshootingApply Salesforce advanced debugging with debug logs, SOQL query plans, and EventLogFile analysis.
Use when standard troubleshooting fails, investigating SOQL performance issues,
or analyzing Apex governor limit violations.
Trigger with phrases like "salesforce hard bug", "salesforce debug log",
"salesforce governor limit", "salesforce query plan", "salesforce deep debug", "SOQL slow".
/salesforce-architecture-variantsChoose and implement Salesforce integration architecture patterns for different scales.
Use when designing new Salesforce integrations, choosing between polling/event-driven/Heroku Connect,
or planning migration paths for Salesforce applications.
Trigger with phrases like "salesforce architecture", "salesforce integration pattern",
"how to structure salesforce integration", "salesforce event-driven", "salesforce Heroku Connect".
/salesforce-ci-integrationConfigure Salesforce CI/CD with GitHub Actions, SFDX deployments, and Apex testing.
Use when setting up automated testing, configuring CI pipelines for metadata deployment,
or integrating Salesforce tests into your build process.
Trigger with phrases like "salesforce CI", "salesforce GitHub Actions",
"salesforce automated tests", "CI salesforce", "sfdx deploy CI".
/salesforce-common-errorsDiagnose and fix Salesforce common errors, SOQL issues, and API exceptions.
Use when encountering Salesforce errors, debugging failed requests,
or troubleshooting integration issues.
Trigger with phrases like "salesforce error", "fix salesforce",
"salesforce not working", "debug salesforce", "SOQL error", "salesforce exception".
/salesforce-core-workflow-aExecute Salesforce CRUD operations on standard sObjects with SOQL and REST API.
Use when creating, reading, updating, or deleting Accounts, Contacts, Leads,
or Opportunities via the Salesforce API.
Trigger with phrases like "salesforce CRUD", "salesforce create record",
"salesforce update account", "salesforce SOQL query", "salesforce REST API".
/salesforce-core-workflow-bExecute Salesforce Bulk API 2.0 and Composite API operations for high-volume data.
Use when importing/exporting large datasets, performing multi-object transactions,
or chaining dependent API calls.
Trigger with phrases like "salesforce bulk API", "salesforce composite",
"salesforce batch", "salesforce mass import", "salesforce large data".
Other plugins' skills for the same job