Skip to main content

Salesforce Technical Debt Audit: Deploys Keep Failing on Code Nobody Owns

A Salesforce technical debt audit grades your Apex, flows, LWC (Lightning Web Components) and metadata A to F in about 10 minutes. Each finding comes with a drafted fix.

Last updated
By the Clientell AI teamHow we write

The scan reads your source and checks it against the Salesforce Well-Architected standard.

Clientell AI, the AI agent for Salesforce admins, scans your org read-only, drafts each fix and asks before it changes anything in production.

Code Quality Data · 2026

What kinds of technical debt does the audit find?

Each one has a cause, a risk and a fix path.

FINDING ACritical
Deploy gate

Apex test coverage

Salesforce requires 75% Apex coverage across the org to deploy to production. The audit shows coverage per class, so you know which classes need tests before the next deploy. Source: Apex code coverage (Salesforce Developers).

FINDING CCritical
Safe to remove

Unused custom fields

Custom fields (the __c fields on Account, Opportunity and other objects) made for an old project, never filled in and never reported on. They still take up page layout space and count against the field limit. Each is listed with a dependency check.

FINDING DCritical
Draft and paused

Inactive flows in metadata

Draft flows nobody activated, paused flows nobody cleaned up, copies of copies. A SOQL query on FlowDefinitionView where ActiveVersionId is null finds flows with no active version. Each one clutters dependency analysis and slows every metadata search.

Tech Debt Scorecard

What does an A to F grade look like for each code domain?

Click a domain to inspect specific issues, severity, and root cause. This is sample data from a demo org.

Healthy baselineB grade overall
Sample orgMid-market demo org
Aligned to Salesforce Well-Architected framework
Coverage Areas

What does the technical debt audit cover?

Six dimensions, mapped to Salesforce Well-Architected. Every issue routes to a fix.

A

A-F grades per domain

The audit reads ApexClass, ApexTrigger, FlowDefinitionView, LightningComponentBundle, WorkflowRule and field metadata. Each of the six domains gets a grade from A to F. The grades follow the Salesforce Well-Architected standard. Your architect can use them to defend the next refactor budget.

B

Apex governor risk patterns

SOQL (Salesforce Object Query Language) queries in loops, DML (data manipulation language, the insert and update statements) in loops, hardcoded record IDs and classes declared without sharing. These four patterns cause silent production failures. Salesforce stops a transaction at 100 SOQL queries or 150 DML statements. The audit scans your Apex source and flags each risky line with a fix. Source: Apex governor limits (Salesforce Developers).

C

Test coverage analysis

Coverage per class, classes with stale or skipped tests, and the gap to the deploy gate. You can spot-check it in Setup under Custom Code, Apex Classes, Estimate your organization’s code coverage. Salesforce needs 75% Apex coverage across the org to deploy to production. Source: Apex code coverage (Salesforce Developers).

E

Dead metadata sweep

Unused custom fields, inactive flows still in metadata, profiles never assigned to a user, and page layouts no record uses. Each asset gets a dependency check and a safe-to-remove status.

F

Multi-trigger framework migration

Two Apex triggers on one object can fire in any order, which causes race conditions. The audit groups ApexTrigger records by TableEnumOrId and lists every object with more than one trigger. It proposes a one-trigger pattern with handler classes and sample code.

How do I read my grade? Example scale

Salesforce technical debt grades A through F with thresholds and recommended action.
GradeBandWhat it meansAction
ATop bandWell-architected. Strong Apex coverage. No governor risks. One trigger per object. No end-of-life automation.Maintain. Annual audit.
BUpper bandHealthy baseline. The Salesforce coverage gate is met. Minor cleanup left.Quarterly cleanup sprint.
CMiddle bandAt risk. Coverage is slipping. Some governor risks. End-of-life automation still active.Cleanup sprint this quarter.
DLower bandSignificant debt. Deploys are risky. Coverage is below the Salesforce gate.Pause non-critical work. Cleanup priority 1.
FBottom bandProduction risk. The test suite cannot vouch for a deploy. Race conditions are likely.Full audit and architect review now.
Warning Signs

Should you run the audit before the next deploy fails?

Debt stays quiet until a deploy fails or Apex hits a governor limit, such as the cap on SOQL queries in one transaction.

A

Your last deploys had failed Apex tests

A flaky test suite or low coverage makes every deploy a gamble. Run all tests in Setup under Custom Code, Apex Test Execution to see yours. The audit shows coverage per class and names the classes that need new tests to clear the deploy gate.

B

Apex CPU limit warnings in the logs

