Bulkify all triggers by operating on Trigger.new and Trigger.newMap collections rather than querying or DML-ing inside loops — move SOQL queries before loops and collect results in Maps keyed by record ID
Enforce a single trigger per object pattern and delegate business logic to handler classes, making it easier to track cumulative SOQL and DML calls across all before/after contexts
Use custom metadata or custom settings to store configuration thresholds so that limit-aware logic (e.g., skip callout if already at 90 callouts) can be adjusted without a code deployment
Check Limits.getLimitQueries(), Limits.getQueries(), Limits.getLimitDmlStatements(), and Limits.getDmlStatements() at critical points in batch or complex flows to detect approaching limits early
For CPU-intensive operations, move processing to Queueable or Batch Apex with explicit chaining, breaking work into chunks that each start fresh with a full governor limit allocation
Use the @TestVisible annotation on helper methods and mock the Limits class behavior in unit tests to validate governor-limit guard logic without actually exhausting limits in test runs
Known gotchas
CPU time governor limits count BOTH Apex and database processing time in some contexts — a query that returns 50,000 rows and processes them in a loop can hit the CPU limit even if the SOQL limit is not exceeded
Static variables in Apex do not reset between records within the same transaction — a static counter used as a limit guard that resets per-class-load will accumulate correctly within a transaction but will not carry over between transactions
Platform cache hits still consume a small amount of CPU time and count toward the overall CPU governor — do not assume cache reads are free from a limits perspective
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