Sf apex constraints

From jiten-singh-shahi/salesforce-claude-code · View interactive version

Sf apex constraints is an AI agent skill from the GitHub repository jiten-singh-shahi/salesforce-claude-code. Enforce Apex governor limits, naming, bulkification, and security rules. Use when writing or reviewing ANY Apex class, trigger, or batch job. Do NOT use for LWC, Flow, or Visualforce.

How to use this skill

Skill file

Apex Constraints

When to Use

This skill auto-activates when writing, reviewing, or modifying any Apex class, trigger, or batch job. It enforces governor limits, naming conventions, bulkification rules, and security requirements for all Apex artifacts.

Hard rules that every Apex class, trigger, and batch job must satisfy. Violations here cause governor failures, security review rejections, or production incidents. Reference files contain the full data; this skill contains only the enforcement rules.

Core Rules

@../_reference/GOVERNOR_LIMITS.md

@../_reference/NAMING_CONVENTIONS.md

@../_reference/SECURITY_PATTERNS.md

@../_reference/DEPRECATIONS.md

Apex-Specific Rules

Never Do

Always Do

Anti-Pattern Reference

| Anti-Pattern | Problem | Correct Pattern |

|---|---|---|

| SOQL in loop | Exceeds per-transaction SOQL limit (see @../_reference/GOVERNOR_LIMITS.md) | Query once, store in Map |

| DML in loop | Exceeds per-transaction DML limit (see @../_reference/GOVERNOR_LIMITS.md) | Collect records, single DML after loop |

| Nested loops for matching | CPU time exhaustion (O(n^2)) | Map/Set lookup (O(1)) |

| String concat in loop | Heap growth + CPU waste | List<String> + String.join() |

| SELECT * (all fields) | Heap exhaustion | SELECT only required fields |

| No sharing keyword | Silent without sharing default | Explicit with sharing declaration |

| Missing CRUD/FLS check | Security review failure | WITH USER_MODE / AccessLevel.USER_MODE |

| Dynamic SOQL via concat | SOQL injection | Bind variables / queryWithBinds() |

| Catching Exception | Masks real bugs | Catch specific exception types |

| Ignoring SaveResult | Silent data loss | Inspect every Database.SaveResult |

| Hardcoded IDs | Breaks across orgs | SOQL / Custom Metadata lookup |

Related

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.