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.

examples/sample-decoded-summary.json

View on GitHub
{
  "scanId": "scan-7f3a91",
  "analysisMode": "static",
  "attribution": "Static only",
  "violationCount": 4,
  "filesScanned": 3,
  "serverViolationBreakdown": {
    "SOQL_IN_LOOP": 1,
    "DML_IN_LOOP": 1,
    "SOQL_NO_WHERE_OR_LIMIT": 1,
    "GGD": 1
  },
  "severityCounts": {
    "1": 1,
    "2": 2,
    "3": 1
  },
  "groupedBy": "rule",
  "groups": [
    {
      "key": "SOQL_IN_LOOP",
      "count": 1,
      "severityCounts": {
        "2": 1
      },
      "sample": [
        {
          "rule": "SOQL_IN_LOOP",
          "message": "SOQL query executed inside a for-loop over Accounts",
          "severity": "2",
          "file": "AccountService.cls",
          "line": 42,
          "method": "",
          "originalCode": "",
          "cpuTimePercentage": null,
          "fixes": [
            "Move the query outside the loop; build a Map<Id,Contact> for in-loop lookups"
          ],
          "resources": [
            "https://developer.salesforce.com/docs/apexguru/soql-in-loop"
          ]
        }
      ]
    },
    {
      "key": "DML_IN_LOOP",
      "count": 1,
      "severityCounts": {
        "1": 1
      },
      "sample": [
        {
          "rule": "DML_IN_LOOP",
          "message": "update statement inside a loop",
          "severity": "1",
          "file": "AccountService.cls",
          "line": 60,
          "method": "",
          "originalCode": "",
          "cpuTimePercentage": null,
          "fixes": [
            "Collect records into a List and update once after the loop"
          ],
          "resources": []
        }
      ]
    },
    {
      "key": "SOQL_NO_WHERE_OR_LIMIT",
      "count": 1,
      "severityCounts": {
        "2": 1
      },
      "sample": [
        {
          "rule": "SOQL_NO_WHERE_OR_LIMIT",
          "message": "SELECT with neither WHERE nor LIMIT on Opportunity",
          "severity": "2",
          "file": "ReportBuilder.cls",
          "line": 15,
          "method": "",
          "originalCode": "",
          "cpuTimePercentage": null,
          "fixes": [
            "Add a selective WHERE on an indexed field and a LIMIT"
          ],
          "resources": []
        }
      ]
    },
    {
      "key": "GGD",
      "count": 1,
      "severityCounts": {
        "3": 1
      },
      "sample": [
        {
          "rule": "GGD",
          "message": "Schema.getGlobalDescribe() called on every request",
          "severity": "3",
          "file": "Utils.cls",
          "line": 12,
          "method": "",
          "originalCode": "",
          "cpuTimePercentage": null,
          "fixes": [
            "Use SObjectType.getDescribe() for the specific object"
          ],
          "resources": []
        }
      ]
    }
  ],
  "topViolations": [
    {
      "rule": "DML_IN_LOOP",
      "message": "update statement inside a loop",
      "severity": "1",
      "file": "AccountService.cls",
      "line": 60,
      "method": "",
      "originalCode": "",
      "cpuTimePercentage": null,
      "fixes": [
        "Collect records into a List and update once after the loop"
      ],
      "resources": []
    },
    {
      "rule": "SOQL_IN_LOOP",
      "message": "SOQL query executed inside a for-loop over Accounts",
      "severity": "2",
      "file": "AccountService.cls",
      "line": 42,
      "method": "",
      "originalCode": "",
      "cpuTimePercentage": null,
      "fixes": [
        "Move the query outside the loop; build a Map<Id,Contact> for in-loop lookups"
      ],
      "resources": [
        "https://developer.salesforce.com/docs/apexguru/soql-in-loop"
      ]
    },
    {
      "rule": "SOQL_NO_WHERE_OR_LIMIT",
      "message": "SELECT with neither WHERE nor LIMIT on Opportunity",
      "severity": "2",
      "file": "ReportBuilder.cls",
      "line": 15,
      "method": "",
      "originalCode": "",
      "cpuTimePercentage": null,
      "fixes": [
        "Add a selective WHERE on an indexed field and a LIMIT"
      ],
      "resources": []
    },
    {
      "rule": "GGD",
      "message": "Schema.getGlobalDescribe() called on every request",
      "severity": "3",
      "file": "Utils.cls",
      "line": 12,
      "method": "",
      "originalCode": "",
      "cpuTimePercentage": null,
      "fixes": [
        "Use SObjectType.getDescribe() for the specific object"
      ],
      "resources": []
    }
  ],
  "truncated": false
}
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