salesforce
Build integrations and automations with Salesforce. Use when a user asks to work with Salesforce CRM, manage leads, contacts, opportunities, and accounts, build SOQL/SOSL queries, create Apex triggers and classes, configure Flows, integrate via REST/SOAP/Bulk APIs, build Lightning Web Components, set up Salesforce DX projects, manage deployments, work with Platform Events, build Connected Apps, or automate Salesforce workflows. Covers Sales Cloud, Service Cloud, APIs, Apex, LWC, and DevOps.
What this skill does
# Salesforce
## Overview
Build on the Salesforce platform — the world's largest CRM. This skill covers REST and Bulk API integration, SOQL/SOSL queries, Apex triggers and classes, Flow automation, Platform Events for real-time messaging, Connected Apps for OAuth2, Salesforce DX for source-driven development, and deployment pipelines. Suitable for CRM integrations, custom business logic, and extending Salesforce with external systems.
## Instructions
### Step 1: Authentication — Connected App & OAuth2
Create a Connected App (Setup → App Manager → New Connected App), enable OAuth, set scopes: `api`, `refresh_token`, `full`.
**JWT Bearer Flow (server-to-server):**
```typescript
import jwt from "jsonwebtoken";
import fs from "fs";
async function getSalesforceToken(clientId: string, username: string) {
const privateKey = fs.readFileSync("server.key", "utf-8");
const token = jwt.sign({
iss: clientId, sub: username, aud: "https://login.salesforce.com",
exp: Math.floor(Date.now() / 1000) + 300,
}, privateKey, { algorithm: "RS256" });
const res = await fetch("https://login.salesforce.com/services/oauth2/token", {
method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", assertion: token }),
});
const data = await res.json();
return { accessToken: data.access_token, instanceUrl: data.instance_url };
}
```
**API helper:**
```typescript
async function sf(method: string, path: string, token: string, instanceUrl: string, body?: any) {
const res = await fetch(`${instanceUrl}/services/data/v60.0${path}`, {
method,
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : undefined,
});
if (!res.ok) throw new Error(`SF ${res.status}: ${await res.text()}`);
return res.status === 204 ? null : res.json();
}
```
### Step 2: SOQL & SOSL Queries
```typescript
// Query with relationships
const opps = await sf("GET", `/query?q=${encodeURIComponent(`
SELECT Id, Name, Amount, StageName, CloseDate, Account.Name, Owner.Name,
(SELECT Id, Subject, Status FROM Tasks WHERE Status != 'Completed')
FROM Opportunity WHERE StageName NOT IN ('Closed Won','Closed Lost') AND Amount > 50000
ORDER BY CloseDate ASC`)}`, token, instanceUrl);
// Aggregate
const summary = await sf("GET", `/query?q=${encodeURIComponent(`
SELECT StageName, COUNT(Id) cnt, SUM(Amount) total FROM Opportunity
WHERE CloseDate = THIS_FISCAL_YEAR GROUP BY StageName`)}`, token, instanceUrl);
// Paginate large results
let url = `/query?q=${encodeURIComponent("SELECT Id, Name FROM Contact")}`;
const all = [];
while (url) {
const data = await sf("GET", url, token, instanceUrl);
all.push(...data.records);
url = data.nextRecordsUrl || null;
}
// SOSL full-text search
const search = await sf("GET",
`/search?q=${encodeURIComponent("FIND {TechStart} RETURNING Lead(Name,Email),Contact(Name),Account(Name)")}`,
token, instanceUrl);
```
### Step 3: REST API — CRUD & Composite
```typescript
// Create Account + Contact + Opportunity
const account = await sf("POST", "/sobjects/Account", token, instanceUrl, {
Name: "TechStart GmbH", Industry: "Technology", BillingCity: "Berlin", BillingCountry: "Germany",
});
await sf("POST", "/sobjects/Contact", token, instanceUrl, {
FirstName: "Marta", LastName: "Schmidt", Email: "[email protected]", AccountId: account.id, Title: "CTO",
});
await sf("POST", "/sobjects/Opportunity", token, instanceUrl, {
Name: "TechStart — Enterprise License", AccountId: account.id,
StageName: "Qualification", Amount: 150000, CloseDate: "2026-06-30",
});
// Update and upsert
await sf("PATCH", `/sobjects/Opportunity/${oppId}`, token, instanceUrl, { StageName: "Negotiation/Review", Amount: 175000 });
await sf("PATCH", `/sobjects/Account/External_ID__c/TECHSTART-001`, token, instanceUrl, { Name: "TechStart GmbH" });
// Composite API (up to 25 requests in one call)
await sf("POST", "/composite", token, instanceUrl, {
allOrNone: true,
compositeRequest: [
{ method: "POST", url: "/services/data/v60.0/sobjects/Account", referenceId: "newAccount", body: { Name: "NewCo" } },
{ method: "POST", url: "/services/data/v60.0/sobjects/Contact", referenceId: "newContact",
body: { LastName: "Doe", AccountId: "@{newAccount.id}" } },
],
});
```
### Step 4: Bulk API 2.0
```typescript
const job = await sf("POST", "/jobs/ingest", token, instanceUrl, {
object: "Contact", operation: "upsert", externalIdFieldName: "Email", contentType: "CSV",
});
await fetch(`${instanceUrl}/services/data/v60.0/jobs/ingest/${job.id}/batches`, {
method: "PUT",
headers: { Authorization: `Bearer ${token}`, "Content-Type": "text/csv" },
body: `FirstName,LastName,Email,AccountId\nMarta,Schmidt,[email protected],${accountId}`,
});
await sf("PATCH", `/jobs/ingest/${job.id}`, token, instanceUrl, { state: "UploadComplete" });
```
### Step 5: Apex & Platform Events
**Trigger (auto-task on high-value opportunities):**
```apex
trigger OpportunityTrigger on Opportunity (after insert) {
List<Task> tasks = new List<Task>();
for (Opportunity opp : Trigger.new) {
if (opp.Amount >= 100000) {
tasks.add(new Task(Subject='Review: ' + opp.Name, WhatId=opp.Id,
OwnerId=opp.OwnerId, ActivityDate=Date.today().addDays(3), Priority='High'));
}
}
if (!tasks.isEmpty()) insert tasks;
}
```
**Custom REST endpoint:**
```apex
@RestResource(urlMapping='/custom/deals/*')
global class DealAPI {
@HttpGet
global static Map<String, Object> getActiveDealsSummary() {
AggregateResult[] results = [SELECT StageName, COUNT(Id) cnt, SUM(Amount) total
FROM Opportunity WHERE IsClosed = false GROUP BY StageName];
List<Map<String, Object>> stages = new List<Map<String, Object>>();
for (AggregateResult ar : results)
stages.add(new Map<String, Object>{'stage'=>ar.get('StageName'),'count'=>ar.get('cnt'),'total'=>ar.get('total')});
return new Map<String, Object>{'stages'=>stages, 'generatedAt'=>Datetime.now()};
}
}
```
**Platform Events** — define `Deal_Closed__e` with fields in Setup, publish from Apex with `EventBus.publish(event)`, subscribe externally via CometD Streaming API.
### Step 6: SFDX & CI/CD
```bash
sf project generate --name my-project && cd my-project
sf org login web --alias myorg
sf project retrieve start --target-org myorg
sf project deploy start --source-dir force-app --target-org myorg
sf apex test run --target-org myorg --code-coverage --result-format human
```
**GitHub Actions deploy:**
```yaml
steps:
- uses: actions/checkout@v4
- run: npm install -g @salesforce/cli
- run: echo "${{ secrets.SF_AUTH_URL }}" > auth.txt && sf org login sfdx-url --sfdx-url-file auth.txt --alias prod
- run: sf project deploy start --source-dir force-app --target-org prod --test-level RunLocalTests
```
### Step 7: Integration Patterns
**Change Data Capture (SF → external):**
```typescript
client.subscribe("/data/OpportunityChangeEvent", async (event: any) => {
const { changeType, recordIds } = event.payload.ChangeEventHeader;
if (changeType === "UPDATE" || changeType === "CREATE") {
for (const id of recordIds) {
const record = await sf("GET", `/sobjects/Opportunity/${id}`, token, instanceUrl);
await externalDb.upsert("opportunities", { sf_id: id, name: record.Name, amount: record.Amount, stage: record.StageName });
}
}
});
```
**External webhook → Salesforce (Stripe example):**
```typescript
app.post("/webhook/stripe", async (req, res) => {
if (req.body.type === "payment_intent.succeeded") {
const payment = req.body.data.object;
const opp = await sf("GET",
`/query?q=${encodeURIComponent(`SELECT Id FROM Opportunity WHERE Stripe_Payment_ID__c = '${payment.id}'`)}`,
token, instanceUrl);
if (opp.records.length > 0) {
awaiRelated in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.