salesforce-apex-quality
Apex code quality guardrails for Salesforce development. Enforces bulk-safety rules (no SOQL/DML in loops), sharing model requirements, CRUD/FLS security, SOQL injection prevention, PNB test coverage (Positive / Negative / Bulk), and modern Apex idioms. Use this skill when reviewing or generating Apex classes, trigger handlers, batch jobs, or test classes to catch governor limit risks, security gaps, and quality issues before deployment.
npx skills add github/awesome-copilot --skill salesforce-apex-quality --agent copilot
Same command for any agent — swap --agent for claude-code, codex, cursor.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Salesforce Apex Quality Guardrails Apply these checks to every Apex class, trigger, and test file you write or review. ## Step 1 — Governor Limit Safety Check Scan for these patterns before declaring any Apex file acceptable: ### SOQL and DML in Loops — Automatic Fail ```apex // ❌ NEVER — causes LimitException at scale for (Account a : accounts) { List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId = :a.Id]; // SOQL in loop update a; // DML in loop } // ✅ ALWAYS — collect, then query/update once Set<Id> accountIds = new Map<Id, Account>(accounts).keySet(); Map<Id, List<Contact>> contactsByAccount = new Map<Id, List<Contact>>(); for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accountIds]) { if (!contactsByAccount.containsKey(c.AccountId)) { contactsByAccount.put(c.AccountId, new List<Contact>()); } contactsByAccount.get(c.AccountId).add(c); } update accounts; // DML once, outside the loop ``` Rule: if you see `[SELECT` or `Database.query`, `insert`, `update`, `delete`, `upsert`, `merge` inside a `for` loop body — stop and refactor before proceeding. ## Step 2 — Sharing Model Verification Every class must declare its sharing intent explicitly. U
- Step 1 — Governor Limit Safety Check
- SOQL and DML in Loops — Automatic Fail
- Step 2 — Sharing Model Verification
- Step 3 — CRUD / FLS Enforcement
- Step 4 — SOQL Injection Prevention
- Step 5 — Modern Apex Idioms
- Step 6 — PNB Test Coverage Checklist
- Positive Path
- Negative Path
- Bulk Path
- Test Class Rules
- Step 7 — Trigger Architecture Checklist
- Quick Reference — Hardcoded Anti-Patterns Summary
What does the salesforce-apex-quality skill do?
Apex code quality guardrails for Salesforce development. Enforces bulk-safety rules (no SOQL/DML in loops), sharing model requirements, CRUD/FLS security, SOQL injection prevention, PNB test coverage (Positive / Negative / Bulk), and modern Apex idioms. Use this skill when reviewing or generating Apex classes, trigger handlers, batch jobs, or test classes to catch governor limit risks, security gaps, and quality issues before deployment.
How do I install it?
Run `npx skills add github/awesome-copilot --skill salesforce-apex-quality --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From github/awesome-copilot, a repository with 37,432 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.