Org Skills

salesforce-automation

Design and build Salesforce automation for Spring '26 — choosing between record-triggered, scheduled, screen, autolaunched and platform-event-triggered Flow, Apex triggers, Flow Approval Processes and Flow Orchestration; before-save vs after-save, entry conditions, Trigger Order, bulk-safe flow patterns, the Custom Error element, fault paths, run context, subflows and invocable actions (including flows used as Agentforce agent actions), Flow Tests, and migrating Workflow Rules and Process Builder.

Download .zip Raw Source
When agents use itUse this whenever the user asks "Flow or Apex?", builds or debugs a flow or a `.flow-meta.xml` file, hits "Too many SOQL queries" or CPU limits from flows, asks about record-triggered flow order, Flow Trigger Explorer, several flows plus a trigger on one object, approvals for a record, scheduled paths, `sf flow run test`, or Migrate to Flow. Also apply it when an Apex trigger request is really a same-record field update that a before-save flow should own.

Install

Copilot (VS Code, Visual Studio, Copilot CLI and github.com) reads skills from the repository — commit them so the whole team gets them.

npx skills add AGCO-Global/org-skills --skill salesforce-automation -a github-copilot
# or with the org installer (adds .github/skills/salesforce-automation):
npx -y github:AGCO-Global/org-skills add skill salesforce-automation

Uses the open skills CLI. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, OpenCode, Windsurf and 60+ others — it asks which agent to install into.

npx skills add AGCO-Global/org-skills --skill salesforce-automation
# user-level instead of project-level:
npx skills add AGCO-Global/org-skills --skill salesforce-automation -g

Installs the salesforce-automation-skills plugin, which bundles all Salesforce / Automation skills and keeps them updated.

/plugin marketplace add AGCO-Global/org-skills
/plugin install salesforce-automation-skills@org-skills
# or just this skill, in this repository:
npx skills add AGCO-Global/org-skills --skill salesforce-automation -a claude-code

Use Download .zip above, then upload it under Customize → Skills → Upload skill. Team and Enterprise admins can sync this repo as a plugin marketplace instead.

Installs into .agents/skills/, which Codex reads.

npx skills add AGCO-Global/org-skills --skill salesforce-automation -a codex

Installs into Cursor's skills folder.

npx skills add AGCO-Global/org-skills --skill salesforce-automation -a cursor

Installs into Gemini CLI's skills folder.

npx skills add AGCO-Global/org-skills --skill salesforce-automation -a gemini-cli

Nothing to install. Press Download .zip above, unzip it, and drop the salesforce-automation folder into your tool's skills folder — .claude/skills/, .github/skills/, .cursor/skills/ or .agents/skills/. Step-by-step, per tool: How to use it. For any other tool with rules or custom prompts, Copy SKILL.md and paste it in — it is plain Markdown.

The npx commands need Node.js 20+ and use your normal git sign-in to GitHub, so they work while the repository is private. Without Node.js, see the No Node.js tab — a skill is a folder of Markdown, so copying it in works just as well.

Skill contents

Salesforce Automation

Targets: Salesforce Spring '26 (API 66.0) · Verified: 2026-09 against https://architect.salesforce.com/docs/architect/decision-guides/guide/record-triggered, help.salesforce.com (Flow Builder, Flow Approval Processes) and the salesforcecli/plugin-flow command reference

Orgs rot when Flow, Apex and leftover Workflow Rules all act on one object with no owner. Good automation is a written strategy per object: one entry-point mechanism, explicit order, bulk-safe elements, a fault path on everything that can fail, and tests that run in CI.

1. Decide first

Question Default Change when
Flow or Apex on this object? One entry-point mechanism per object: record-triggered flows or one Apex trigger (decision guide) Apex when logic needs cross-object aggregation, callouts with retry, recursion control or high volume; if both already exist, an ADR names which owns which fields and nothing adds a third
How many record-triggered flows? Several focused flows with tight entry conditions and an explicit Trigger Order Merge flows only when they share the same entry condition and owner
Same-record field defaults or validation Before-save flow; block the save with the Custom Error element Simple field-level integrity → validation rule
Related records, notifications, actions After-save flow Callouts or slow work → Run Asynchronously path or Queueable Apex
Time-based work Scheduled path on the record-triggered flow Org-wide sweep → schedule-triggered flow (≤ 250 000 records per 24 h, or 200 × user licences if greater) or Batch Apex/Apex Cursors
Approvals Flow Approval Process (approval orchestration with stages and steps) Classic Approval Process only where one already exists; multi-object, multi-team work that is not an approval → Flow Orchestration
Logic Flow cannot express @InvocableMethod Apex with a List<Request> signature (see apex-development) —
Run context Default (user context for screen flows, system context for record-triggered) System Context Without Sharing only with a written reason; see salesforce-security

