New advertisers: 50% off your first month with code FIRSTMONTHSee slots
github avatar

Salesforce Apex Quality

Apex quality guardrails that block SOQL/DML in loops, enforce sharing and CRUD/FLS, and require PNB test coverage.

skills.sh installs
886
GitHub stars
41.4K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers governor-limit checks, sharing declarations, CRUD/FLS enforcement, SOQL injection prevention, and modern Apex idioms
  • Includes PNB test coverage rules (Positive, Negative, Bulk at 200 to 251 records) and a trigger architecture checklist
  • Enforces that SOQL and DML never run inside loops and that every class declares with sharing, without sharing, or inherited sharing
  • Designed for reviewing or generating Apex classes, trigger handlers, batch jobs, and test classes before deployment

Install

$ npx -y skills add github/awesome-copilot --skill salesforce-apex-quality -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

// ❌ 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

Details

Repository
github.com/github/awesome-copilot
Categories
Code Review & Quality, Testing & QA, Security
First seen
May 16, 2026

More from github/awesome-copilot

All 293

Similar to Salesforce Apex Quality

More Code Review & Quality