agentsclimarketplace

Sf debug

Skill kugamon/salesforce-core-skills/plugins/salesforce-core/skills/sf-debug

Eleven general-purpose Salesforce admin & developer skills for Claude (Apex, Flow, SOQL/Data, LWC, Metadata, Permissions, Diagrams, Org Audit, Tests, Security, Debug) — works with any Salesforce MCP server. Installable as a Claude Desktop / Cowork plugin marketplace.

Install
npx -y skills add kugamon/salesforce-core-skills --skill sf-debug

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Captures and analyzes Salesforce debug logs through the Tooling API — trace flag setup, log retrieval, parsing for exceptions, SOQL-in-loop detection, CPU/heap/limit analysis, and row-lock diagnosis — all MCP-first against the live org. Use when the user hits an error in Salesforce, mentions debug logs, governor limits, "too many SOQL queries", CPU timeouts, UNABLE_TO_LOCK_ROW, flow errors, or asks why something failed in the org. Usage: /sf-debug [trace|logs|analyze|limits] {user|class|logId} ...

SKILL.md

7.1 KB, as published. Nobody here has run it

Salesforce Debug Log Capture & Analysis

Debugging specialist for live Salesforce orgs. Set up tracing, capture the failure, read the log so the user doesn't have to, and hand back a diagnosis with the fix — not a wall of log lines.

Dispatch

First argument or intentWorkflow
trace, "turn on logging", "capture what happens"Set Up Tracing
logs, "get the logs", "latest log for X"Retrieve Logs
analyze, a log ID/file, "why did this fail"Analyze Log
limits, "governor limits", "CPU/heap usage"Limit Analysis
An error message pasted with no other contextTriage (below)

Triage: when the user pastes an error, classify first via references/common-errors.md — many errors (validation rule text, duplicate rules, flow fault emails) identify themselves without needing a log capture. Only set up tracing when the cause genuinely needs execution detail.

Execution modes

See references/execution-modes.md. This skill is inherently live-org: Tooling API via MCP in every mode (cli mode may use sf apex tail log as a convenience). Initialize the connection first (org_init convention).


Set Up Tracing

  1. Identify the traced entity — a user (most common), the Automated Process user (flows/platform events), or a platform integration user. Resolve the user ID via SOQL.

  2. Create or reuse a DebugLevel (Tooling DML). Default profile:

    CategoryLevelWhy
    ApexCodeFINEMethod entry/exit without FINEST's noise
    ApexProfilingINFOLimit snapshots
    DatabaseINFOSOQL/DML with row counts
    WorkflowINFOFlow/process elements
    CalloutINFORequest/response boundaries
    SystemDEBUGSystem.debug output
    ValidationINFORule evaluations

    Escalate to FINEST (ApexCode) only for method-level CPU hunts — FINEST logs hit the 20 MB truncation limit fast in busy transactions.

  3. Create the TraceFlag (Tooling DML): TracedEntityId, DebugLevelId, LogType='USER_DEBUG', ExpirationDate ≤ 30 minutes out. Short expirations are deliberate — abandoned trace flags fill org log storage (250 MB cap) and then NOTHING logs.

  4. Tell the user to reproduce the failure, or reproduce it yourself via apex_execute when the repro is scriptable (safe, non-mutating repros only in production — prefer sandboxes for anything that writes).

  5. Clean up afterward — delete the TraceFlag when analysis is done. Always. This is the debugging equivalent of removing the tourniquet.

Retrieve Logs

Query, newest first:

SELECT Id, LogUser.Name, Operation, Request, Status, LogLength,
       DurationMilliseconds, StartTime
FROM ApexLog ORDER BY StartTime DESC LIMIT 10

Filter by LogUserId, Operation (e.g. /apex/..., API, BatchApexWorker), or Status != 'Success' as context demands. Fetch the body via the MCP REST tool: GET /services/data/vXX.X/tooling/sobjects/ApexLog/{Id}/Body.

Logs over ~2 MB: don't read linearly. In code-execution modes, save to a file and extract the interesting sections with the parsing patterns below; in mcp-only mode, fetch and scan in chunks prioritizing the end of the log (exceptions and limit summaries cluster there).

Analyze Log

Work the log in this order — it's diagnostic priority, not file order:

  1. Fatal errors first: search FATAL_ERROR, EXCEPTION_THROWN, FLOW_ELEMENT_ERROR. The LAST exception is usually the reported one; the FIRST is usually the cause.
  2. Limit summary: LIMIT_USAGE_FOR_NS blocks (per namespace). Compare each meter to its ceiling — see Limit Analysis table.
  3. SOQL-in-loop signature: repeated SOQL_EXECUTE_BEGIN with the same query text and climbing aggregate count, typically interleaved with METHOD_ENTRY of the same method. Same pattern for DML_BEGIN = DML in loop. This is the #1 finding in real logs — report the query, the loop method, and the row counts.
  4. CPU hotspots: with ApexProfiling, use CUMULATIVE_PROFILING blocks; without it, bracket CODE_UNIT_STARTED/FINISHED timestamps to find the expensive unit. Flow-heavy transactions: count FLOW_ELEMENT_BEGIN — loops over collections in flows burn CPU invisibly.
  5. Lock diagnosis: UNABLE_TO_LOCK_ROW — identify the contested record from the DML context, then look for the competing transaction type (batch + trigger on the same parent is the classic). See references/common-errors.md for the resolution matrix.
  6. Callout timeline: CALLOUT_REQUEST/RESPONSE pairs — long gaps are external latency, not org problems; say so explicitly.

Output format — always this shape:

## Diagnosis
<one-paragraph root cause>

## Evidence
<log line numbers/timestamps + the meters or exceptions that prove it>

## Fix
<specific change, with a handoff to sf-apex/sf-flow/sf-test when code changes>

## Prevention
<the limit/pattern to watch, monitoring suggestion if warranted>

Limit Analysis

Reference ceilings (synchronous / asynchronous):

LimitSyncAsyncLog marker
SOQL queries100200Number of SOQL queries
SOQL rows50,00050,000Number of query rows
DML statements150150Number of DML statements
DML rows10,00010,000Number of DML rows
CPU time10,000 ms60,000 msMaximum CPU time
Heap6 MB12 MBMaximum heap size
Callouts100100Number of callouts
Future calls500 in future ctxNumber of future calls

Report meters above 60% as warnings and above 85% as critical even when the transaction succeeded — today's 87% is next month's limit exception when the data grows. For recurring analysis across many transactions, offer an org-wide pass: query recent ApexLog rows, extract limit blocks in a code loop, and present the top offenders by operation.

Cross-skill handoffs

  • Bulkification / CPU fixes → sf-apex (its 150-point rubric covers the patterns); flow element fixes → sf-flow
  • Failing tests captured in logs → sf-test
  • Systemic slow queries → sf-data (query optimization)

References

FileRead when
references/common-errors.mdTriage — error classification and resolution matrix
references/execution-modes.mdStart of session

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.