debug-log

debug-log is a command for coding agents from bhanu91221/sfdx-iq. It costs 6 tokens per session (723 once invoked), scanned A, original, MIT.

A command for retrieving and analyzing Salesforce debug logs, which record what code and automation did inside a Salesforce organization. It can set up a trace flag, fetch recent logs, and inspect queries, database writes, limits, callouts, exceptions, and flows.

In plain words
What is it for?
Use it to investigate Apex, Flow, database, HTTP-callout, CPU, heap, and governor-limit problems in a Salesforce org.
Why use it?
It helps locate the cause of Salesforce errors and slow or limit-heavy executions in detailed runtime records. It also highlights Salesforce governor limits, which restrict resource use per request.

Command

Part of the sfdx-iq plugin — 20 commands, 7 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/bhanu91221/sfdx-iq/debug-log
Clone the repo
git clone --depth 1 https://github.com/bhanu91221/sfdx-iq

Or install sfdx-iq, the plugin that ships this one along with the rest of its 20 commands, 7 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for debug-log

README.md
[![agentmods](https://agentmods.dev/badge/commands/bhanu91221/sfdx-iq/debug-log.svg)](https://agentmods.dev/commands/bhanu91221/sfdx-iq/debug-log)
Your own site
<a href="https://agentmods.dev/commands/bhanu91221/sfdx-iq/debug-log"><img src="https://agentmods.dev/badge/commands/bhanu91221/sfdx-iq/debug-log.svg" alt="Measured on agentmods" height="20"></a>
Per session 6 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 723 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00006 $0.00723
Opus 5 $0.00003 $0.00362
Sonnet 5 $0.00001 $0.00145
Haiku 4.5 $0.00001 $0.00072

Measured 3d ago against content hash 7ea4e1d1e9bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

debug-log scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/debug-log.md · 89 lines

How it starts

The opening of the file, as written. The whole thing — 89 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/debug-log

Retrieve debug logs from a Salesforce org, parse them for issues, and provide actionable analysis.

Workflow

  1. Set up trace flag (if not active)

    • Check for active trace flags on the running user:
      sf data query --query "SELECT Id, ExpirationDate, DebugLevelId FROM TraceFlag WHERE TracedEntityId = '<userId>' AND ExpirationDate > NOW()" --target-org <org>
      
    • If no active trace flag, create one:
      sf apex tail log --target-org <org>
      
  2. Retrieve logs

    • Get the most recent log:
      sf apex get log --number 1 --target-org <org>
      
    • Or list available logs and let user choose:
      sf apex list log --target-org <org>
      
  3. Parse the debug log Analyze the log for key sections:

    Section What to Look For
    SOQL queries Count, timing, selectivity warnings
    DML operations Count, records affected, errors
    CPU time Total usage vs limit
    Heap allocation Peak usage vs limit
    Callouts HTTP status, response time, timeouts
    Exceptions Stack traces, error messages
    Flow interviews Flow execution path, element timing
  4. Governor limit summary Extract limits from the LIMIT_USAGE_FOR_NS section:

    Governor Limit Usage:
      SOQL Queries:    23/100 (23%)
      DML Statements:  8/150 (5%)
      CPU Time:        3,450/10,000 ms (35%)
      Heap Size:       1.2/6 MB (20%)
      Callouts:        2/100 (2%)
    
  5. Identify issues

    • Flag any limit >70% usage as ⚠️ WARNING
    • Flag any limit >90% as 🔴 CRITICAL
    • Identify SOQL queries that appear in loops (check query count vs unique queries)
    • Highlight slow queries (>100ms)
    • Flag unhandled exceptions
  6. Recommendations Based on analysis, suggest:

    • Queries to optimize (slow or redundant)
    • DML to consolidate
    • Code paths to move to async
    • Delegate to apex-code-reviewer agent if limits are concerning

Read the full file on GitHub · 89 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 89 lines · 6 tokens per session scan A 7ea4e1d1e9bc

Subscribe to this mod's changes

debug-log is a command published in the GitHub repository bhanu91221/sfdx-iq (2 stars, last pushed 3mo ago), licensed MIT. It adds 6 tokens to every session and 723 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.