salesforce-integration-patternslisted
Install: claude install-skill ArieGoldkin/claude-forge
# Salesforce Integration Patterns
Production patterns for Salesforce CRM ↔ application backend integration (AWS Lambda, Python).
## Quick Start
### Client Setup
Use a global Salesforce client with Secrets Manager authentication:
```python
# utils/salesforce_client.py
from simple_salesforce import Salesforce
from aws_lambda_powertools import Logger
import boto3, json, os
class SalesforceClient:
def __init__(self):
self._client = None
self._secrets = boto3.client('secretsmanager')
@property
def client(self):
if not self._client:
creds = json.loads(self._secrets.get_secret_value(
SecretId=os.getenv("SALESFORCE_SECRET_NAME")
)["SecretString"])
self._client = Salesforce(**creds)
return self._client
sf_client = SalesforceClient()
```
### User Sync Pattern
Upsert application users to Salesforce Contacts using an external ID custom field:
```python
# Check + upsert pattern.
# SOQL has no bind-parameter API in simple_salesforce, so the value is
# interpolated — VALIDATE it first to prevent SOQL injection. user.id is your
# own PK, so a strict allowlist is both safe and sufficient.
import re
user_ext_id = str(user.id)
if not re.fullmatch(r"[A-Za-z0-9_-]+", user_ext_id):
raise ValueError("unexpected External_User_ID format")
existing = sf_client.client.query(
f"SELECT Id FROM Contact WHERE External_User_ID__c = '{user_ext_id}'"
)
# Tip: prefer upsert-by-external-id to skip