sf-governor-limits

Diagnose and mitigate Salesforce Apex governor limit violations in transactions.

13|2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-governor-limits
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sf-governor-limits
Source: https://github.com/jiten-singh-shahi/salesforce-claude-code/tree/main/.cursor/skills/sf-governor-limits
Command: npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-governor-limits

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers diagnose and remediate Salesforce Apex transactions that exceed governor limits and throw System.LimitException by identifying root causes and suggesting concrete optimizations.

Core Features & Use Cases

  • Detect and diagnose: Identify SOQL-in-loop, excessive DML, heap and CPU hotspots, and improper callout usage that lead to limit breaches.
  • Optimization strategies: Advise on query consolidation into maps, aggregate queries, single-batch DML patterns, async offloading, heap reduction techniques, and limit-aware guards.
  • Testing and validation: Provide patterns for unit tests that reset and measure limit consumption, and guidance for bulk-safe trigger and service design.

Quick Start

Ask the skill to analyze this Apex trigger that throws a System.LimitException and recommend specific refactors to remove SOQL-in-loop and minimize DML.

Frequently Asked Questions about sf-governor-limits

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix System.LimitException in Salesforce Apex triggers?

To fix System.LimitException in Apex triggers, you must diagnose and remediate governor limit violations by consolidating SOQL queries, removing DML inside loops, and applying bulk-safe processing patterns.

What causes Salesforce Apex governor limit violations during bulk processing?

Apex governor limit violations occur when transactions exceed SOQL, DML, CPU, or heap limits due to inefficient bulk processing, typically caused by SOQL-in-loop patterns, excessive DML statements, or improper callout usage.

How do I optimize SOQL and DML limits in synchronous Apex controllers?

Optimize SOQL and DML limits in synchronous Apex controllers by consolidating queries into maps, using aggregate queries, executing single-batch DML operations, and offloading heavy processing to asynchronous queueable jobs.

Can I use asynchronous Apex to prevent CPU and heap limit exceptions?

Yes, you can prevent CPU and heap limit exceptions by offloading resource-intensive logic to asynchronous Apex jobs like batch or queueable classes, which have higher governor limits and support heap minimization techniques.

How do I write unit tests that measure Apex governor limit consumption?

You can write unit tests that measure Apex governor limit consumption by using built-in limit methods to reset and track resource usage, validating that your trigger and service designs remain bulk-safe under load.

What is the best way to handle callout limits in Salesforce Apex integrations?

The best way to handle callout limits in Apex integrations is to identify improper callout usage, implement limit-aware guards, and offload long-running external requests to asynchronous processing to avoid boundary breaches.