Workflow Rules and Process Builder cannot be created any more: migrate them (section 6), never extend them.

2. Write the object's automation strategy

Record it next to the code (docs/automation/<Object>.md); template and the full coexistence rule in references/object-automation-strategy.md.

Object: Order__c            Entry point: record-triggered Flow (no Apex trigger)
10  Order_Before_Upsert       before save   create/update   Status, Region defaults; Custom Error on bad dates
20  Order_After_Update        after save    Status → Approved   creates Shipment__c, publishes Order_Event__e;
                                                                async path handles Slack/email actions
Invocable Apex: OrderPricingAction (called from 20)   Scheduled path: +3 days after Due_Date__c → escalate
Owner: Order team — changes need a review in Flow Trigger Explorer
  • Trigger Order values 1–2000; flows without a value run between 1000 and 1001 in creation order, so number every flow. Check the result in Flow Trigger Explorer.
  • Two flows must never write the same field. Same-record updates belong in before-save flows, never in an after-save Update Records on $Record.
  • Naming: Object · Record Type Label (if applicable) · Context · Event — Problem Asset_MQ Standard_Before_Upsert, Order_After_Update. There is no free-text purpose segment, so the scheme allows one flow per object × record type × context × event; put the purpose, owner and ticket in the description. Rule owned by salesforce-org-conventions.
  • Every flow carries a feature toggle, the way validation rules reference User.Ignore_Validation_Rules__c, so it can be switched off without deactivating and redeploying.

3. Build bulk-safe flows

A record-triggered flow interview runs per record, but the platform bulkifies DML and queries across the 200-record chunk only when the element sits outside a loop. Target shape for an after-save flow:

Start (after save, Status = 'Approved', "only when updated to meet the condition")
→ Get Records  Shipment_Config__mdt (once, filtered)
→ Loop over $Record.Order_Lines__r ids   → Assignment: add new Shipment_Line__c to colLines
→ Create Records colLines (once, after the loop)   → Fault → Subflow Log_Flow_Fault
  1. No Get, Create, Update or Delete element inside a Loop. Collect in the loop, do one DML after it.
  2. Entry conditions on Start plus "only when a record is updated to meet the condition requirements": this is the recursion guard and the limits saver.
  3. Before-save: assign to $Record; no Update element, no DML consumed.
  4. Filter Get Records on indexed fields and use Collection Filter/Sort and Transform elements instead of looping to filter.
  5. Callouts (HTTP Callout action, External Services) only on the async path or in screen flows; a callout after DML in the same transaction fails.
  6. Limits that bite: SOQL 100, DML 150 and CPU 10 s are shared with Apex in the transaction. The old 2 000-executed-elements limit no longer applies to flows on API 57.0+.

Element-by-element trace, .flow-meta.xml keys (triggerType, recordTriggerType, triggerOrder, runInMode, status) and the limits table are in references/bulk-safe-flow.md.

4. Errors and run context

  • Fault connector on every Get, DML and Action element → one shared fault subflow that logs through an invocable logger (custom object or Platform Event, so the log survives rollback).
  • A fault in a record-triggered flow rolls back the whole transaction; async and scheduled paths are separate transactions and retry, so make them idempotent.
  • Custom Error element = user-facing validation message on the record or a field. Use it instead of a fault-and-email pattern.
  • Platform-event-triggered flows run in system context as the Automated Process user unless the org sets a default workflow user: grant that user the permissions.
  • Send flow error emails to a distribution list (Process Automation Settings), not to the last modifier.
  • Screen flows: validate on the screen, one Create/Update at the end, a confirmation screen; custom screen components come from lwc-development.

5. Approvals, orchestration and agent actions

