/dx-apexguru-scan
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,
$ npx -y skills add forcedotcom/sf-skills --skill dx-apexguru-scan --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/dx-apexguru-scan
Context preview
The summary Claude sees to decide when to auto-load this skill.
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,
SKILL.md
dx-apexguru-scan.SKILL.mdname: dx-apexguru-scan
description: "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."
allowed-tools: Read, Bash(bash), Bash(node), Bash(curl), Bash(zip), Bash(unzip), Bash(jq), Bash(sf), Bash(date), Write
argument-hint: "[project-path] [--org <alias>] [--fast]"
metadata:
version: "1.1"
relatedSkills:
- "dx-code-analyzer-run"
cliTools:
- tool: ["curl"]
semver: ">=7.0.0"
- tool: ["jq"]
semver: ">=1.6.0"
- tool: ["node"]
semver: ">=18.0.0"
- tool: ["sf"]
semver: ">=2.0.0"ApexGuru Performance Scan Skill
CRITICAL: Mandatory Script Usage
Every step — token resolution, zipping, API calls, and report decoding — MUST go through the bundled scripts in `<skill_dir>/scripts/`. No exceptions.
WRONG — never do this:
# WRONG: hand-rolled curl to the API
curl -X POST https://api.salesforce.com/... -F file=@x.zip
# WRONG: inline base64 + jq to read the report
cat raw.json | jq -r .report | base64 -d | jq '.[]'
# WRONG: reading the raw result file directly (report is a large base64 blob)
Read tool → apexguru-raw-*.json
# WRONG: inline node/python to parse violations
node -e "const r = require('./raw.json'); ..."RIGHT — always do this:
# PREFERRED — one command runs all three steps (package → submit+poll →
# decode+present) and prints the ready-to-show report as its final stdout.
# Use this for every initial scan: it cannot be left half-finished.
bash "<skill_dir>/scripts/scan.sh" "<project-root>"
# Optionally persist the presented markdown to a file as well:
bash "<skill_dir>/scripts/scan.sh" "<project-root>" --out ./apexguru-report.md
The three underlying scripts still exist and `scan.sh` calls them in order. Invoke them individually only for **drill-downs on an already-scanned result** (Step 5), or when you deliberately need to inspect an intermediate artifact:
# Equivalent manual chain (scan.sh runs exactly these, in this order):
bash "<skill_dir>/scripts/build-zip.sh" "<project-root>" "./apexguru-<TS>.zip"
bash "<skill_dir>/scripts/run-scan.sh" "./apexguru-<TS>.zip" "./apexguru-raw-<TS>.json"
node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --present
# Drill into a subset WITHOUT re-scanning (reuse the raw file scan.sh left, or
# pass --raw to scan.sh to keep it at a known path):
node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --rule SOQL_IN_LOOP --full
node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --group file --top 5
`<skill_dir>` is the absolute path to the directory containing this SKILL.md. **Never** use `./scripts/` — that resolves against the user's CWD, not the skill dir.
Any filter/rank/group question ("which file has the most issues?", "show only SOQL-in-loop", "break down by severity") is answered by re-running `decode-report.js` with flags against the **same raw result file** — never re-scan, never parse the JSON by hand.
---
CRITICAL: Present `--present` output verbatim — never condense it
`decode-report.js --present` (Step 4) already produces the final, ready-to-show markdown: severity legend, one detail card per violation (message, code, fix, resource link), and a closing summary table. That stdout **is** the response. Print it to the user exactly as printed — do not rewrite it into a shorter table, do not drop the per-issue cards down to just the summary table, and do not wait for the user to ask "explain a violation" before including message/fix/resource. Condensing it defeats the entire point of `--present`.
The attribution is **already in that stdout** — the summary line is the exact output that states the mode (e.g. "ApexGuru (static analysis) is active. To unlock runtime intelligence…"). Do **NOT** prepend or append your own attribution sentence (no "Attribution: analysisMode: static…", no naming the org, no restating "static-only findings"). The script's line is the complete, approved wording; adding your own makes the output non-deterministic and off-message.
WRONG — never do this:
Top Issues (worst first)
# Severity Rule Method Line
1 Major UsingTheTestMethodKeyword legacy... 136
...
Key Antipatterns Detected:
- SOQL/DML in loops (3 violations)
*(a hand-built summary that drops every message/code/fix — even for violations that had one)*
Attribution: analysisMode: static — source-only analysis. The scanned org
(ag-skills-org) is not onboarded to ApexGuru's full runtime metrics, so
these are static-only findings.
*(an agent-authored attribution line prepended to the report — the script's own summary line already states the mode; this duplicate is non-deterministic and names an org the script never had access to)*
RIGHT — always do this:
Paste the full stdout from `decode-report.js --present` — every `### Issue N` card and the closing `## Summary` table — unedited, in one response.
---
Overview
ApexGuru detects **performance antipatterns** in Apex (SOQL/DML in loops, `Schema.getGlobalDescribe()`, SOQL without `WHERE`/`LIMIT`, unused SOQL fields). This skill drives the ApexGuru **SFAP Scan API**: it packages the user's Ape
Read more
name: dx-apexguru-scan
description: "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."
allowed-tools: Read, Bash(bash), Bash(node), Bash(curl), Bash(zip), Bash(unzip), Bash(jq), Bash(sf), Bash(date), Write
argument-hint: "[project-path] [--org <alias>] [--fast]"
metadata:
version: "1.1"
relatedSkills:
- "dx-code-analyzer-run"
cliTools:
- tool: ["curl"]
semver: ">=7.0.0"
- tool: ["jq"]
semver: ">=1.6.0"
- tool: ["node"]
semver: ">=18.0.0"
- tool: ["sf"]
semver: ">=2.0.0"ApexGuru Performance Scan Skill
CRITICAL: Mandatory Script Usage
Every step — token resolution, zipping, API calls, and report decoding — MUST go through the bundled scripts in `<skill_dir>/scripts/`. No exceptions.
WRONG — never do this:
# WRONG: hand-rolled curl to the API
curl -X POST https://api.salesforce.com/... -F file=@x.zip
# WRONG: inline base64 + jq to read the report
cat raw.json | jq -r .report | base64 -d | jq '.[]'
# WRONG: reading the raw result file directly (report is a large base64 blob)
Read tool → apexguru-raw-*.json
# WRONG: inline node/python to parse violations
node -e "const r = require('./raw.json'); ..."RIGHT — always do this:
# PREFERRED — one command runs all three steps (package → submit+poll → # decode+present) and prints the ready-to-show report as its final stdout. # Use this for every initial scan: it cannot be left half-finished. bash "<skill_dir>/scripts/scan.sh" "<project-root>" # Optionally persist the presented markdown to a file as well: bash "<skill_dir>/scripts/scan.sh" "<project-root>" --out ./apexguru-report.md
The three underlying scripts still exist and `scan.sh` calls them in order. Invoke them individually only for **drill-downs on an already-scanned result** (Step 5), or when you deliberately need to inspect an intermediate artifact:
# Equivalent manual chain (scan.sh runs exactly these, in this order): bash "<skill_dir>/scripts/build-zip.sh" "<project-root>" "./apexguru-<TS>.zip" bash "<skill_dir>/scripts/run-scan.sh" "./apexguru-<TS>.zip" "./apexguru-raw-<TS>.json" node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --present # Drill into a subset WITHOUT re-scanning (reuse the raw file scan.sh left, or # pass --raw to scan.sh to keep it at a known path): node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --rule SOQL_IN_LOOP --full node "<skill_dir>/scripts/decode-report.js" "./apexguru-raw-<TS>.json" --group file --top 5
`<skill_dir>` is the absolute path to the directory containing this SKILL.md. **Never** use `./scripts/` — that resolves against the user's CWD, not the skill dir.
Any filter/rank/group question ("which file has the most issues?", "show only SOQL-in-loop", "break down by severity") is answered by re-running `decode-report.js` with flags against the **same raw result file** — never re-scan, never parse the JSON by hand.
---
CRITICAL: Present `--present` output verbatim — never condense it
`decode-report.js --present` (Step 4) already produces the final, ready-to-show markdown: severity legend, one detail card per violation (message, code, fix, resource link), and a closing summary table. That stdout **is** the response. Print it to the user exactly as printed — do not rewrite it into a shorter table, do not drop the per-issue cards down to just the summary table, and do not wait for the user to ask "explain a violation" before including message/fix/resource. Condensing it defeats the entire point of `--present`.
The attribution is **already in that stdout** — the summary line is the exact output that states the mode (e.g. "ApexGuru (static analysis) is active. To unlock runtime intelligence…"). Do **NOT** prepend or append your own attribution sentence (no "Attribution: analysisMode: static…", no naming the org, no restating "static-only findings"). The script's line is the complete, approved wording; adding your own makes the output non-deterministic and off-message.
WRONG — never do this:
Top Issues (worst first) # Severity Rule Method Line 1 Major UsingTheTestMethodKeyword legacy... 136 ... Key Antipatterns Detected: - SOQL/DML in loops (3 violations)
*(a hand-built summary that drops every message/code/fix — even for violations that had one)*
Attribution: analysisMode: static — source-only analysis. The scanned org (ag-skills-org) is not onboarded to ApexGuru's full runtime metrics, so these are static-only findings.
*(an agent-authored attribution line prepended to the report — the script's own summary line already states the mode; this duplicate is non-deterministic and names an org the script never had access to)*
RIGHT — always do this:
Paste the full stdout from `decode-report.js --present` — every `### Issue N` card and the closing `## Summary` table — unedited, in one response.
---
Overview
ApexGuru detects **performance antipatterns** in Apex (SOQL/DML in loops, `Schema.getGlobalDescribe()`, SOQL without `WHERE`/`LIMIT`, unused SOQL fields). This skill drives the ApexGuru **SFAP Scan API**: it packages the user's Ape
This repository provides a curated collection of Salesforce agent skills for building applications.
Repo: forcedotcom/sf-skills
Other skills on sf-skills.
- /agentforce-generate
Build, modify, optimize, debug, and deploy agents with Agentforce Agent Script. TRIGGER when: user creates, modifies, optimizes, or asks about .agent files or aiAuthoringBundle metadata; changes agent behavior, responses, or conversation logic; designs agent actions, tools,
Open skill - /agentforce-observe
Analyze production Agentforce agent behavior using session traces and Data Cloud. TRIGGER when: user queries STDM session data or Data Cloud trace records; investigates production agent failures, regressions, or performance issues; asks about session traces, conversation logs,
Open skill - /agentforce-test
Write, run, and analyze structured test suites for Agentforce agents — functional AND security. TRIGGER when: user writes or modifies test spec YAML (AiEvaluationDefinition); runs sf agent test create, run, run-eval, or results commands; asks about test coverage strategy, metric
Open skill - /automation-flow-generate
Generate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as \"when a record is
Open skill - /dx-code-analyzer-configure
Set up, configure, and troubleshoot Salesforce Code Analyzer for any project. Handles installation, prerequisite checks, diagnosing broken setups, creating and editing code-analyzer.yml overrides, engine-specific settings, ignore patterns, severity overrides, and CI/CD pipeline
Open skill - /dx-code-analyzer-custom-rule-create
Create custom Code Analyzer rules for Regex (pattern matching), PMD (XPath/AST for Apex and metadata XML), and ESLint (LWC/JavaScript/TypeScript). Use when users want to enforce coding standards, ban patterns, detect hardcoded values, govern metadata, or add rules not in the
Open skill

