In any Apex REST resource or Invocable method that may be called externally, query Limits.getQueries() vs Limits.getLimitQueries() and similar pairs at the end of execution and include the consumed/limit ratio in a custom response header or return object
Define a LimitSnapshot helper class that captures all key Limits values at construction time; take a snapshot before and after heavy operations to compute the delta consumed by that section of code
Surface warnings to callers when any limit crosses a configured threshold (e.g., 80% of SOQL limit consumed) by returning a warnings array in the API response body rather than throwing an exception
Use the Apex Profiling section in debug logs (set the log category to PROFILING at FINE level) to identify which methods consume disproportionate CPU or SOQL budget during load testing
For long-running processes, implement a continuation pattern: if remaining limits fall below a safe threshold mid-process, serialize state to a custom object or Platform Cache, return a partial result with a resumeToken, and let the caller re-invoke with that token to continue
Instrument Batch Apex start(), execute(), and finish() methods with LimitSnapshot logging so per-batch-chunk limit consumption is visible in the batch job's debug log
Known gotchas
Limits methods reflect the cumulative consumption since the start of the current transaction — there is no built-in way to reset or checkpoint limits mid-transaction, only to read them
Platform Cache operations are not reflected in Limits.getQueries() — they have their own capacity metrics accessible via the Cache.Org.getCapacity() and similar methods, which are separate from the SOQL governor
In Apex test context, Limits values reset per test method (each @isTest method starts fresh), which means integration tests that chain multiple operations must be structured as a single test method to accurately measure cumulative limit consumption
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp