Skip to content

forcedotcom/sf-skills / skills/dx-apexguru-scan

dx-apexguru-scan

Verified

Run an ApexGuru performance scan on a Salesforce Apex project via the ApexGuru SFAP Scan API. Zips the project's Apex (any layout), submits it, polls to completion, decodes the base64 report, and presents performance antipattern violations (SOQL in loop, DML in loop, Schema.getGlobalDescribe(), SOQL without WHERE/LIMIT, unused SOQL fields) grouped by rule with severity, file:line, and suggested fixes — clearly attributed as 'Static only' or 'Production insights'. TRIGGER when the user says 'run ApexGuru', 'ApexGuru scan', 'check Apex performance', 'find governor-limit / performance antipatterns', 'SOQL in loop', 'scan my Apex for performance', or 'ApexGuru performance insights'. DO NOT TRIGGER for general static analysis or security scans (use dx-code-analyzer-run), for fixing code without scanning, or for onboarding an org to ApexGuru.

references/violation-catalog.md

View on GitHub
# ApexGuru Violation Catalog

Performance antipatterns ApexGuru detects, with what they mean and the typical fix.
Use this to explain a violation when the user asks "what does this mean / how do I
fix it?". The API's `report` carries per-violation `message`, `fixes`, and help-doc
`resources` — prefer those when present; this catalog is the fallback explanation.

| Rule (`rule`) | What it flags | Why it hurts | Typical fix |
|---------------|---------------|--------------|-------------|
| `SOQL_IN_LOOP` | A SOQL query inside a `for`/`while` loop | Each iteration issues a query → hits the 100-SOQL governor limit fast; slow | Move the query outside the loop; query once and build a `Map<Id, SObject>` keyed for lookup inside the loop |
| `DML_IN_LOOP` | `insert`/`update`/`delete`/`upsert` inside a loop | Each iteration issues DML → hits the 150-DML limit; slow | Collect records into a `List` and perform one DML statement after the loop |
| `GGD` | `Schema.getGlobalDescribe()` usage | Describes **every** object in the org — expensive, grows with org size | Use targeted describes (`SObjectType.getDescribe()`, `Schema.describeSObjects([...])`) for only the objects needed |
| `SOQL_NO_WHERE_OR_LIMIT` | SOQL with neither `WHERE` nor `LIMIT` | Full-table scan; can return huge result sets and blow the heap / row limits | Add a selective `WHERE` clause and/or a `LIMIT`; ensure filters are on indexed fields |
| `SOQL_UNUSED_FIELDS` | SELECTed fields never read | Wastes query CPU/heap fetching unused columns | Select only fields the code actually uses |

## Severity mapping

ApexGuru severities follow the standard 1–5 scale: **1 = Critical, 2 = High,
3 = Moderate, 4 = Low, 5 = Info.** `DML_IN_LOOP` and `SOQL_IN_LOOP` are usually the
highest-impact (governor-limit) findings.

## Static vs. full attribution

- **Static** findings come from source analysis alone — the antipattern exists in the
  code regardless of runtime.
- **Full** findings are enriched with production metrics — e.g. a `SOQL_IN_LOOP`
  that actually executed against large data volumes in production is prioritized
  higher. Always label which mode produced the results.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall