Salesforce(営業支援クラウド)のデバッグログ解析とトラブルシューティングを100点満点のスコアリング(評価)で提供します。 **次のような場合に使用:** - ユーザーがデバッグログを分析している - ガバナー制限(システムの実行制限)に達した - スタックトレース(エラー発生の経路情報)を読んでいる - Salesforce組織の .log ファイルを操作している **使用しない場合:** - Apex(プログラミング言語)テストを実行している場合 → platform-apex-test-run を使用 - Apex コードを生成・修正している場合 → platform-apex-generate を使用 - Agentforce(AI音声・チャット機能)のセッショントレース(実行履歴の追跡)を行っている場合 → agentforce-observe を使用
Salesforce debug log analysis and troubleshooting with 100-point scoring. TRIGGER when: user analyzes debug logs, hits governor limits, reads stack traces, or touches .log files from Salesforce orgs. DO NOT TRIGGER when: running Apex tests (use platform-apex-test-run), generating or fixing Apex code (use platform-apex-generate), or Agentforce session tracing (use agentforce-observe).
次のような場合に使用: ユーザーがデバッグログから根本原因を特定する必要がある場合。具体的には、ガバナンスリミット(Salesforceの処理制限)の診断、スタックトレース(エラーが発生した処理の流れ)の読み解き、遅いクエリの調査、メモリやCPU負荷の分析、またはログに基づく再現から修正までの一連の作業が該当します。
platform-apex-logs-debugを使用するのは以下の作業が含まれる場合です:
.logファイル以下の場合は別のスキルに委ねてください:
以下の内容を確認または推測してください:
references/cli-commands.md のコマンドを使って、対象の組織からログを一覧表示・ダウンロード・ストリーミング(リアルタイム取得)します。
以下を優先します:
詳細な進め方: references/analysis-playbook.md
| 問題 | 主な兆候 | 対策の方向性 |
|---|---|---|
| ループ内のSOQL | ループ処理の中で繰り返される SOQL_EXECUTE_BEGIN |
クエリを1回に、その結果をマップ・グループ化して使用 |
| ループ内のDML | 繰り返される DML_BEGIN パターン |
行データを集めて1回のDMLを実行 |
| 不適切なクエリ | スキャン行数が多い・選択性が低い | インデックス付きフィルタを追加、検索範囲を縮小 |
| CPU負荷 | CPU使用量が同期実行の上限に接近 | アルゴリズムの複雑さを削減、キャッシュ化、妥当な場合は非同期処理に |
| メモリ負荷 | メモリ使用量が同期実行の上限に接近 | SOQLのfor-loopでストリーミング処理、メモリ上のデータ量を削減 |
| ヌルポインタ・致命的エラー | EXCEPTION_THROWN / FATAL_ERROR |
ヌル値チェックの追加、空のクエリ結果の処理を修正 |
詳細な例: references/common-issues.md
分析完了時は、この順序で報告してください:
推奨される形式:
問題: <概要>
場所: <クラス / 行番号 / トランザクション段階>
根本原因: <説明>
深刻度: 危機的 | 警告 | 情報
修正: <具体的な対応>
検証: <テストまたは再実行のステップ>
| ルール | 理由 |
|---|---|
| 修正の推奨は常にログ証拠に基づく | 推測診断を避ける — 根本原因はログで追跡可能である必要がある |
| 発見した問題ごとに6つの出力項目すべてを報告する | 各問題について実行可能で完全な知見を確保する |
| すべての発見を「危機的」「警告」「情報」に分類する | ユーザーが対応の優先順位を決めやすくする |
コード生成はplatform-apex-generateに委ねる |
このスキルは診断専門——Apexコードの書き直しは行わない |
テスト実行はplatform-apex-test-runに委ねる |
このスキルはテストクラスの実行・修復を行わない |
LIMIT_USAGEイベントを読まずにリミットが安全と仮定しない |
リミットは失敗ポイント以前の操作で消費されている可能性がある |
| 落とし穴 | 対策 |
|---|---|
| ログが2MBで切られている | デバッグレベルを下げ(例:ApexCode: INFO、ApexProfiling: FINE)、再度キャプチャ |
| 同じ問題がSOQL問題とCPU問題の両方に見える | ループ内のSOQLを先に修正——通常これがCPU急増の二次的な原因 |
| トレースフラグ設定後、ログが表示されない | トレースフラグの有効期限(ExpirationDate)が未来の日付か、正しいユーザーがトレース対象か確認 |
| 非同期処理ではリミット値が変わる | CPU上限は非同期で60,000ミリ秒、同期で10,000ミリ秒——リミット判定の前にトランザクションタイプを確認 |
| スタックトレースがフレームワークの行を指す | ユーザーコードの発生源を見つけるため、トリガーハンドラを越えてコールスタックを遡る |
| 必要な作業 | 委ねるスキル | 理由 |
|---|---|---|
| Apex修正を実装する | platform-apex-generate | コード変更生成・レビュー |
| テストで再現する | platform-apex-test-run | テスト実行とカバレッジの確認ループ |
| 修正をデプロイする | platform-metadata-deploy | デプロイメント統制 |
| デバッグ用データを作成する | platform-data-manage | 再現用データの準備・供給 |
| ファイル | 読むべき場面 |
|---|---|
references/analysis-playbook.md |
まずここから——デバッグセッション全般の詳細な進め方 |
references/common-issues.md |
ループ内SOQL・ループ内DML・CPU/メモリ負荷・ヌルポインタパターンの辞書 |
references/cli-commands.md |
デバッグログの取得・ストリーミング・管理用のSF CLIコマンド |
references/debug-log-reference.md |
イベントタイプ完全カタログ、ログレベル、ガバナンスリミット参照値 |
references/log-analysis-tools.md |
Apex Log Analyzer・Developer Console・CLI grep パターンのガイド |
references/benchmarking-guide.md |
パフォーマンス計測の技法、ベンチマークデータ、アンチパターン |
references/scoring-rubric.md |
分析品質を評価するための100点スコアリング基準 |
assets/benchmarking-template.cls |
パフォーマンス計測用のApex無名実行テンプレート(コピペ可) |
assets/cpu-heap-optimization.cls |
CPU時間とメモリ割り当てを減らすApexパターン |
assets/dml-in-loop-fix.cls |
ループ内DML問題の修正ビフォー・アフター例 |
assets/soql-in-loop-fix.cls |
ループ内SOQL問題の修正ビフォー・アフター例 |
assets/null-pointer-fix.cls |
ヌルポインタ例外対策パターン |
| スコア | 意味 |
|---|---|
| 90以上 | 熟練した分析と優れた修正ガイダンス |
| 80〜89 | 良好な分析、軽微な漏れあり |
| 70〜79 | 許容範囲だが二次的な問題を見落とす可能性 |
| 60〜69 | 部分的な診断のみ |
| 60未満 | 不完全な分析 |
Use this skill when the user needs root-cause analysis from debug logs: governor-limit diagnosis, stack-trace interpretation, slow-query investigation, heap / CPU pressure analysis, or a reproduction-to-fix loop based on log evidence.
Use platform-apex-logs-debug when the work involves:
.log files from SalesforceDelegate elsewhere when the user is:
Ask for or infer:
Use the commands in references/cli-commands.md to list, download, or stream logs for the target org.
Prefer fixes that are:
Expanded workflow: references/analysis-playbook.md
| Issue | Primary signal | Default fix direction |
|---|---|---|
| SOQL in loop | repeating SOQL_EXECUTE_BEGIN in a repeated call path |
query once, use maps / grouped collections |
| DML in loop | repeated DML_BEGIN patterns |
collect rows, bulk DML once |
| Non-selective query | high rows scanned / poor selectivity | add indexed filters, reduce scope |
| CPU pressure | CPU usage approaching sync limit | reduce algorithmic complexity, cache, async where valid |
| Heap pressure | heap usage approaching sync limit | stream with SOQL for-loops, reduce in-memory data |
| Null pointer / fatal error | EXCEPTION_THROWN / FATAL_ERROR |
guard null assumptions, fix empty-query handling |
Expanded examples: references/common-issues.md
When finishing analysis, report in this order:
Suggested shape:
Issue: <summary>
Location: <class / line / transaction>
Root cause: <explanation>
Severity: Critical | Warning | Info
Fix: <specific action>
Verify: <test or rerun step>
| Rule | Rationale |
|---|---|
| Always base fix recommendations on log evidence | Avoid speculative diagnosis — root cause must be traceable in the log |
| Report all six output fields for every issue found | Ensures actionable, complete findings for each problem |
| Classify every finding as Critical, Warning, or Info | Helps the user prioritize which issues to address first |
Delegate code generation to platform-apex-generate |
This skill diagnoses; it does not rewrite Apex code |
Delegate test execution to platform-apex-test-run |
This skill does not run or repair test classes |
Never assume limits are safe without reading LIMIT_USAGE events |
Limits may be consumed by earlier operations not visible in the failure point |
| Pitfall | Resolution |
|---|---|
| Log truncated at 2 MB | Reduce debug levels (e.g., ApexCode: INFO, ApexProfiling: FINE) and re-capture |
| Same issue appears as both SOQL and CPU problem | Fix SOQL-in-loop first — it typically drives the CPU spike as a secondary effect |
| No logs appear after trace flag is set | Verify the trace flag ExpirationDate is in the future and the correct user is traced |
| Async context changes limit values | CPU limit is 60,000 ms async vs 10,000 ms sync — check transaction type before flagging limits |
| Stack trace points to framework line, not user code | Walk up the call stack past trigger handlers to find the originating user code |
| Need | Delegate to | Reason |
|---|---|---|
| Implement Apex fix | platform-apex-generate | code change generation / review |
| Reproduce via tests | platform-apex-test-run | test execution and coverage loop |
| Deploy fix | platform-metadata-deploy | deployment orchestration |
| Create debugging data | platform-data-manage | targeted seed / repro data |
| File | When to read |
|---|---|
references/analysis-playbook.md |
Start here — expanded step-by-step workflow for any debugging session |
references/common-issues.md |
Quick lookup for SOQL in loop, DML in loop, CPU/heap pressure, null pointer patterns |
references/cli-commands.md |
SF CLI commands for retrieving, streaming, and managing debug logs |
references/debug-log-reference.md |
Full event type catalog, log levels, and governor limit reference values |
references/log-analysis-tools.md |
Tool guide: Apex Log Analyzer, Developer Console, CLI grep patterns |
references/benchmarking-guide.md |
Performance benchmarking techniques, benchmark data, and anti-patterns |
references/scoring-rubric.md |
100-point scoring rubric for evaluating analysis quality |
assets/benchmarking-template.cls |
Copy-paste Anonymous Apex template for running performance benchmarks |
assets/cpu-heap-optimization.cls |
Apex patterns for reducing CPU time and heap allocation |
assets/dml-in-loop-fix.cls |
Before/after example for resolving DML-in-loop violations |
assets/soql-in-loop-fix.cls |
Before/after example for resolving SOQL-in-loop violations |
assets/null-pointer-fix.cls |
Patterns for guarding against null pointer exceptions |
| Score | Meaning |
|---|---|
| 90+ | Expert analysis with strong fix guidance |
| 80–89 | Good analysis with minor gaps |
| 70–79 | Acceptable but may miss secondary issues |
| 60–69 | Partial diagnosis only |
| < 60 | Incomplete analysis |
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。