On this page
- What counts as technical debt in a Salesforce org?
- How do you know the debt is real?
- How do you grade each of the six areas?
- How do you find the debt yourself?
- In what order should you pay it down?
- What does it cost to leave the debt alone?
- How does Clientell AI help, and is it safe?
- Sources
- Questions people ask
Salesforce technical debt is the accumulated cost of old code, dead metadata and automation nobody owns. You measure it in six areas (Apex classes, Apex triggers, Flows, Lightning Web Components, Workflow Rules and metadata), grade each one, and fix the lowest grade first.
Clientell AI, the AI Salesforce admin, grades all six areas for you in a free, read-only scan. Apex is Salesforce's Java-like programming language. A Flow is a point-and-click automation built in Flow Builder. SOQL (Salesforce Object Query Language) reads records, DML (data manipulation language) writes them, and LWC (Lightning Web Component) is the newer UI code.
What counts as technical debt in a Salesforce org?
Six patterns cover almost all of it.
- Governor risks in Apex. A SOQL query or a DML statement inside a loop works on five records and fails on a full batch. Salesforce enforces governor limits, for example 100 SOQL queries in one synchronous transaction.
- Test coverage gaps. Salesforce requires 75% Apex test coverage to deploy to production. Classes below that line block releases.
- Several triggers on one object. Salesforce does not guarantee the order they run in. The usual fix is one trigger per object that calls a handler class, as the trigger best practices describe.
- Unsupported automation. Salesforce ended support for Workflow Rules and Process Builder on December 31, 2025. Active ones still run, but they get no bug fixes.
- Dead metadata. Custom fields nobody fills, Flows stuck in Draft, layouts assigned to no one and profiles with zero users.
- Unowned automation. Flows, classes and fields with a blank
Descriptionand no named owner.
The six compound. Weak Apex coverage usually travels with old Workflow Rules and unused fields, because nobody runs regular hygiene.
How do you know the debt is real?
Look for three signals. Deploys fail more often, with test failures and dependency conflicts during validation. New features take longer, because adding a field means checking every automation on the object first. New admins need months, not weeks, to understand the org.
How do you grade each of the six areas?
Give each area a grade from A to F. The table shows what to measure and one example finding.
Swipe sideways to see all columns
| Area | What to measure | Example finding |
|---|---|---|
| Apex classes | Coverage per ApexClass, SOQL or DML in loops, hardcoded IDs, sharing keywords | A handler class at low coverage with a query inside a for loop |
| Apex triggers | Triggers per object, handler pattern, bulkification, recursion | Three triggers on Account with no shared handler |
| Flows | Active vs draft versions, subflow depth, Description filled, Get Records in loops | A Flow with a Get Records element inside a loop |
| Lightning Web Components | API version, Jest tests, accessibility attributes | A component on an old API version |
| Workflow Rules | Every active rule, field updates, matching Flow | An active rule on Lead that sets a field a Flow also sets |
| Metadata | Fields with zero references, orphan layouts, empty profiles | A custom field with no value in any record |
Workflow Rules always grade F while they are active, because the platform no longer supports them. LWC is usually the healthiest area, since it is the newest code.
Salesforce Well-Architected is Salesforce's official architecture framework. Map each finding to one of its themes so architects and CIOs can read your report. SOQL in a loop is a performance and reliability finding. A pile of dead fields is a maintainability finding.
How do you find the debt yourself?
Start with three checks in Developer Console or Workbench. Each result tells you where to look first.
SELECT ApexClassOrTrigger.Name, NumLinesCovered, NumLinesUncovered
FROM ApexCodeCoverageAggregate
ORDER BY NumLinesUncovered DESC
This Tooling API query (see the ApexCodeCoverageAggregate reference) lists the classes with the most uncovered lines. To find stacked triggers, query ApexTrigger and group by TableEnumOrId. Any object with a count above one needs a handler. To spot Workflow Rules, open Setup > Process Automation > Workflow Rules and note every active rule.
Run the Salesforce Code Analyzer on your repo. It flags patterns such as queries in loops. If you want all six areas graded at once, the free Technical Debt Audit does it without writing any query.
In what order should you pay it down?
Work in this order. Each step names the result to check, a failure case and the undo.
- Backfill Apex tests for the highest-risk classes. Open Setup > Environments > Jobs > Apex Test Execution to run them. Expected result: every class clears the deploy gate. Failure case: tests that pass alone but fail together in a suite. Undo: tests are new files, so delete them.
- Fix governor risks. Move queries out of loops into one bulk query, and collect DML into a list. Replace hardcoded IDs with Custom Metadata Types. Failure case: a changed query returns fewer rows. Undo: redeploy the earlier class from version control.
- Migrate Workflow Rules to Flows. In Setup > Process Automation > Workflow Rules, list every active rule. Build each Flow in a sandbox, compare field updates record by record, activate the Flow, then deactivate the rule. The migration tool post covers the mechanics. Failure case: a Flow and a rule both fire. Undo: reactivate the rule.
- Consolidate triggers. Build one trigger and one handler class per object, test in a sandbox, then promote. Failure case: the old order of execution mattered. Undo: redeploy the old triggers.
- Remove dead metadata. Check that a field has zero references in code, layouts, reports and validation rules before you delete it. Failure case: a hidden dependency in an integration. Undo: redeploy the field from the metadata snapshot you took before the cleanup.
- Backfill ownership. Write a one-line purpose in the
Descriptionof every active Flow, and add a header comment to every class.
A realistic target is grade B. Grade A needs steady upkeep, so schedule a re-scan each quarter.
What does it cost to leave the debt alone?
Delivery slows, because the team spends more time reading the old org than building. Consultants quote more for indebted orgs, since discovery takes longer and change risk is higher. AI rollouts also suffer. Agentforce and similar tools work on your metadata, so unowned Flows and duplicate fields give them poor context. The free health check shows where your org stands before you plan an AI project.
How does Clientell AI help, and is it safe?
Clientell AI scans your org in read-only mode first. It builds fixes in a sandbox, tests them, and asks before it changes anything in production. You approve each change, and the security page explains the controls.
Here is the split. The agent drafts Apex test classes, converts simple Workflow Rules to Flows, and lists dead fields for removal. Humans decide architecture, such as how to restructure triggers. Start with the free read-only audit, or try the 14-day trial with no card.
Try it in Clientell AI: "List every active Workflow Rule and Apex class below the deploy coverage gate, ranked by risk." Start the 14-day trial, no card.
If your team has no spare quarter, our managed services can run the cleanup. Book a demo is the second option.
Questions people ask
How often should I scan for Salesforce technical debt?
Scan monthly if your org grades C or worse, and quarterly at B. Clientell AI can run incremental scans on a schedule.
Can the cleanup be automated?
Parts of it. Test class drafts, simple Workflow Rule to Flow conversions and dead field lists can be automated. A person should approve each change and decide the architecture.
Does managed package code count as debt?
No. You cannot edit managed package internals, so they are left out of grading. Which packages you actually use is still worth reviewing.
What about Salesforce Industries (Vlocity) components?
The current audit covers Salesforce-native items. DataRaptors, OmniScripts and Integration Procedures are not graded yet.
Will a scan change anything in my org?
No. The scan only reads. Fixes are tested in a sandbox first, and Clientell AI asks before it changes anything in production.
Sources
Salesforce documentation
- Running Apex tests and deploy coverage (Apex Developer Guide)
- Execution governors and limits (Apex Developer Guide)
- Trigger best practices (Apex Developer Guide)
- ApexCodeCoverageAggregate (Tooling API)
- Workflow Rules and Process Builder end of support (Salesforce Help)
Industry research
- Salesforce Well-Architected (Salesforce Architects)
- Salesforce Code Analyzer (Salesforce Developers)
Last reviewed October 2026
Last updated: October 22, 2026




