flow-vs-apex
Skill1 starsChanged 7 months agoMITView on GitHub
Decide whether a new piece of automation should be built as a Flow, an Apex Trigger, or another mechanism. Asks the user 6–8 quick questions, then recommends with rationale. No code generated.
In this repository53 other files it gives its agents.
- templates/CLAUDE.mdCLAUDE.md
- adrSkill
- agent-deploySkill
- agent-discoverSkill
- agent-eval-trendSkill
- agent-exchange-listSkill
- agent-specSkill
- agent-testSkill
- agent-vs-flow-vs-apexSkill
- before-vs-after-triggerSkill
- code-reviewSkill
- complexitySkill
- coverage-trendSkill
- dead-codeSkill
- dependency-graphSkill
- deploySkill
- destructive-changesSkill
- diff-deploySkill
- erdSkill
- field-impactSkill
- flaky-test-finderSkill
- flow-auditSkill
- fls-auditSkill
- gateway-configSkill
- generate-docsSkill
- limit-usageSkill
- lwc-vs-reactSkill
- mcp-tool-vs-restSkill
- notifySkill
- onboardSkill
- org-diffSkill
- org-exploreSkill
- package-versionSkill
- pattern-packSkill
- perf-reviewSkill
- permset-auditSkill
- pr-prepareSkill
- queueable-vs-batchSkill
- quick-deploySkill
- react-initSkill
- release-notesSkill
- scratch-orgSkill
- security-scanSkill
- sequence-diagramSkill
- sf-initSkill
- sharing-reviewSkill
- slack-agentSkill
- soql-analyzerSkill
- test-coverageSkill
- test-dataSkill
- test-planSkill
- trust-evalSkill
- trust-layer-auditSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
If the org cache exists, peek at active Flows on the affected object so the recommendation can reference existing automation.
- Distinctive: line 28
Ask in order. Skip questions that are obviously answered by the description.
- Distinctive: line 36
Are there sharing/security implications?: must respect record-level sharing?
- Distinctive: line 116
Always cite existing automation: if the org cache shows it.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
You are helping the user choose between Flow, Apex Trigger, Apex Queueable/Batch, Platform Event, or External Service for a new piece of automation. Ask the questions below in order, take their answers, then recommend with a one-paragraph rationale.
Read Project Config First (optional context)
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
ORG="$(sf_config_get '.platform.defaultTargetOrg' "$ENV")"If the org cache exists, peek at active Flows on the affected object so the recommendation can reference existing automation.
Input
$ARGUMENTS:
- (empty) — interactive Q&A
<one-line description>— interactive Q&A seeded with the description for context--object <Object>— pre-fill the affected object so the questions are concrete--non-interactive answers="..."— accept answers as a comma-separated list (for scripted use)
Decision questions
Ask in order. Skip questions that are obviously answered by the description.
- What's the input? record-triggered (insert/update/delete), scheduled, user-initiated (button/screen), platform event, callout from external?
- What's the volume? under 200 records per call, 200–10K per batch, > 10K?
- What's the operation? field set / record creation / cross-object update / external callout / async work / delete cleanup?
- Who owns it after build? the dev team (in source) or the admin team (declarative)?
- Does it need transaction control? rollback on partial failure, savepoints?
- Does it need callouts? outbound HTTP, MuleSoft, external systems?
- Are there sharing/security implications? must respect record-level sharing? Or run as system?
- Existing automation on the object? (Check
/argo:flow-audit <Object>if available)
Decision tree
record-triggered AND volume <= 200 AND simple field updates AND admin-owned
→ Flow (record-triggered, before-save if same-record, after-save otherwise)
record-triggered AND volume > 200 OR complex logic OR transaction control
→ Apex Trigger + TriggerHandler framework (SF-7)
scheduled AND volume <= 100 records of work
→ Schedulable Apex calling Queueable
scheduled AND volume > 100 records OR runtime > 10s
→ Database.Batchable (Batch Apex)
user-initiated screen AND admin-owned AND single-record
→ Screen Flow
user-initiated screen AND complex multi-step OR custom UI
→ LWC + Apex controller (SF-6 AuraEnabled)
external event in
→ Platform Event subscriber (Apex trigger on the __e channel) — see `pattern-pack add platform-events`
callout out, transactional
→ Apex with Named Credential (SF-15)
callout out, fire-and-forget after commit
→ Queueable with callout, with static guard (PRJ-6) — or Platform Event publish + external subscriberOutput
# Automation Choice: <one-line description>
## Answers
- Input: record-triggered (after-update on Order__c)
- Volume: up to 5,000 records per batch import
- Operation: cross-object update + outbound notification
- Owner: dev team
- Transaction control: rollback on failure required
- Callouts: yes — to Order Management API
- Sharing: must respect user sharing (caller is internal user)
- Existing automation: 1 active Flow on Order__c (`Order_Set_Region_AfterSave`)
## Recommendation: **Apex Trigger + Queueable for callout**
### Why
- Volume of 5K records exceeds Flow's reliable threshold (Flow is fine up to ~200, brittle above)
- Transaction control rules out Flow (no native rollback; partial-record DML)
- Callout in transaction would block the trigger; Queueable defers it, respects governor limits, and chains cleanly
- Coexisting Flow on the same object (`Order_Set_Region_AfterSave`) is fine — Flow runs first (before-save Flows always do; after-save run before triggers in the order documented [here](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm))
### Implementation outline (for @architect / @apex-dev)
- Trigger: `OrderTrigger` (after update) → `TriggerDispatcher.Run(new OrderTriggerHandler())`
- Handler: collect changed records, push to `OrderNotifyQueueable` (with PRJ-6 static guard)
- Queueable: callout via Named Credential `Order_API` (SF-15), retry policy on transient failure (PE-5 if you ever migrate to Platform Event)
### Patterns referenced
- SF-7 (Trigger Handler Framework)
- SF-15 (HTTP Callout via Named Credential)
- PRJ-6 (Queueable with Static Guard)
### Alternatives considered
- **Pure Flow**: would have to subdivide work into chunks under 200; transaction-control limits make this brittle for the 5K case
- **Platform Event**: viable if you control both publisher and consumer and want decoupling; overkill for a single project-internal notification
- **Outbound Message**: legacy; not recommended for new workExit codes
- 0 — recommendation produced
- 2 — input parsing error
Rules
- Don't generate code. This skill recommends;
@architect/@apex-devimplement - Always cite existing automation if the org cache shows it. Coexisting Flow + Apex is fine but the dev needs to know
- Be opinionated. "It depends" is unhelpful — pick one and explain
- Show alternatives. The user may know something you don't; surface 1–2 alternatives so they can push back
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