Code that runs fine on a few records can trip governor limits on a bulk load. Look for the LIMIT_USAGE_FOR_NS lines in the debug log. Common causes are SOQL in loops, DML in loops and nested triggers. The audit finds every one with a line number. Source: Apex governor limits (Salesforce Developers).

C

Your architect just left

Their knowledge left with them. Check the LastModifiedById field on your ApexClass records: if those users are gone, nobody owns that code. The audit writes the architect brief nobody had time to write.

D

A custom object is near its field limit

Salesforce caps custom fields per object by edition. Open Object Manager, then Fields & Relationships, to see your count. When you are close, some of those fields are probably dead. The audit lists every unused field with usage stats and a safe-to-remove status.

E

You inherited code from a consulting partner

Record IDs hardcoded from their sandbox, which break in production. Apex classes named after their internal tools. No comments. The audit maps what you inherited and proposes a cleanup order.

Deliverables

What do you get with the audit?

Five deliverables. Architect-grade reports plus admin-actionable cleanup queues.

A

Per-domain grade report (A through F)

Six domains, six grades, one weighted overall score, mapped to Salesforce Well-Architected categories. Export it as PDF or XLSX for architect review and budget defense.

B

Governor risk inventory

Every SOQL-in-loop, DML-in-loop, hardcoded ID and without-sharing class. Each has a line number, a severity and a proposed rewrite. Export to CSV for your ticket queue.

D

EOL migration queue

Every Workflow Rule and Process Builder process past end of support, paired with its Flow successor. Each migration script is tested in a sandbox.

E

Dead metadata cleanup plan

Unused custom fields, inactive flows, orphan profiles and dead layouts. Each is tagged safe to remove, with its dependencies. Clientell AI drafts the removal.

FAQ

You have
questions,
we have
answers.

What architects and CIOs ask before a technical debt audit.

A

What is a Salesforce technical debt audit?

It grades the code and metadata in your org from A to F across six domains: Apex Classes, Apex Triggers, Flows, LWC Components, Workflow Rules and Metadata. It flags governor risks, hardcoded IDs, coverage gaps, end-of-life automation and unused metadata. The scan takes about 10 minutes.

B

What is a good Apex test coverage percentage?

Salesforce requires at least 75% Apex coverage across the org to deploy to production, and every trigger needs some coverage. Aim higher than the minimum so one failing class does not block a deploy. See the Salesforce Apex developer guide for the exact rule. Source: Apex code coverage (Salesforce Developers).

C

What technical debt patterns does the audit detect?

Governor risks (SOQL in loops, DML in loops, queries without limits), security bypasses (classes without sharing, hardcoded IDs) and multiple triggers per object. It also finds coverage gaps and dead metadata such as unused fields, inactive flows and orphan profiles.

D

Are Workflow Rules technical debt?

Often, yes. Salesforce ended support for Workflow Rules and Process Builder on 31 Dec 2025 (Salesforce Help, "Workflow Rules & Process Builder End of Support"). Existing ones still run but get no bug fixes. The audit lists each one with its Flow migration path. Source: Workflow Rules & Process Builder End of Support (Salesforce Help).

E

How does the audit grade my code?

Each domain gets a score weighted by issue severity and impact. Test coverage, governor risk count, sharing model compliance and code smell density all count. The score maps to a letter from A to F, as in the grade table above.

F

How is this different from Salesforce Optimizer?

Optimizer produces a static report with general recommendations. This audit grades your code, finds governor risks at the source level and builds a coverage roadmap. It also drafts a fix for each finding.

G

Can the audit suggest specific Apex rewrites?

Yes. Each governor risk and code smell comes with a proposed rewrite based on bulk patterns and a trigger handler framework. You review the diff in a sandbox. Clientell AI asks before it changes anything in production.

H

What is the Salesforce Well-Architected framework?

It is the architecture guidance Salesforce publishes on security, performance, reliability and maintainability (Salesforce Architects, "Well-Architected"). Every finding maps to one of its categories. Your architect, auditor and CIO can all read the same labels. Source: Well-Architected (Salesforce Architects).

I

Does the audit work for managed packages?

It reads your custom code and configuration. It does not grade managed package code, which you cannot change anyway. Installed packages appear in the inventory with license and usage stats but stay out of the quality score.

J

How long does technical debt cleanup take?

It depends on org size and how much debt there is. Clientell AI drafts the test classes, EOL migration scripts and dead metadata cleanup for you to review.

Getting Started

Get your free
Salesforce tech debt audit.

A-F grades, a governor risk list, a coverage roadmap and an EOL migration queue. Run it free for 14 days, no card.

14-day free trial  ·  No credit card required

SOC 2
HIPAA
ISO 27001
Salesforce Partner