
Sf Debug
Debug Apex and Salesforce runtime issues using Limits APIs, log parsing, Execute Anonymous, and Tooling API trace flags.
Overview
Sf-debug is an agent skill most often used in Ship (also Operate errors) that guides Salesforce debugging with Limits APIs, logs, Execute Anonymous, and trace flags.
Install
npx skills add https://github.com/clientell-ai/salesforce-skills --skill sf-debugWhat is this skill?
- Complete Limits class method reference table (queries, DML, CPU, heap, callouts, queueable, and more)
- Sync vs async limit columns (e.g. 100 vs 200 SOQL, 10s vs 60s CPU)
- Execute Anonymous patterns and debug log parsing guidance
- Performance profiling and structured error-handling reference
- Tooling API trace flag management for targeted log capture
- Limits reference covers method pairs including queries, DML, CPU, heap, callouts, future, and queueable jobs
- Documents sync SOQL limit 100 vs async 200 and CPU 10,000 ms vs 60,000 ms
Adoption & trust: 1 installs on skills.sh; 7 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You hit governor limit failures or opaque Apex errors and lack a single reference for limits, logs, and trace configuration.
Who is it for?
Indie Salesforce builders diagnosing limit exceptions, async vs sync discrepancies, and production-like sandbox failures.
Skip if: Greenfield Salesforce learning with no Apex yet, or non-Salesforce application debugging.
When should I use this skill?
User debugs Apex failures, governor limits, Salesforce logs, Execute Anonymous scripts, or trace flags.
What do I get? / Deliverables
You can map failures to specific limit buckets, capture readable debug logs, and profile performance with repeatable Salesforce-native techniques.
- Limit usage diagnosis mapped to Limits class methods
- Trace flag and log capture plan for the failing transaction
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Primary shelf is Ship because systematic debug and limit profiling happen while validating code before production, though it remains essential in Operate when errors surface live. Testing subphase covers reproducing failures, reading debug logs, and profiling governor limits before release.
Where it fits
Profile a bulk trigger approach against getDmlRows and getCpuTime before promoting to production.
Parse overnight batch failure logs and tie heap size errors to specific Limit methods.
Design queueable chaining with getQueueableJobs limits in mind during feature implementation.
How it compares
Salesforce-native limit and log playbook—not generic stack-trace debugging for Node or Python services.
Common Questions / FAQ
Who is sf-debug for?
Solo and small-team Apex developers who need governor limit tables, log parsing, and trace flag steps inside their coding agent.
When should I use sf-debug?
During Ship testing when validating triggers and batch jobs, and during Operate when investigating user-reported errors or limit spikes in live orgs.
Is sf-debug safe to install?
The skill describes diagnostic actions that can enable verbose logging; review the Security Audits panel on this page and avoid broad trace flags in production without change control.
SKILL.md
READMESKILL.md - Sf Debug
# Debug Reference Deep reference for Salesforce debugging — Limits class API, log parsing, Execute Anonymous patterns, error handling, performance profiling, and Tooling API trace flag management. --- ## Complete Limits Class Method Reference All methods follow the pattern: `Limits.getX()` returns current usage, `Limits.getLimitX()` returns the maximum. | Method Pair | Sync Limit | Async Limit | Description | |-------------|-----------|-------------|-------------| | `getQueries()` / `getLimitQueries()` | 100 | 200 | SOQL queries issued | | `getDmlStatements()` / `getLimitDmlStatements()` | 150 | 150 | DML statements executed | | `getDmlRows()` / `getLimitDmlRows()` | 10,000 | 10,000 | Total rows processed by DML | | `getQueryRows()` / `getLimitQueryRows()` | 50,000 | 50,000 | Total rows retrieved by SOQL | | `getCpuTime()` / `getLimitCpuTime()` | 10,000 ms | 60,000 ms | CPU time consumed | | `getHeapSize()` / `getLimitHeapSize()` | 6,291,456 | 12,582,912 | Heap memory in bytes | | `getCallouts()` / `getLimitCallouts()` | 100 | 100 | HTTP/SOAP callouts | | `getFutureCalls()` / `getLimitFutureCalls()` | 50 | 0 | @future method invocations | | `getQueueableJobs()` / `getLimitQueueableJobs()` | 50 | 1 | Queueable jobs enqueued | | `getAggregateQueries()` / `getLimitAggregateQueries()` | 300 | 300 | Aggregate SOQL queries | | `getSoslQueries()` / `getLimitSoslQueries()` | 20 | 20 | SOSL queries | | `getPublishImmediateDML()` / `getLimitPublishImmediateDML()` | 150 | 150 | Platform Event publishes | | `getEmailInvocations()` / `getLimitEmailInvocations()` | 10 | 10 | Emails sent via Apex | | `getMobilePushApexCalls()` / `getLimitMobilePushApexCalls()` | 10 | 10 | Mobile push notifications | | `getSavepoints()` / `getLimitSavepoints()` | 150 (shared w/ DML) | 150 | Database savepoints | | `getSavepointRollbacks()` / `getLimitSavepointRollbacks()` | 150 (shared w/ DML) | 150 | Savepoint rollbacks | | `getFieldsDescribes()` / `getLimitFieldsDescribes()` | 100 | 100 | Schema describe calls | | `getPicklistDescribes()` / `getLimitPicklistDescribes()` | 100 | 100 | Picklist describe calls | ### Limits Snapshot Utility ```apex // Log all key limits at a named checkpoint public with sharing class LimitsLogger { public static void logAll(String context) { System.debug(LoggingLevel.INFO, '=== Limits [' + context + '] === ' + 'SOQL:' + Limits.getQueries() + '/' + Limits.getLimitQueries() + ' DML:' + Limits.getDmlStatements() + '/' + Limits.getLimitDmlStatements() + ' CPU:' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime() + ' Heap:' + Limits.getHeapSize() + '/' + Limits.getLimitHeapSize()); } } ``` --- ## Debug Log Format — Parsing Patterns Each debug log line follows this structure: ``` HH:MM:SS.sss (nanoseconds)|EVENT_TYPE|[line,col]|details ``` ### Regex Patterns for Common Log Events ``` # SOQL queries with line numbers and statements SOQL_EXECUTE_BEGIN\|\[(\d+)\]\|.*?\|(SELECT .+) SOQL_EXECUTE_END\|\[(\d+)\]\|Rows:(\d+) # DML operations DML_BEGIN\|\[(\d+)\]\|Op:(Insert|Update|Delete|Upsert|Undelete)\|Type:(\w+)\|Rows:(\d+) # Exceptions and fatal errors EXCEPTION_THROWN\|\[(\d+)\]\|(.+?):\s*(.+) FATAL_ERROR\|(.+) # Governor limit summary Number of SOQL queries: (\d+) out of (\d+) Number of DML statements: (\d+) out of (\d+) Maximum CPU time: (\d+) out of (\d+) Maximum heap size: (\d+) out of (\d+) # Heap, callouts, debug output HEAP_ALLOCATE\|\[(\d+)\]\|Bytes:(\d+) CALLOUT_REQUEST\|\[(\d+)\]\|(.+) USER_DEBUG\|\[(\d+)\]\|(\w+)\|(.+) CODE_UNIT_STARTED\|\[EXTERNAL\]\|(.+) FLOW_START_INTERVIEWS_BEGIN\|(.+) # Log truncation detection \*\*\* Skipped (\d+) bytes of detailed log ``` --- ## Execute Anonymous Debugging Patterns ### Reproduce a Specific Record Issue ```apex Id recordId = '001xxxxxxxxxxxx'; Account acc = [SELECT Id, Name, Industry, OwnerId, (SELECT Id, Amount FROM Opportunities) FROM Account WHERE Id = :recordId]; Sy