Need Use
New approval on a record Flow Approval Process: autolaunched or record-triggered approval orchestration with stages, approval steps (work items to users, groups, queues) and background steps; users submit with the Request Approval record-page component
Existing classic Approval Process that works Leave it; do not build new classic processes
Multi-stage work across teams and objects that is not an approval Flow Orchestration with interactive and background steps

Keep state transitions inside the approval process; other flows react to the status field. An autolaunched flow exposed as an Agentforce agent action needs clear labels and descriptions on the flow and every input/output variable, because the agent reads them as its contract.

6. Test, deploy, migrate

  • Flow Tests are created in Flow Builder (View Tests, or Convert to test from a debug run). They cover record-triggered flows only; no delete-triggered flows, no asynchronous paths, max 200 tests per flow. Cover those gaps with Apex tests (apex-testing).
  • CI: sf flow run test --target-org ci --class-names Order_After_Update --synchronous --code-coverage --result-format junit --output-dir test-results; sf logic run test (Beta) runs Apex and Flow tests together. Both need View All Data.
  • Static analysis: sf code-analyzer run --workspace force-app --rule-selector flow (Code Analyzer v5 flow engine).
  • Deploying flows as active in production needs Deploy processes and flows as active and 75 % flow test coverage from Apex tests. Details and version clean-up in references/flow-testing-and-deployment.md.
  • Workflow Rule / Process Builder migration playbook: references/object-automation-strategy.md § Migration.

7. Deliverable format

## Decision — entry-point mechanism for the object and why; ADR text if Flow and Apex coexist
## Strategy — the per-object table (order, flow, context, entry condition, fields owned)
## Flow design — element trace per flow (Start → … → Fault), variables, subflows, invocables
## Tests — Flow Tests to create, Apex tests for delete/async gaps, the sf commands
## Risks — limits per 200 records, fields with more than one writer, migration steps

Checklist

  • One entry-point mechanism per object, or an ADR naming field ownership where Flow and Apex coexist
  • Every record-triggered flow has entry conditions and an explicit Trigger Order
  • Same-record updates are before-save; no after-save update of $Record
  • No Get/Create/Update/Delete inside a Loop; bulk-tested with 200 records
  • Every Get, DML and Action element has a fault path to the shared fault subflow
  • Validation uses Custom Error or a validation rule, not a fault
  • Callouts only on async paths or screen flows; async paths idempotent
  • New approvals are Flow Approval Processes
  • Flow Tests exist and run with sf flow run test; delete and async paths covered by Apex tests
  • No hard-coded Ids, emails or URLs: Custom Metadata, Custom Labels or $Setup
  • No active Workflow Rules or Process Builders left on the object

Anti-patterns

  • "One flow per object" mega-flow with 40 decisions → several focused flows with entry conditions and Trigger Order.
  • Adding an Apex trigger to an object driven by flows (or the reverse) without an ADR → keep one entry point; extend it, or call invocable Apex from the flow.
  • Get or Update inside a Loop → collect, then one DML after the loop.
  • After-save flow updating its own record → before-save assignment.
  • Recursion "fixed" with a checkbox the flow toggles → entry condition with "only when updated to meet the condition".
  • No fault connectors; errors emailed to the last admin → shared fault subflow and a distribution list.
  • New classic Approval Process or Process Builder "just this once" → Flow Approval Process / record-triggered flow.
  • sf flow test run in CI → the command is sf flow run test.

Go deeper

  • references/object-automation-strategy.md — the Flow/Apex coexistence rule in full, ADR template, Trigger Order rules, Workflow Rule and Process Builder migration playbook. Other Salesforce skills link here for the rule.
  • references/bulk-safe-flow.md — element trace of a bulk-safe after-save flow, the .flow-meta.xml keys to check, flow limits table.
  • references/flow-testing-and-deployment.md — Flow Test scope and limits, CLI commands, active deployment, version clean-up, Code Analyzer flow rules.
  • Sibling skills: apex-development for triggers and invocable Apex, apex-testing for tests, lwc-development for screen components, salesforce-integration for callouts and events, salesforce-devops for pipelines, salesforce-code-review for reviews, salesforce-org-conventions for the org's naming and mandated patterns.

References

Deeper material the agent loads only when needed.