The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Check what else runs on an object before shipping AI-Generated changes (opens in a new tab)

You will learn a repeatable way to list the active Flows, Validation Rules and triggers on an object using the Salesforce CLI and pandas, so a reviewer can see what a change will collide with before it ships.

  1. Export active Flows with SOQL
  2. Export active Validation Rules
  3. Export active triggers via Tooling API
  4. Filter the exports by object in pandas
  5. Attach the tables to the ticket for review
The article's method for finding existing automation on an object before shipping an AI-generated change

The article argues that an AI-drafted Flow, Apex class or Validation Rule must be checked against everything else already running on the same object. Before review, the author suggests finding that automation first, since a clean-looking change can clash with an existing rule, loop with another Flow, or overwrite a field a batch expects to be empty.

The method uses the Salesforce CLI to export active Flows with a SOQL query on FlowDefinitionView, and active Validation Rules and triggers through the Tooling API. Triggers are matched on their object, while Flows have no dedicated object field, so the author scans API name, label and description instead, which is imperfect but faster than opening every Flow. A short pandas script then filters the three exports for a chosen object such as Opportunity and produces a review agenda.

The author adds that managed package automation will also show up in these results. Managed items cannot be edited but can still fire after a change, so they belong in a separate list. The tables should be attached to the ticket so the next reviewer does not have to rerun the queries.

The piece also proposes three test cases a model often skips: a record that must be blocked with a clear message, a record that must pass even when a field arrives late, and the same change run by a non-admin user. It lists reasons to wait a day before shipping, such as a missing description, tests that check coverage rather than the business rule, or a field the model invented. The article is practical and short, and the queries are the main takeaway.

Read the original at dev.to (opens in a new tab)

Worth reading?

Must-read

Catching AI-Generated Apex that breaks governor Limits with budget tests in CI (opens in a new tab)

You will learn how to measure governor limit consumption in Apex tests, set per-context budgets, and close the loop so AI agents fix limit-heavy code before it merges.

Why read this

The post includes a snapshot class pattern, a limits table and a retry-and-escalation design.

  1. Agent pushes code with bulk tests
  2. CI measures limit consumption
  3. Breach sends feedback to agent
  4. Up to two refactor attempts
  5. Human architect review if still failing
How the CI loop handles a governor limit breach in agent-written code

The article argues that AI-generated Apex can be functionally correct and fully unit-tested yet still exhaust shared transaction budgets, because agents build each feature in isolation and small additions compound until a governor limit is breached. Standard small-data tests rarely expose this, and since governor limits are platform capacity ceilings, the author recommends treating them as architectural contracts and enforcing them automatically before code merges. It illustrates the compounding with a sprint-by-sprint example where SOQL consumption climbs from 15% to 59% through individually harmless changes.

The proposed approach has several parts. Teams should supply a shared, immutable GovernorLimitSnapshot test utility, require agents to write bulk tests of 200 records that capture before and after snapshots, and have CI verify that these test conventions are present. A table compares synchronous and asynchronous limits, and a budget-allocation table recommends consumption thresholds by execution context: roughly 40 to 50% for trigger code, 60 to 70% for service classes, 80 to 85% for isolated asynchronous jobs, and 20 to 30% for Scheduled Apex. Snapshots should be taken just before Test.stopTest() so the synchronous footprint is measured separately from asynchronous work, which is tested in its own method.

The article then describes a closed feedback loop in CI. When a test breaches its budget, a structured prompt containing the metric, consumption, threshold and required optimization steps goes back to the agent, which gets up to three attempts, with the delta between attempts supplied on later tries. If the third attempt fails, the merge is blocked and a human architect is asked to review, possibly moving the logic to Queueable. Agents must not be allowed to weaken tests or thresholds, and the author notes that some limits, such as callouts and Platform Event publishing, need production monitoring as well. Thresholds should start generous, use warning and violation tiers, and be tightened over time, with a closing checklist for rolling the pattern out.

Read the original at Salesforce Architects (opens in a new tab)

Worth reading?