salesforce-advanced-troubleshooting
Apply Salesforce advanced debugging with debug logs, SOQL query plans, and EventLogFile analysis. Use when standard troubleshooting fails, investigating SOQL performance issues, or analyzing Apex governor limit violations. Trigger with phrases like "salesforce hard bug", "salesforce debug log", "salesforce governor limit", "salesforce query plan", "salesforce deep debug", "SOQL slow".
Best use case
salesforce-advanced-troubleshooting is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Apply Salesforce advanced debugging with debug logs, SOQL query plans, and EventLogFile analysis. Use when standard troubleshooting fails, investigating SOQL performance issues, or analyzing Apex governor limit violations. Trigger with phrases like "salesforce hard bug", "salesforce debug log", "salesforce governor limit", "salesforce query plan", "salesforce deep debug", "SOQL slow".
Teams using salesforce-advanced-troubleshooting should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/salesforce-advanced-troubleshooting/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How salesforce-advanced-troubleshooting Compares
| Feature / Agent | salesforce-advanced-troubleshooting | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Apply Salesforce advanced debugging with debug logs, SOQL query plans, and EventLogFile analysis. Use when standard troubleshooting fails, investigating SOQL performance issues, or analyzing Apex governor limit violations. Trigger with phrases like "salesforce hard bug", "salesforce debug log", "salesforce governor limit", "salesforce query plan", "salesforce deep debug", "SOQL slow".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Marketing
Discover AI agents for marketing workflows, from SEO and content production to campaign research, outreach, and analytics.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Agents for Marketing
A curated list of the best AI agents and skills for marketing teams focused on SEO, content systems, outreach, and campaign execution.
SKILL.md Source
# Salesforce Advanced Troubleshooting
## Overview
Deep debugging techniques for complex Salesforce issues: Apex debug log analysis, SOQL query plan optimization, governor limit diagnosis, and EventLogFile forensics.
## Prerequisites
- Salesforce CLI authenticated
- Access to Setup > Debug Logs
- Understanding of Apex governor limits
- Enterprise+ for EventLogFile access
## Instructions
### Step 1: Enable Debug Logging
```bash
# Set up debug logging for a specific user
sf apex log list --target-org my-org
# Create a trace flag for detailed logging
# Setup > Debug Logs > New Trace Flag
# - Traced Entity: your integration user
# - Debug Level: SFDC_DevConsole (or create custom)
# - Start: now, Expiration: +2 hours
# Tail logs in real-time
sf apex log tail --target-org my-org --debug-level SFDC_DevConsole
```
### Step 2: Analyze Debug Log for Governor Limits
```typescript
// Key governor limits to watch in debug logs:
const GOVERNOR_LIMITS = {
'Number of SOQL queries': { limit: 100, trigger: 'per transaction' },
'Number of query rows': { limit: 50000, trigger: 'per transaction' },
'Number of DML statements': { limit: 150, trigger: 'per transaction' },
'Number of DML rows': { limit: 10000, trigger: 'per transaction' },
'Maximum CPU time': { limit: 10000, trigger: 'ms per transaction' },
'Maximum heap size': { limit: 6000000, trigger: 'bytes (sync), 12MB (async)' },
'Number of callouts': { limit: 100, trigger: 'per transaction' },
'Number of future calls': { limit: 50, trigger: 'per transaction' },
};
// Parse debug log for limit consumption
// Look for lines like:
// Number of SOQL queries: 45 out of 100
// Number of query rows: 23456 out of 50000
// Maximum CPU time on the Salesforce servers: 8500 out of 10000
```
```bash
# Download and analyze debug log
sf apex log get --number 1 --target-org my-org > debug.log
# Search for limit warnings
grep -n "LIMIT_USAGE_FOR_NS" debug.log
grep -n "out of" debug.log | tail -20
# Search for slow SOQL
grep -n "SOQL_EXECUTE_BEGIN" debug.log
grep -n "SOQL_EXECUTE_END" debug.log
# Compare timestamps — queries > 1000ms need optimization
```
### Step 3: SOQL Query Plan Analysis
```typescript
// Use the Query Plan tool in Developer Console:
// Developer Console > Query Editor > Query Plan button
// Or via REST API (Tooling API)
const conn = await getConnection();
const queryPlan = await conn.request({
method: 'GET',
url: `/services/data/v59.0/query/?explain=SELECT Id, Name FROM Account WHERE Industry = 'Technology'`,
});
// Analyze the plan
for (const plan of queryPlan.plans) {
console.log({
cardinality: plan.cardinality, // Estimated result rows
fields: plan.fields, // Fields used in filter
leadingOperationType: plan.leadingOperationType, // Index | TableScan
relativeCost: plan.relativeCost, // Lower is better (0-1)
spikeError: plan.spikeError, // True if selective threshold exceeded
});
}
// GOOD: leadingOperationType = "Index" and relativeCost < 0.3
// BAD: leadingOperationType = "TableScan" — needs index or different filter
// Selective filters (use indexed fields):
// - Id, Name, OwnerId (always indexed)
// - CreatedDate, LastModifiedDate, SystemModstamp
// - Lookup/Master-Detail fields
// - Custom fields marked as External ID or Unique
// - Custom indexes (request via Salesforce Support)
```
### Step 4: Diagnose UNABLE_TO_LOCK_ROW
```typescript
// UNABLE_TO_LOCK_ROW occurs when:
// 1. Multiple processes update the same record simultaneously
// 2. Bulk operations trigger cascading updates via triggers/flows
// 3. Parent record locked by child DML (implicit lock)
// Diagnostic query — find records with heavy automation
const triggers = await conn.query(`
SELECT Name, TableEnumOrId, Body
FROM ApexTrigger
WHERE Status = 'Active'
ORDER BY TableEnumOrId
`);
console.log('Active triggers:', triggers.records.map(
(t: any) => `${t.Name} on ${t.TableEnumOrId}`
));
// Mitigation: Use Bulk API with serial mode
await conn.bulk2.loadAndWaitForResults({
object: 'Account',
operation: 'update',
input: csvData,
lineEnding: 'LF',
// Bulk API processes in parallel by default
// For lock issues, reduce concurrency or use smaller batches
});
```
### Step 5: EventLogFile Forensics (Enterprise+)
```typescript
// EventLogFile stores detailed API usage data for 30 days
const conn = await getConnection();
// Find heavy API consumers
const apiEvents = await conn.query(`
SELECT Id, EventType, LogDate, LogFileLength
FROM EventLogFile
WHERE EventType = 'API'
AND LogDate >= LAST_N_DAYS:1
ORDER BY LogFileLength DESC
LIMIT 5
`);
for (const event of apiEvents.records) {
// Download the CSV log file
const csvContent = await conn.request(
`/services/data/v59.0/sobjects/EventLogFile/${event.Id}/LogFile`
);
// CSV columns include:
// TIMESTAMP, USER_ID, URI, METHOD, STATUS_CODE, RUN_TIME, CPU_TIME, DB_TOTAL_TIME
// Parse to find slow queries, high CPU operations, etc.
console.log(`${event.EventType} log (${event.LogDate}): ${event.LogFileLength} bytes`);
}
// Login forensics
const loginEvents = await conn.query(`
SELECT Id, LogDate, LogFileLength
FROM EventLogFile
WHERE EventType = 'Login'
AND LogDate >= LAST_N_DAYS:7
`);
```
### Step 6: Minimal Reproduction
```typescript
// Strip to absolute minimum to isolate the issue
async function minimalRepro(): Promise<void> {
const conn = new jsforce.Connection({
loginUrl: process.env.SF_LOGIN_URL,
version: '59.0', // Pin version
});
await conn.login(process.env.SF_USERNAME!, process.env.SF_PASSWORD! + process.env.SF_SECURITY_TOKEN!);
// Test with simplest possible operation
try {
// 1. Can we query at all?
const result = await conn.query('SELECT Id FROM Account LIMIT 1');
console.log('Basic query works:', result.totalSize);
// 2. Can we create?
const created = await conn.sobject('Account').create({ Name: 'Debug Test' });
console.log('Create works:', created.success);
// 3. Clean up
await conn.sobject('Account').destroy(created.id);
console.log('Delete works');
} catch (error: any) {
console.error('FAILURE:', {
errorCode: error.errorCode,
message: error.message,
fields: error.fields,
});
}
}
```
## Output
- Debug logging enabled with trace flags
- Governor limit consumption identified
- SOQL query plan analyzed for performance issues
- EventLogFile data retrieved for API forensics
- Minimal reproduction created for support escalation
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| No debug logs appearing | Trace flag expired or wrong user | Recreate trace flag in Setup |
| `SOQL_EXECUTE_LIMIT` | 100+ queries in one transaction | Consolidate queries, use collections |
| Query plan shows TableScan | Non-selective filter | Add indexed field to WHERE clause |
| EventLogFile empty | Not Enterprise+ edition | Use instrumented client logging instead |
## Resources
- [Debug Log Reference](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_debugging_debug_log.htm)
- [SOQL Query Plan](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_query_plan.htm)
- [Governor Limits](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)
- [EventLogFile](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_eventlogfile.htm)
## Next Steps
For load testing, see `salesforce-load-scale`.Related Skills
windsurf-advanced-troubleshooting
Advanced Windsurf debugging for hard-to-diagnose IDE, Cascade, and indexing issues. Use when standard troubleshooting fails, Cascade produces consistently wrong output, or investigating deep configuration problems. Trigger with phrases like "windsurf deep debug", "windsurf mystery error", "windsurf impossible to fix", "cascade keeps failing", "windsurf advanced debug".
vercel-advanced-troubleshooting
Advanced debugging for hard-to-diagnose Vercel issues including cold starts, edge errors, and function tracing. Use when standard troubleshooting fails, investigating intermittent failures, or preparing evidence for Vercel support escalation. Trigger with phrases like "vercel hard bug", "vercel mystery error", "vercel intermittent failure", "difficult vercel issue", "vercel deep debug".
supabase-advanced-troubleshooting
Deep Supabase diagnostics: pg_stat_statements for slow queries, lock debugging with pg_locks, connection leak detection, RLS policy conflicts, Edge Function cold starts, and Realtime connection drop analysis. Use when standard troubleshooting fails, investigating performance regressions, debugging race conditions, or building evidence for Supabase support escalation. Trigger: "supabase deep debug", "supabase slow query", "supabase lock contention", "supabase connection leak", "supabase RLS conflict", "supabase cold start".
snowflake-advanced-troubleshooting
Apply advanced Snowflake debugging with query profiling, spill analysis, lock contention, and performance deep-dives using ACCOUNT_USAGE views. Use when standard troubleshooting fails, investigating slow queries, or diagnosing warehouse performance issues. Trigger with phrases like "snowflake hard bug", "snowflake slow query debug", "snowflake query profile", "snowflake spilling", "snowflake deep debug".
shopify-advanced-troubleshooting
Debug complex Shopify API issues using cost analysis, request tracing, webhook delivery inspection, and GraphQL introspection. Trigger with phrases like "shopify hard bug", "shopify mystery error", "shopify deep debug", "difficult shopify issue", "shopify intermittent failure".
sentry-advanced-troubleshooting
Advanced Sentry troubleshooting for complex SDK issues, silent event drops, source map failures, distributed tracing gaps, and SDK conflicts. Use when events silently disappear, source maps fail to resolve, traces break across service boundaries, or the SDK conflicts with other libraries like OpenTelemetry or winston. Trigger with phrases like "sentry events missing", "sentry source maps broken", "sentry debug", "sentry not capturing errors", "sentry tracing gaps", "sentry memory leak", "sentry sdk conflict".
salesforce-webhooks-events
Implement Salesforce Platform Events, Change Data Capture (CDC), and Outbound Messages. Use when building real-time integrations, listening for record changes, or implementing event-driven architecture with Salesforce. Trigger with phrases like "salesforce events", "salesforce CDC", "salesforce platform events", "salesforce streaming", "salesforce outbound message", "salesforce real-time".
salesforce-upgrade-migration
Analyze, plan, and execute Salesforce API version upgrades and jsforce major version migrations. Use when upgrading Salesforce API versions, migrating jsforce v1 to v3, or adapting to deprecated API changes. Trigger with phrases like "upgrade salesforce", "salesforce API version", "jsforce upgrade", "salesforce deprecation", "salesforce version migration".
salesforce-security-basics
Apply Salesforce security best practices for Connected Apps, OAuth, and field-level security. Use when securing API credentials, implementing least privilege access, or auditing Salesforce security configuration. Trigger with phrases like "salesforce security", "salesforce secrets", "secure salesforce", "salesforce connected app security", "salesforce FLS".
salesforce-sdk-patterns
Apply production-ready Salesforce jsforce patterns for TypeScript and Python. Use when implementing Salesforce integrations, refactoring SDK usage, or establishing team coding standards for Salesforce. Trigger with phrases like "salesforce SDK patterns", "jsforce best practices", "salesforce code patterns", "idiomatic salesforce", "salesforce typescript".
salesforce-reliability-patterns
Implement Salesforce reliability patterns including circuit breakers, idempotent upserts, and fallback caching. Use when building fault-tolerant Salesforce integrations, implementing retry strategies, or adding resilience to production Salesforce services. Trigger with phrases like "salesforce reliability", "salesforce circuit breaker", "salesforce idempotent", "salesforce resilience", "salesforce fallback", "salesforce retry".
salesforce-reference-architecture
Implement Salesforce integration reference architecture with jsforce, SFDX, and event-driven patterns. Use when designing new Salesforce integrations, reviewing project structure, or establishing architecture standards for Salesforce-connected applications. Trigger with phrases like "salesforce architecture", "salesforce project structure", "salesforce integration design", "how to organize salesforce code", "salesforce layout".