Apex Code Reviewer
Quick answer
This skill teaches an AI assistant to review Apex classes, triggers and test classes the way a careful senior developer would. It finds bulkification, security and test-quality problems, ranks them high, medium or low with line references and corrected snippets, and lists what it did not review. It never edits or deploys code.
What this skill does
- Checks for SOQL and DML in loops, single-record assumptions and other bulkification problems that fail in triggers and data loads.
- Reviews sharing keywords, CRUD and field-level security (with sharing, WITH USER_MODE, Security.stripInaccessible) and SOQL injection (bind variables, String.escapeSingleQuotes).
- Finds hard-coded IDs and URLs, recursion problems, trigger structure issues and async misuse.
- Reviews test classes for assertions, @TestSetup, SeeAllData and bulk coverage, and callouts for Named Credential use.
- Produces findings with severity, line reference, why it matters and a corrected snippet, plus a list of what was not reviewed.
When to use it
- You want a second pair of eyes on a class or trigger before a pull request.
- A trigger fails during a data load and you suspect it is not bulk safe.
- You inherited Apex and need to know which parts are risky.
- You want a security pass on an @AuraEnabled controller or REST resource.
What you need
- Connection: No connection if you paste code or have the project locally. To review code that lives in an org, the Salesforce CLI logged in to it (sf project retrieve start or a Tooling API query on ApexClass) or an MCP server that can read Apex source.
- Permissions: Reading Apex source from an org needs access to view Apex classes (for example View Setup and Configuration). Managed package code is hidden and cannot be reviewed.
How it works
- It gets the code: pasted, read from your local project, or retrieved from the org read-only.
- It lists the files in scope with their API versions and reads everything, including the test classes, before judging.
- It walks the checklist in references/apex-review-checklist.md, one section at a time.
- It verifies each finding against the exact line and drops anything it cannot support.
- It ranks findings high, medium or low and writes a minimal corrected snippet for each important one.
- It states what was not reviewed and that nothing was compiled, run or deployed.
Safety rules built into the skill
- It never edits files, deploys, runs anonymous Apex or changes anything in an org. Fixes appear only as snippets or diffs in the report.
- It reviews only code it has actually read and does not invent findings for code it was not given.
- It quotes governor limit numbers only from the verified list on this site and points to the governor limits tool for the rest.
- It marks uncertain findings as possible and says what would confirm them.
- It treats your code as confidential and asks before writing retrieved files into your project.
Try asking
- Review this trigger and handler for bulkification and recursion. [paste code]
- Review force-app/main/default/classes/OrderService.cls and its test class. Focus on security.
- Retrieve the ApexClass CaseRouter from my sandbox and review it for governor-limit risk.
- Is this test class good enough? List missing assertions and bulk cases.
How to install a skill
A skill is a folder with a SKILL.md file: YAML frontmatter with a name and a
description, then plain Markdown instructions. An assistant reads the description to decide when the skill
applies and loads the rest only then. The format is the open
Agent Skills specification.
- Claude Code: unzip the download so the folder lands in
~/.claude/skills/apex-code-reviewer/for all projects, or.claude/skills/apex-code-reviewer/inside one project. Start a new session. - Claude app (web and desktop): upload the zip in the Skills section of your settings. Availability depends on your plan, and the menu names change, so check Anthropic's current help pages.
- Other assistants that support Agent Skills: copy the folder into the skills directory that assistant documents.
- Any other LLM: open
SKILL.mdand paste its contents into the system prompt, custom instructions or project instructions. You lose automatic loading, but the guidance works the same.
Skills that work with your org need a connection: a Salesforce MCP server added to your assistant, or the Salesforce CLI logged in to an org. Start with a sandbox or scratch org, and give the connection the least access that does the job.
The skill file (SKILL.md)
This is the exact file in the download. Read it before you install it.
---
name: apex-code-reviewer
description: Reviews Apex classes, triggers and test classes for bulkification, SOQL or DML in loops, governor-limit risk, sharing and CRUD/FLS, SOQL injection, hard-coded IDs, recursion, async misuse, test quality and callout handling. Use when the user pastes Apex, points to local files, or asks for a review of code in an org. Returns prioritized findings with line references and corrected snippets. Never edits or deploys code.
license: MIT
metadata:
version: "1.0.0"
publisher: SFDX Talk (sfdxtalk.com)
---
# Apex Code Reviewer
Review Apex like a careful senior developer: find the defects that break in bulk or in production, rank them, and show the fix. Propose diffs only. Never edit, save or deploy.
## Getting the code
Use the first source that applies:
1. **Pasted code.** Review exactly what was given. Number the lines yourself if the paste has no line numbers, and say so.
2. **Local project.** Read the files with file tools. Trigger and class files end in `.trigger` and `.cls` under `force-app/main/default/`. Review a class together with its test class and its `-meta.xml` (API version).
3. **Org, read-only.** Retrieve into the local project with `sf project retrieve start --metadata "ApexClass:<Name>" --target-org <alias>` (also `ApexTrigger:<Name>`), which only downloads files. Ask before writing into the user's project; prefer a temporary folder. Or read the source with a Tooling API query: `sf data query --use-tooling-api --target-org <alias> --query "SELECT Name, ApiVersion, Body FROM ApexClass WHERE Name = '<Name>'"` (`ApexTrigger` works the same way). Managed package code is hidden and cannot be reviewed.
4. **An MCP server** with a read tool that returns Apex source, if one is connected. Use read tools only.
If you cannot get the code, say so and ask the user to paste it. Do not review from memory or guess at code you have not seen.
## Workflow
1. **Scope.** List the files to review: each class, trigger and test class, with its API version. State what is out of scope (for example, other classes it calls but you were not given).
2. **Read it all first.** Understand entry points (trigger, `@AuraEnabled`, `@InvocableMethod`, batch, queueable, REST resource) before judging. Context matters: a SOQL query in a loop in a method called once per request is still a defect if the method can be called from a trigger.
3. **Walk the checklist** in `references/apex-review-checklist.md`, section by section: bulkification and limits, security, trigger structure, async, errors, tests, callouts.
4. **Verify each finding** against the code. Quote the exact line. Drop findings you cannot support. Mark uncertain ones "possible" and say what would confirm them.
5. **Rank** each finding: High (data loss or exposure, certain failure in bulk, security hole), Medium (likely failure under load or maintainability that causes bugs), Low (style, clarity, small risk).
6. **Write a corrected snippet** for every High and Medium finding, and for Low findings where it is short. Keep fixes minimal and compatible with the surrounding code. Do not rewrite the whole class.
7. **State what was not reviewed**, then offer to apply the changes only if the user asks. Even then, present them as a diff for the user to apply; do not deploy.
## Limits and numbers
Do not state governor-limit numbers from memory. Point to the site's governor limits tool at /tools/governor-limits/ for current values. The numbers below are the ones verified there for Winter '27 (API 68.0) and are the only ones to quote:
- SOQL queries per transaction: 100 synchronous, 200 asynchronous.
- Records retrieved by SOQL: 50,000.
- DML statements: 150. Records processed by DML: 10,000.
- Callouts: 100 per transaction.
- Trigger stack depth: 16. Trigger batch size: 200.
- Future calls: 50 per invocation. Queueable jobs added with `System.enqueueJob`: 50 synchronous, 1 asynchronous.
For any other limit (CPU time, heap, email, cursors and so on), name the limit and link the tool without giving a number.
## Rules
- Read-only. Never edit files, run `sf project deploy`, run anonymous Apex, run tests against a shared org, or change anything in an org. Proposed code goes in the report as a diff or snippet.
- Review the code that exists. Do not praise or criticize code you have not read.
- Every finding has: severity, location (file and line), what is wrong, why it matters, and a fix. No generic advice without a line.
- Be accurate about Salesforce behavior. When you are not certain a rule applies to the code's API version or context, say "check" and name what to check. Do not invent annotations, methods or limits.
- Do not flag a pattern as wrong when it is correct in context (for example `without sharing` on a class that deliberately needs it, documented in a comment, can be Low or an observation, not High).
- Treat code as confidential. Do not paste it into other tools.
- Keep the review proportionate: report the findings that matter, grouped, instead of listing every nit.
## Output format
1. **Summary:** what was reviewed, the overall risk in two or three sentences, and counts of High, Medium and Low findings.
2. **Findings**, High first. For each:
- `[HIGH|MEDIUM|LOW] Short title`
- Location: `ClassName.cls:42` (or the pasted line number)
- Problem: what the code does.
- Why it matters: the concrete failure or exposure.
- Fix: a corrected snippet or small diff in a fenced code block.
3. **What looks good:** one to three lines, only if true.
4. **Not reviewed:** files, code paths, managed packages, org configuration (triggers on other objects, flows, validation rules), runtime behavior and anything you could not retrieve. Say that nothing was compiled, run or deployed.
5. **Next steps:** the order to fix things in, and a pointer to /tools/governor-limits/ when limits are involved.
Files in the download: apex-code-reviewer/SKILL.md, apex-code-reviewer/references/apex-review-checklist.md
Frequently asked questions
Will it change or deploy my code?
No. The skill only reads and reports. Fixes are shown as corrected snippets or diffs for you to apply. Retrieving code from an org only downloads files, and the skill asks before writing them into your project folder.
Where does it get the governor limit numbers?
It quotes only a short list of limits verified for Winter '27 (API 68.0) taken from this site's governor limits data, and points to the governor limits tool for everything else. It will name a limit without a number rather than guess one.
Does it replace Salesforce Code Analyzer or a human review?
No. It is a fast review that explains problems and proposes fixes, but it does not compile or run the code. Use a static analyzer and your normal review process as well. It says in every report that nothing was run.
Can it review code that is only in my org?
Yes, if the CLI is logged in. It can retrieve the class with sf project retrieve start or read the source with a Tooling API query on ApexClass or ApexTrigger. Managed package code is not readable, and it reports that as not reviewed.
Does it work with assistants other than Claude?
Yes. Assistants that support the Agent Skills format can load the folder, including the checklist in references. For any other model, paste SKILL.md and the checklist into the prompt.
Related tools
Related guides
Official sources
- https://developer.salesforce.com/docs/platform/apex-dev/references/apex-dev/apex-gov-limits.html
- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_with_security_stripInaccessible.htm
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_org_list_metadata.html
- https://agentskills.io/specification
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Skills are provided as is, under the MIT license. Review what a skill does and test it in a sandbox before you rely on it. All skills