ApexGuru is an AI-driven performance and code optimization engine integrated into Salesforce Code Analyzer. It works alongside the PMD, ESLint, and RetireJS engines to detect SOQL inefficiencies and scalability issues in your Apex code. ApexGuru executes real-time scans on connected Salesforce orgs directly through the Salesforce CLI and delivers exact line-level highlights, severity ratings, and actionable recommendations as JSON output.
Run a Scan via Salesforce CLI
Use the sf code-analyzer run --rule-selector apexguru command to run a scan with the ApexGuru engine. Specify the target org and output preferences. You must be connected to the target org. Authentication to the target org is through Salesforce CLI and not the configuration file. There’s no username, password, or token property. The engine reuses your sf login session.
ApexGuru scans .cls and .trigger files. ApexGuru doesn’t scan metadata XML, objects, flows, and other file types.
Integrate with VS Code
To get ApexGuru scan results directly in your development workspace, set the Code Analyzer Rule Selectors to apexguru in your extension settings. Then when you right-click a file in the Explorer or save an active Apex file, ApexGuru scans your code.
In the editor, lines containing ApexGuru violations are highlighted. Hover over a line to inspect combined engine findings. For example, view PMD rules alongside ApexGuru performance warnings.
As you edit and save the class file, ApexGuru updates the line numbers dynamically.
ApexGuru Configuration Reference
To customize the ApexGuru engine, add these settings to your code-analyzer.yml file.
Property
Type
Default
Constraints
Purpose
disable_engine
boolean
false
—
Turns off the ApexGuru engine. To speed up Code Analyzer output and disable ApexGuru, turn off the engine in your configuration.
target_org
string
(none → default org)
Must resolve to an authenticated org
The Salesforce org to run the remote scan against.
api_timeout_ms
number (ms)
300000(5 min)
> 0
Time limit on the scan: submit, poll, and decode. The api_* settings never override api_timeout_ms, even if you tune polling. The scan always stops at the overall timeout budget.
api_initial_retry_ms
number (ms)
2000(2 sec)
> 0
Delay before the first poll for results.
api_max_retry_ms
number (ms)
60000 (60 sec)
> 0 and >= api_initial_retry_ms
Upper limit on the delay between polls.
api_backoff_multiplier
number
2
>= 1
How fast the poll delay grows after each round.
Limitations
Authentication to the target org is through Salesforce CLI and not the configuration file. There’s no username, password, or token property. The engine reuses your sf login session.
ApexGuru scans .cls and .trigger files. ApexGuru doesn’t scan metadata XML, objects, flows, and other file types.
The api_* settings never override api_timeout_ms, even if you tune polling. The scan always stops at the overall timeout budget.