Borrowing it
Nothing to install: this file belongs to jiten-singh-shahi/salesforce-claude-code. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/jiten-singh-shahi/salesforce-claude-code/main/.cursor/skills/sf-apex-best-practices/SKILL.mdgit clone --depth 1 https://github.com/jiten-singh-shahi/salesforce-claude-codeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jiten-singh-shahi/salesforce-claude-code/sf-apex-best-practices)<a href="https://agentmods.dev/skills/jiten-singh-shahi/salesforce-claude-code/sf-apex-best-practices"><img src="https://agentmods.dev/badge/skills/jiten-singh-shahi/salesforce-claude-code/sf-apex-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/jiten-singh-shahi/salesforce-claude-code/sf-apex-best-practices"><img src="https://agentmods.dev/badge/skills/jiten-singh-shahi/salesforce-claude-code/sf-apex-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00034 | $0.02936 |
| Opus 5 | $0.00017 | $0.01468 |
| Sonnet 5 | $0.00007 | $0.00587 |
| Haiku 4.5 | $0.00003 | $0.00294 |
Grade A, and why
sf-apex-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 422 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Apex Best Practices
Procedures for writing production-ready Apex. Constraint rules (never/always lists) live in sf-apex-constraints. This skill covers the how — class organization, error handling patterns, null safety techniques, and collection usage.
Reference files:
@../_reference/GOVERNOR_LIMITS.md @../_reference/NAMING_CONVENTIONS.md @../_reference/SECURITY_PATTERNS.md
When to Use
- When writing new Apex classes, triggers, or test classes for a Salesforce org
- When reviewing existing Apex code for structure or error handling issues
- When onboarding new developers to Salesforce Apex coding standards
- When refactoring legacy Apex code to improve readability and maintainability
Class Organization
Organize class members in this order:
- Constants (
static final) - Static variables
- Instance variables (fields)
- Constructors
- Public methods
- Private/Protected methods
- Inner classes
public with sharing class OrderProcessor {
// 1. Constants
private static final String STATUS_PENDING = 'Pending';
private static final String STATUS_PROCESSING = 'Processing';
private static final String STATUS_COMPLETE = 'Complete';
private static final Integer MAX_LINE_ITEMS = 500;
// 2. Static variables
private static Boolean isProcessing = false;
// 3. Instance variables
private List<Order__c> orders;
private Map<Id, Account> accountMap;
private OrderValidator validator;
// 4. Constructor
public OrderProcessor(List<Order__c> orders) {
this.orders = orders;
this.accountMap = new Map<Id, Account>();
this.validator = new OrderValidator();
}
// 5. Public methods
public List<ProcessResult> processAll() {
List<ProcessResult> results = new List<ProcessResult>();
loadRelatedAccounts();
for (Order__c order : orders) {
results.add(processSingleOrder(order));
}
return results;
}
// 6. Private methods
private void loadRelatedAccounts() {
Set<Id> accountIds = new Set<Id>();
for (Order__c order : orders) {
if (order.AccountId != null) {
accountIds.add(order.AccountId);
}
}
for (Account acc : [SELECT Id, Name, CreditLimit__c FROM Account WHERE Id IN :accountIds]) {
accountMap.put(acc.Id, acc);
}
}
private ProcessResult processSingleOrder(Order__c order) {
if (!validator.isValid(order)) {
return new ProcessResult(order.Id, false, validator.getLastError());
}
order.Status__c = STATUS_PROCESSING;
return new ProcessResult(order.Id, true, null);
}
// 7. Inner classes
public class ProcessResult {
public Id orderId { get; private set; }
public Boolean success { get; private set; }
public String message { get; private set; }
public ProcessResult(Id orderId, Boolean success, String message) {
this.orderId = orderId;
this.success = success;
this.message = message;
}
}
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 11d ago First seen · 422 lines · 34 tokens per session scan A edd0443f2917
sf-apex-best-practices is a skill published in the GitHub repository jiten-singh-shahi/salesforce-claude-code (16 stars, last pushed 2mo ago), licensed MIT. It adds 34 tokens to every session and 2,936 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
case-feed-send-email-action
Use when configuring the outbound Send Email quick action in Lightning Case Feed — creating the action in Setup on Case (Action Type = Send Email), attaching a default Custom email template, setting predefined To/CC/BCC values, wiring QuickAction.QuickActionDefaultsHandler Apex defaults, respecting the Lightning…
approval-process-apex-patterns
Programmatically driving Salesforce Approval Processes from Apex — Approval.process(ProcessSubmitRequest) to submit, ProcessWorkitemRequest to approve / reject / reassign, recall semantics, querying ProcessInstance and ProcessInstanceWorkitem to find pending approvals, and the bulk-submit / bulk-action error-row…
connected-app-troubleshooting
Troubleshooting Connected App OAuth flows — IP relaxation vs IP restriction, refresh token policy traps (default kills the connection on first refresh), session-revocation semantics, the OAuth error-code catalog (invalidgrant, invalidclientid, unsupportedgranttype), per-user vs admin-pre-approved flows, and the…
connected-apps-and-auth
Use when designing, reviewing, or troubleshooting Salesforce connected apps, External Client Apps, Named Credentials, External Credentials, and OAuth-based integration access. Triggers: 'connected app', 'OAuth flow', 'client credentials', 'JWT bearer', 'Named Credential', 'External Credential', 'integration user', 'IP…
api-contract-documentation
Produce or review API contract documentation for Salesforce integrations: versioning policy artifacts, request/response schema specs, error code catalogs, rate limit documentation, OpenAPI generation for sObjects. Trigger keywords: Salesforce API versioning policy, API end-of-life policy, document API endpoints, REST…
activity-and-task-patterns
Task and Event objects: polymorphic WhatId/WhoId, Activity object model, ActivityHistory vs OpenActivity, activity timeline customization, bulk task creation, Einstein Activity Capture boundaries. NOT for turning on EAC or calendar sync — use admin/einstein-activity-capture-setup. NOT for Email-to-Case — use…