nadolskimm-max/sf-skills/sf-debug
Claude Code and agent skill by nadolskimm-max/sf-skills
- community
Checking that the SKILL.md file is still in the repository.
Analyzes Salesforce debug logs, diagnoses governor limit violations, and identifies performance bottlenecks. Use when investigating errors, analyzing debug logs, fixing SOQL-in-loop issues, CPU time violations, heap size errors, or mixed DML exceptions. Do NOT use for writing new Apex logic (use sf-apex) or running tests (use sf-testing).
Install
npx vskill@latest install nadolskimm-max/sf-skills/sf-debugSKILL.md
The same SKILL.md was published earlier as nadolskimm-max/sf-skills/sf-debug.
Salesforce Debug & Troubleshooting
Core Responsibilities
- Analyze debug logs for errors and performance issues
- Diagnose governor limit violations (SOQL limits, CPU time, heap)
- Identify and fix common runtime exceptions
- Set up and manage trace flags
- Recommend performance optimizations
Workflow
Phase 1 — Capture
Set up trace flags and capture logs:
Phase 2 — Analyze
Look for these patterns in order:
- FATAL_ERROR lines — the root cause
- LIMIT_USAGE_FOR_NS — governor limit consumption
- DML_BEGIN/DML_END inside LOOP — DML in loop
- SOQL_EXECUTE_BEGIN count > 100 — too many queries
- CUMULATIVE_LIMIT_USAGE at end — overall consumption
Phase 3 — Fix
Apply targeted fixes based on the diagnosis:
Common Exceptions & Fixes
| Exception | Root Cause | Fix | |
|---|---|---|---|
System.LimitException: Too many SOQL queries: 101 | SOQL inside for-loop | Move query before loop, use Map for lookups | |
System.LimitException: Apex CPU time limit exceeded | Complex logic or large loops | Optimize algorithms, reduce loop iterations, use batch | |
System.LimitException: Apex heap size too large | Large data structures in memory | Process in smaller chunks, remove unnecessary variables | |
System.DmlException: MIXED_DML_OPERATION | Setup + non-setup DML in same transaction | Use System.runAs() or separate into @future | |
System.NullPointerException | Accessing field on null reference | Add null checks before accessing fields | |
System.QueryException: List has no rows | .get(0) or assignment from empty query | Use List<> return type, check isEmpty() | |
System.DmlException: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY | Trigger/flow error on related DML | Check trigger handler and flow entry criteria | |
System.CalloutException: Callout from triggers not supported | HTTP callout in trigger context | Use @future(callout=true) or Queueable |
Governor Limit Diagnosis
When analyzing CUMULATIVE_LIMIT_USAGE:
Priority thresholds:
- > 90% of any limit → CRITICAL — will fail at scale
- > 70% of any limit → WARNING — refactor recommended
- < 50% of all limits → HEALTHY
Debug Log Levels
| Category | Level for Debugging | Level for Production | |
|---|---|---|---|
| Apex_code | FINEST | ERROR | |
| Apex_profiling | FINE | NONE | |
| Database | FINE | ERROR | |
| System | DEBUG | ERROR | |
| Validation | INFO | ERROR | |
| Workflow | FINE | ERROR | |
| Callout | FINE | ERROR |
Performance Optimization Checklist
- SOQL: Move queries outside loops, use selective filters, add LIMIT
- DML: Collect records in lists, single DML operation after loop
- CPU: Reduce nested loops, use Maps instead of nested queries
- Heap: Process in batches, null out large variables after use
- Callouts: Use Queueable for chaining, batch for bulk callouts
Cross-Skill References
- For fixing Apex code issues: see sf-apex
- For re-running tests after fixes: see sf-testing
- For query optimization: see sf-soql
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sf-debug/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nadolskimm-max/sf-skills/sf-debug)