org-limits-monitoring
Use when designing or implementing proactive monitoring of Salesforce org-level limits such as API call consumption, storage usage, custom object counts, or platform event allocations. Trigger phrases: 'how do I monitor org limits programmatically', 'set up alerts before we hit API limits', 'REST Limits resource usage', 'OrgLimits.getAll() in Apex', 'scheduled limit checks', 'proactive limit threshold alerting', 'Company Information limits dashboard', 'we keep getting surprised by limit breaches in production'. NOT for per-transaction governor limit planning (use limits-and-scalability-planning). NOT for Connected App API throttling or rate limiting policies (use api-security-and-rate-limiting). NOT for individual Apex code optimization against transaction limits (use apex-cpu-and-heap-optimization).
Best use case
org-limits-monitoring is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when designing or implementing proactive monitoring of Salesforce org-level limits such as API call consumption, storage usage, custom object counts, or platform event allocations. Trigger phrases: 'how do I monitor org limits programmatically', 'set up alerts before we hit API limits', 'REST Limits resource usage', 'OrgLimits.getAll() in Apex', 'scheduled limit checks', 'proactive limit threshold alerting', 'Company Information limits dashboard', 'we keep getting surprised by limit breaches in production'. NOT for per-transaction governor limit planning (use limits-and-scalability-planning). NOT for Connected App API throttling or rate limiting policies (use api-security-and-rate-limiting). NOT for individual Apex code optimization against transaction limits (use apex-cpu-and-heap-optimization).
Teams using org-limits-monitoring should expect a more consistent output, faster repeated execution, less prompt rewriting, better workflow continuity with your supporting tools.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
- You already have the supporting tools or dependencies needed by this skill.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/org-limits-monitoring/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How org-limits-monitoring Compares
| Feature / Agent | org-limits-monitoring | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when designing or implementing proactive monitoring of Salesforce org-level limits such as API call consumption, storage usage, custom object counts, or platform event allocations. Trigger phrases: 'how do I monitor org limits programmatically', 'set up alerts before we hit API limits', 'REST Limits resource usage', 'OrgLimits.getAll() in Apex', 'scheduled limit checks', 'proactive limit threshold alerting', 'Company Information limits dashboard', 'we keep getting surprised by limit breaches in production'. NOT for per-transaction governor limit planning (use limits-and-scalability-planning). NOT for Connected App API throttling or rate limiting policies (use api-security-and-rate-limiting). NOT for individual Apex code optimization against transaction limits (use apex-cpu-and-heap-optimization).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
Use this skill when an org needs proactive, automated visibility into its consumption of Salesforce platform limits. Unlike per-transaction governor limits that are enforced inline during code execution, org-level limits are shared ceilings that accumulate over time -- daily API calls, data storage, file storage, custom object counts, platform event delivery allocations, and more. When these limits are exhausted, the impact is org-wide: all integrations fail, all users are blocked from creating records, or platform events are silently dropped. The correct response is not reactive firefighting but proactive monitoring with automated threshold alerts. --- ## Before Starting - **Which limits matter most?** Not every org needs to monitor every limit. Identify the limits that are most likely to be exhausted given the org's usage pattern -- integration-heavy orgs should monitor API calls; high-growth orgs should monitor storage; event-driven architectures should monitor platform event delivery allocations. - **What is the current consumption baseline?** Before setting thresholds, establish what "normal" looks like. A single day's snapshot is not enough -- collect at least two weeks of data to identify peaks and trends. - **What notification channels are available?** Email is the simplest but most easily ignored. Platform Events can drive real-time LWC dashboards. Custom Notifications appear in-app. Outbound Messages or callouts can reach Slack or PagerDuty. --- ## Core Concepts ### Three Monitoring Surfaces Salesforce exposes org-level limit data through three distinct surfaces, each with different strengths: #### Surface 1: Apex OrgLimits Class The `System.OrgLimits` class (available since API v41.0) provides a `Map<String, System.OrgLimit>` via `OrgLimits.getAll()`. Each `OrgLimit` instance exposes `.getName()`, `.getLimit()`, and `.getValue()` (current consumption). This is the best surface for scheduled Apex-based monitoring because it runs inside the org without consuming an API call. Key characteristics: - Returns a curated subset of limits, not every limit the REST resource exposes. - Does not consume an API call (it is native Apex, not a callout). - Available in all Apex execution contexts (trigger, batch, queueable, scheduled). - The map keys are string names like `DailyApiRequests`, `DataStorageMB`, `FileStorageMB`, `DailyAsyncApexExecutions`, `DailyBulkApiRequests`, `DailyStreamingApiEvents`, `HourlyPublishedPlatformEvents`, and others. #### Surface 2: REST API Limits Resource `GET /services/data/vXX.0/limits` returns a JSON object with every org limit, including limits not available through the Apex class. Each entry contains `Max` and `Remaining` values. Key characteristics: - Most comprehensive surface -- exposes limits that OrgLimits.getAll() does not. - Consumes one API call per invocation (factor this into API budget calculations). - Ideal for external monitoring tools, middleware health checks, or CI/CD pre-deployment validation. - Response payload is a flat JSON object with limit names as keys. #### Surface 3: Setup -- Company Information The Setup > Company Information page displays storage usage, API usage (last 24 hours), and feature limits in the UI. This is the only monitoring surface available to administrators without developer tooling. Key characteristics: - No programmatic access -- manual inspection only. - Useful for one-time audits but not for proactive alerting. - Shows a rolling 24-hour window for API usage. - Storage breakdown shows data storage, file storage, and big object storage separately. ### Threshold Alerting Architecture The recommended architecture for proactive limit monitoring follows a simple pattern: 1. **Scheduled Apex** runs on a cron schedule (hourly or every 4 hours). 2. The job calls `OrgLimits.getAll()` and compares each limit's `.getValue()` against `.getLimit()`. 3. When consumption crosses a configured threshold (e.g., 70% warning, 90% critical), the job fires an alert through one or more channels. 4. Alert channels include: `Messaging.SingleEmailMessage` for email, Platform Event publish for real-time dashboard updates, `Messaging.CustomNotification` for in-app bell notifications, or an HTTP callout to an external incident management system. ### Custom Metadata for Threshold Configuration Store monitoring thresholds in Custom Metadata Type records rather than hard-coding them. This allows administrators to adjust thresholds without code changes and supports per-limit configuration: - `Limit_Monitor_Config__mdt` with fields: `Limit_Name__c` (text, matches the OrgLimit key), `Warning_Threshold__c` (percent, e.g., 70), `Critical_Threshold__c` (percent, e.g., 90), `Enabled__c` (checkbox), `Notification_Channel__c` (picklist: Email / Platform Event / Custom Notification / External). ### Distinguishing From Related Skills | Concern | Correct Skill | |---|---| | Designing for governor limit headroom in new builds | limits-and-scalability-planning | | Throttling API consumers via Connected App policies | api-security-and-rate-limiting | | Optimizing individual Apex transactions for CPU/heap | apex-cpu-and-heap-optimization | | Monitoring org-wide limit consumption and alerting | **org-limits-monitoring** (this skill) | --- ## Recommended Workflow 1. **Identify critical limits.** Review the org's integration landscape, storage trajectory, and automation density. Select the 5-10 limits most likely to be exhausted. Common high-priority limits: `DailyApiRequests`, `DataStorageMB`, `FileStorageMB`, `DailyBulkApiRequests`, `HourlyPublishedPlatformEvents`, `DailyAsyncApexExecutions`. 2. **Establish baselines.** Run `OrgLimits.getAll()` or `GET /services/data/vXX.0/limits` daily for two weeks. Record peak consumption values. Use these peaks to set meaningful thresholds that avoid false alarms. 3. **Design the monitoring job.** Create a Scheduled Apex class that reads limit values from `OrgLimits.getAll()`, compares them against thresholds stored in Custom Metadata, and dispatches alerts when thresholds are crossed. Schedule the job at an appropriate frequency (hourly for API-heavy orgs, every 4 hours for storage-focused monitoring). 4. **Configure alert routing.** Map each limit to a notification channel. API limit breaches may need to reach the integration team via Slack webhook. Storage warnings may need to reach the data team via email. Critical alerts for any limit should page the platform team. 5. **Build visibility.** Create a Lightning Dashboard or LWC component that displays current limit consumption as gauges or progress bars. If the monitoring job publishes Platform Events, the dashboard can update in near-real-time without polling. 6. **Test with realistic load.** In a full sandbox, simulate high-consumption scenarios (e.g., run a bulk data load that consumes 80% of daily API calls) and verify that alerts fire correctly and reach the intended audience. 7. **Operationalize.** Add the monitoring job to the org's runbook. Document the escalation path for each alert severity. Review thresholds quarterly as org usage patterns evolve. --- ## Modes of Engagement ### Mode 1: Greenfield Monitoring Setup The org has no limit monitoring in place. Start from Step 1 of the Recommended Workflow. Deliver a complete monitoring solution including Scheduled Apex, Custom Metadata configuration, alert routing, and a visibility dashboard. ### Mode 2: Incident Response -- Limit Exhausted A limit has already been breached. Start by identifying which limit was exhausted using `GET /services/data/vXX.0/limits` or Setup > Company Information. Determine the root cause (unexpected integration spike, data load, runaway automation). Implement emergency mitigation (disable the offending integration, archive data, increase allocation if contractually possible). Then proceed to Mode 1 to prevent recurrence. ### Mode 3: Existing Monitoring Enhancement The org has basic monitoring (e.g., a weekly manual check or a simple email alert) but needs more sophistication. Assess the current monitoring coverage, identify blind spots (limits not being tracked, thresholds too high or too low, alert fatigue from false positives), and enhance the solution incrementally. --- ## Key Limit Categories ### API Consumption Limits | Limit | Scope | How to Check | |---|---|---| | DailyApiRequests | Per 24-hour rolling window | OrgLimits / REST /limits | | DailyBulkApiRequests | Per 24-hour rolling window | OrgLimits / REST /limits | | DailyBulkV2QueryJobs | Per 24-hour rolling window | REST /limits | | DailyBulkV2QueryFileStorageMB | Per 24-hour rolling window | REST /limits | ### Storage Limits | Limit | Scope | How to Check | |---|---|---| | DataStorageMB | Org-wide | OrgLimits / REST /limits / Setup | | FileStorageMB | Org-wide | OrgLimits / REST /limits / Setup | ### Platform Event Limits | Limit | Scope | How to Check | |---|---|---| | HourlyPublishedPlatformEvents | Per clock hour | OrgLimits / REST /limits | | HourlyPublishedStandardVolumePlatformEvents | Per clock hour | REST /limits | | DailyStandardVolumePlatformEvents | Per 24-hour rolling window | REST /limits | ### Async Processing Limits | Limit | Scope | How to Check | |---|---|---| | DailyAsyncApexExecutions | Per 24-hour rolling window | OrgLimits / REST /limits | | ConcurrentAsyncGetReportInstances | Concurrent | REST /limits | --- ## Official Sources Used - Apex Reference Guide -- OrgLimits class and OrgLimit methods - REST API Developer Guide -- Limits resource (`/services/data/vXX.0/limits`) - Salesforce Help -- Monitor API Usage and Limits - Salesforce Well-Architected Overview -- Operational Excellence pillar
Related Skills
limits-and-scalability-planning
Use when planning a new org build for scale, auditing an existing org for governor limit exposure, or investigating a limit-related incident. Trigger phrases: 'org is hitting governor limits', 'how many custom objects can we have', 'will our data volume cause performance issues', 'batch job keeps failing with limit errors', 'planning for 10 million records', 'platform event throughput limits', 'SOQL limit exceeded in production'. NOT for code-level optimization (use apex-cpu-and-heap-optimization), NOT for individual SOQL query tuning (use apex/soql-optimization), NOT for Batch Apex authoring mechanics (use apex/batch-apex).
event-monitoring
Shield Event Monitoring: event log types, downloading logs via REST API and SOQL, real-time event monitoring with streaming API, and threat detection policies. NOT for debug logs (use debug-logs-and-developer-console). NOT for custom platform event publishing/subscribing (use platform-events-apex).
callout-limits-and-async-patterns
Use when designing or troubleshooting Apex callouts that approach governor limits: choosing between synchronous callouts, @future, Queueable, Continuation, or async chaining strategies. NOT for HTTP request construction or Named Credential setup (use named-credentials-setup).
api-governance-and-rate-limits
Monitor and govern Salesforce API consumption: per-user limits, org allocation, lightning-rest limits, and backoff. NOT for designing new endpoints.
flow-governor-limits-deep-dive
Compute and budget governor-limit consumption per Flow type with worked math: SOQL, DML rows, CPU time, heap. Includes per-entry-point budget tables, cross-automation shared-limit math, and tuning strategies when a flow hits a ceiling. NOT for general bulkification (use flow-bulkification). NOT for Apex limits (use apex-governor-limits).
flow-error-monitoring
Set up monitoring + alerting for Flow runtime errors at org scale: routing fault emails, Flow runtime error reports, custom centralized logging (Integration_Log__c), escalation thresholds, and trend detection. NOT for diagnosing a specific flow error (use flow-runtime-error-diagnosis). NOT for debug-mode setup (use flow-debugging).
deployment-monitoring
Tracking the real-time and historical status of Salesforce metadata deployments via Metadata API checkDeployStatus, REST deployRequest polling, and the Deployment Status Setup page. Covers DeployResult field interpretation, component error triage, concurrent deployment queue behavior, and 30-day history limits. NOT for post-deployment functional smoke testing (use post-deployment-validation). NOT for CI/CD pipeline setup (use github-actions-for-salesforce). NOT for rollback execution.
scheduled-apex-failure-detection-and-monitoring
Use when nightly batch / scheduled Apex jobs are failing without anyone noticing — covers why uncaught exceptions in `execute()` go to the debug log instead of email, how to query `AsyncApexJob` for `Status`, `NumberOfErrors`, and `ExtendedStatus`, when to implement `Database.RaisesPlatformEvents` so the platform publishes `BatchApexErrorEvent` on uncaught failures, how to subscribe to that event with an Apex trigger and notify operators, and how to layer a custom watcher schedule on top so silent-failure modes (job that never started, scheduled class deleted, queue stuck on `Queued`) still surface. Triggers: 'nightly batch failed at 2am with no notification', 'how do we know if a scheduled apex job is failing', 'BatchApexErrorEvent vs custom retry logic', 'Setup Apex Jobs only shows last 7 days, where else can I look', 'job is stuck in queued status nobody noticed for a week'. NOT for general Apex exception handling patterns (use apex/apex-exception-handling-and-logging), NOT for Batch Apex authoring or chunking strategy (use apex/batch-apex-design), NOT for Setup → Apex Jobs UI walkthrough as an admin task (use admin/batch-job-scheduling-and-monitoring), NOT for retry logic itself (use apex/scheduled-apex-retry-patterns once authored).
governor-limits
Use when writing, reviewing, or troubleshooting Apex that risks hitting Salesforce governor limits. Triggers: 'too many SOQL queries', 'too many DML statements', 'CPU time limit', 'bulkification', 'Queueable vs Batch'. NOT for trigger architecture decisions unless the core problem is limit consumption.
formula-field-performance-and-limits
Use when diagnosing SOQL performance problems caused by formula fields, hitting formula compile-size limits, or deciding whether to replace a formula field with a stored field for indexing. Triggers: 'formula field slowing SOQL', 'compile size limit', 'cross-object formula spanning limit', 'formula field not indexable', 'LDV query full table scan', 'SOQL WHERE on formula'. NOT for formula syntax help, building formula expressions, or authoring new formulas from scratch — use admin/formula-fields for that.
custom-logging-and-monitoring
Use when designing or implementing a custom logging framework in Apex: log sObject schema, log level gating, retention policies, batch purge jobs, and forwarding logs to external monitoring systems (Splunk, Datadog, etc.). NOT for built-in debug logs or Developer Console (use debug-logs-and-developer-console), NOT for exception capture and error propagation (use error-handling-framework), NOT for Event Monitoring (use security skills).
apex-limits-monitoring
Use this skill when writing Apex that must check governor limits at runtime before executing expensive operations — guard clauses, early-exit patterns, Queueable re-queue on limit approach, and batch scope sizing. Trigger keywords: check governor limits before SOQL apex, defensive coding against limits apex, Limits.getDMLStatements getLimitDMLStatements, Limits class usage, guard clause governor limits, remaining SOQL queries Apex, heap size check before DML, LimitException handling. NOT for limit values themselves — see apex-cpu-and-heap-optimization. NOT for async job design choices — use the async-selection decision tree. NOT for org-level aggregate limit consumption — see architect/org-limits-monitoring.