• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdevelopment

platform-lsp-integrate

プラグイン
salesforce-development
ソース
GitHub で見る ↗
説明

Salesforce LSP(言語サーバープロトコル — プログラムコード補助機能)のMCPツールの呼び出し方法と、これらが使えない場合の対応方法を説明します。 **次のような場合に使用:** - Salesforce LSPの使い方について質問されたとき - どのLSP/MCPツールが存在するかを聞かれたとき - apex.diagnostics / validate_soql / complete_soql の機能について説明する必要があるとき - lsp_disabled、no_apex_workspace、no_org_connected などのエラーが返された理由を聞かれたとき - LSPホスト(中核となるサービス)のデバッグ方法を聞かれたとき - LSPをオフにする方法を聞かれたとき - 他のスキルがLSPツールを呼ぶときに従うべき契約(どのツールを優先するか、結果の読み方、LSPホストがない場合の代替手段)について説明するとき **使用しないでください:** - Apex/LWC/メタデータ(設定情報)の生成や編集が目的の場合(platform-apex-generate を使用) - デプロイ(環境への反映)の実行が目的の場合(platform-metadata-deploy を使用) - SOQLクエリ(データベース問い合わせ)の作成が目的の場合(platform-soql-query を使用) このスキルはリファレンス資料(仕様書)です。LSP層そのものまたはそのMCPツールについての質問に限定して使用してください。

原文を表示

Reference for how to call the Salesforce LSP MCP tools and what to do when they are unavailable. Use when the user asks how to use the Salesforce LSP, which LSP/MCP tools exist, what apex.diagnostics / validate_soql / complete_soql do, why an LSP tool returned an error like lsp_disabled or no_apex_workspace or no_org_connected, how to debug the LSP host, or how to turn the LSP off. Also the contract other skills follow when they call an LSP tool: which tool to prefer, how to read its result, and the fallback when the LSP host is absent. DO NOT TRIGGER for generating or editing Apex/LWC/metadata (use platform-apex-generate), running deploys (use platform-metadata-deploy), or SOQL authoring (use platform-soql-query); this skill is a reference and contract document — use it only when the question is specifically about the LSP layer or its MCP tools.

ユースケース
  • Salesforce LSPの使い方について質問されるとき
  • LSP/MCPツールの存在確認を聞かれるとき
  • LSP機能の説明が必要なとき
  • LSPエラーの原因を聞かれるとき
  • LSPホストのデバッグ方法を聞かれるとき
  • LSPをオフにする方法を聞かれるとき
本文(日本語訳)

Salesforce LSP の使用方法

salesforce-development プラグインは、salesforce-lsp という名前のローカル MCP サーバーをホストしており、Salesforce Language Server(言語解析サーバー)の子プロセスを必要に応じて起動し、その解析機能を MCP ツールとして公開しています。このスキルは、他のスキルがこれらのツールを呼び出す際に従う仕様書の役割を果たすもので、「Salesforce LSP をどう使うのか」という問いへの答えです — 各ツールが何をするか、結果の読み方、すべてのエラーコードの意味、ホストがない場合の代替手段まで説明します。

このスキルはドキュメント・リファレンス専門です。コード作成やデプロイは行わず、LSP ツールを正しく使う方法を説明します。

このプラグインビルドは Apex と SOQL のみに対応しています。 salesforce-lsp ホストは Apex 言語サーバー(@salesforce/apex-ls)と SOQL 言語サーバーを含んでいます。LWC(Lightning Web Components・ウェブコンポーネント)言語サーバーは意図的にこのプラグインに含まれていません — lwc.* ツールはホストに登録されていますが、ここでは常に unavailable(利用不可)の応答を返します。lwc.* ツールの呼び出しはすべて利用不可として扱い、代替手段(コンポーネントソースの直接参照/デプロイ時のコンパイル)を使用してください。

このスキルの使い時

  • ユーザーが Salesforce LSP の使い方、またはどのような LSP/MCP ツールが利用可能かを尋ねた場合。
  • ユーザーが特定のツール(apex.diagnostics、validate_soql、complete_soql など)の動作や出力の読み方を尋ねた場合。
  • LSP ツールがエラー応答(lsp_disabled、spawn_timeout、circuit_open、no_apex_workspace、no_org_connected)を返し、その意味と解決方法を知る必要がある場合。
  • LSP ツールを呼び出す別のスキルを作成・レビューしており、標準的な呼び出し/代替パターンを参照する必要がある場合。
  • LSP に問題が発生しているようでデバッグが必要な場合(lsp.health、${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor、停止スイッチ)。

ツール一覧

すべてのツールは MCP サーバー salesforce-lsp で提供されます(呼び出し名はプラグイン接頭辞パターンに従います: mcp__plugin_salesforce-development_salesforce-lsp__<tool_name> — ツール名のドット(.)はアンダースコア(_)に置き換わります。例えば apex.diagnostics は mcp__plugin_salesforce-development_salesforce-lsp__apex_diagnostics になります)。起動は遅延的です。言語サーバーを必要とするツールは初回呼び出し時にそのサーバーを起動し(Apex の場合は数秒の初期起動時間)、その後は再利用します。純粋な静的解析ツールは何も起動しません。

Apex(Apex LSP を起動)

ツール 目的 主な入力 主な出力
apex.diagnostics .cls/.trigger ファイルのコンパイルチェック。エラー・警告を表示 { filePath } { ok, diagnostics: [{ line, column, severity, message }] }
apex.hover カーソル位置の型・シグネチャを表示 { filePath, line, character } ホバーテキスト(Markdown形式)
apex.documentSymbol ファイル内のシンボル(関数、クラスなど)の構造を表示 { filePath } シンボルツリー
apex.completion カーソル位置でのコード補完候補を提示 { filePath, line, character } 補完アイテム

SOQL

ツール 目的 起動する? 主な出力
validate_soql SOQL 文字列の構文エラーをチェック SOQL LSP { ok, diagnostics: [{ line, column, severity, message }] }
complete_soql スキーマ対応の補完(カーソル位置のオブジェクト・フィールド・ピックリスト値を組織に基づいて解決) SOQL LSP { ok, items, expanded, unresolved, hint? }
extract_soql_from_apex Apex 内のすべてのインライン [SELECT …] を静的に抽出 いいえ(純粋な静的解析) { ok, totalQueries, totalDynamic, files }
check_soql_selectivity 選択性ヒューリスティクス(オプションで組織の LIMIT-0 プローブを実行) デフォルトではいいえ 選択性レポート
refresh_org_schema キャッシュされた組織スキーマを無効化し、補完が再取得されるようにする いいえ { ok, removed }

フィールド・オブジェクトをデプロイしたのに解決されない? SOQL または Apex で新たにデプロイされたフィールドへの参照が失敗した場合(例:No such column 'Foo__c'、または complete_soql が候補に表示しない)は、デプロイ直後でキャッシュされた組織スキーマが古い可能性があります — refresh_org_schema を呼び出してキャッシュを無効化し、コード エラーだと判定したり名前変更をする前に再度チェックを実行してください。これはデプロイ後のスキーマ遅延に対応するためのツールです。失敗をクエリ/クラスのバグだと判断する前にこのツールを使ってください。(ローカルキャッシュのみをクリアします。サーバー側の伝播速度は上げられないため、組織自体がフィールドの公開を終えていない場合は、しばらく待ってからの再実行が代替手段です。)

LWC — このビルドでは利用不可

lwc.* ツール(lwc.diagnostics、lwc.hover、lwc.definition、lwc.completion、lwc.workspace_symbols)はホストに登録されていますが、LWC 言語サーバーはこのプラグインに含まれていません。すべての lwc.* 呼び出しは利用不可応答を返します。LWC 作業は、コンポーネントソーステンプレートを直接読むか、デプロイ時のコンパイルと CLI エラーの確認で対応してください。

診断・ヘルスチェック

ツール 目的 起動する?
lsp.health 停止スイッチ状態、ワークスペース、サーバー別状態、サーキットブレーカー状態、初期起動タイミング、apex-ls バージョンを表示(読み取り専用) いいえ — 起動しない

座標はすべて1始まりです(line/column)。validate_soql の診断座標はファイルではなくクエリ文字列に相対的です。クエリが extract_soql_from_apex から来た場合、そのクエリの範囲を使って戻して変換してください。

呼び出し・代替手段の仕様

LSP ツールを呼び出すすべてのスキルは、同じ 3 つのルールに従います:

  1. 推測より LSP ツールを優先する。 対応するツール(クエリ検証、クラスコンパイルチェック、組織スキーマ補完など)が存在する場合、代替手段に頼る前にそれを呼び出してください。
  2. エラー応答を「利用不可」として扱う。合格ではなく。 ツールは結果の代わりに { error: <code> } を返すことがあります(エラーコード参照)。そのようなコードが返された場合、レポートに <tool>=unavailable: <code> と記録し、代替パスを続行してください — チェックが実行されなかったという理由で入力を有効・正常だと報告しないでください。
  3. 失敗ではなく、機能低下に対応する。 LSP はアクセラレーター(高速化ツール)であり、必須依存ではありません。ホスト自体が利用不可の場合、上記の MCP ツールは登録されないため、(例えば)validate_soql への呼び出しは解決されません。これはエラー応答と同じ方法で検出し — ツールは利用不可 — ドキュメント化された代替手段を使用してください:
LSP ツール利用不可 代替手段
apex.diagnostics sf project deploy でデプロイ・コンパイルし、CLI エラーを読む
validate_soql sf data query --json で読み取り専用でクエリを実行し、簡易チェック(構文エラーは CLI エラーに表示される)
complete_soql sf sobject describe --sobject <O> --json でフィールド一覧を取得。ユーザーが指定した名前から作成
extract_soql_from_apex ファイルを読んで [SELECT … ] を手動で探す
apex.completion / apex.hover ソースを直接読む
lwc.*(ここでは常に利用不可) コンポーネントソース・テンプレートを直接読むか、デプロイコンパイルして CLI エラーを読む

エラーコード

ツールは結果の代わりに { error: <code> } を返します(または complete_soql の場合は hint)。各コードと復旧方法は以下の通り:

コード 意味 対応方法
lsp_disabled 停止スイッチ(SFDX_LSP)がこの言語を禁止している LSP 非対応の代替手段を使用するか、LSP を再度有効にしてください(デバッグ参照)
spawn_timeout 言語サーバーが時間内に起動しなかった 1 回再試行。継続する場合は代替手段にフォールバックして ${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor を実行
circuit_open 連続する起動失敗がサーキットブレーカーをトリップした。呼び出しは遮断されている 今すぐ代替手段にフォールバック。lsp.health / ${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor で調査
no_apex_workspace パッケージディレクトリ下に classes/*.cls がない — Apex ツールは起動しない 非 Apex プロジェクトでは想定通り。チェック対象はなし
no_org_connected (complete_soql ヒント)組織スキーマを解決できなかった キーワード補完は動作します。正確なフィールド・オブジェクト名を質問するか、組織を接続してください。__…_PLACEHOLDER ラベルを実フィールドとして表示しないでください

最初の 3 つはすべての起動ツールで共有される一時的・設定状態です。残りは特定のワークスペース/組織/ファイル文脈での想定動作 — インストール破損の兆候ではありません。(no_lwc_bundles / unsupported_lwc_file は LWC 専用コードです。このビルドでは LWC サーバーは含まれていないため、lwc.* は理由に関わらず利用不可を返します。)

LSP のデバッグ

3 層あります。最も軽量なものから:

  1. lsp.health(MCP ツール)。 最速のチェック — 子プロセスを起動しません。停止スイッチ状態、解決されたワークスペース、サーバー別状態、サーキットブレーカー状態、最後の初期起動タイミング、含まれている apex-ls バージョンをレポートします。Claude に「lsp.health を実行して」と言うか、lsp.health ツールを直接呼び出してください。

  2. bin/lsp-doctor(CLI)。 より詳しいインストールレベルの診断。サポートとオンボーディング(利用開始支援)用です。コミットされたバンドルが存在すること、含まれている apex-ls アーティファクトが解決できること、組織スキーマキャッシュが解析可能であること、各 LSP 子プロセスが実際に起動できることを確認します。健全な場合は終了コード 0、問題がある場合は終了コード 1 と構造化された項目別出力で終了します。

    "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-
原文(English)を表示

Using the Salesforce LSP

The salesforce-development plugin hosts a local MCP server named salesforce-lsp that lazily spawns Salesforce Language Server children and exposes their semantic capabilities as MCP tools. This skill is the contract other skills follow when they call those tools, and the answer to "how do I use the Salesforce LSP?" — what each tool does, how to read its result, what every error code means, and how to fall back when the host is absent.

This is a documentation/reference skill. It does not author or deploy code; it tells you (and other skills) how to drive the LSP tools correctly.

This plugin build vendors Apex + SOQL only. The salesforce-lsp host ships the Apex language server (@salesforce/apex-ls) and the SOQL language server. The LWC language server is intentionally not bundled in this plugin — the lwc.* tools are registered by the host but will always return an unavailable-class envelope here. Treat any lwc.* call as unavailable and use the fallback (read the component source / deploy-compile).

When to Use This Skill

  • A user asks how to use the Salesforce LSP, or which LSP/MCP tools are available.
  • A user asks what a specific tool does (apex.diagnostics, validate_soql, complete_soql, etc.) or how to read its output.
  • An LSP tool returned an error envelope (lsp_disabled, spawn_timeout, circuit_open, no_apex_workspace, no_org_connected) and you need to know what it means and how to recover.
  • You're authoring or reviewing another skill that calls an LSP tool and need the canonical call/fallback pattern.
  • The LSP seems broken and you need to debug it (lsp.health, ${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor, the kill switch).

The Tools

All tools are served by the MCP server salesforce-lsp (invoke names follow the plugin-prefixed pattern: mcp__plugin_salesforce-development_salesforce-lsp__<tool_name>, where dots in tool names become underscores — e.g. apex.diagnostics becomes mcp__plugin_salesforce-development_salesforce-lsp__apex_diagnostics). Spawning is lazy: a tool that needs a language server brings the child up on first call (a one-time cold start of a few seconds for Apex), then reuses it. The pure static-analysis tools never spawn anything.

Apex (spawns the Apex LSP)

Tool Purpose Key input Key output
apex.diagnostics Compile-check a .cls/.trigger; surface errors/warnings { filePath } { ok, diagnostics: [{ line, column, severity, message }] }
apex.hover Type/signature at a position { filePath, line, character } hover markdown
apex.documentSymbol Outline of a file's symbols { filePath } symbol tree
apex.completion Code-completion at a position { filePath, line, character } completion items

SOQL

Tool Purpose Spawns? Key output
validate_soql Parse a SOQL string for syntax errors SOQL LSP { ok, diagnostics: [{ line, column, severity, message }] }
complete_soql Schema-aware completion at a cursor (SObjects, fields, picklist values resolved against the org) SOQL LSP { ok, items, expanded, unresolved, hint? }
extract_soql_from_apex Statically pull every inline [SELECT …] out of Apex No (pure static) { ok, totalQueries, totalDynamic, files }
check_soql_selectivity Selectivity heuristics (optional org LIMIT-0 probe) No by default selectivity report
refresh_org_schema Invalidate the cached org describe so completion re-fetches No { ok, removed }

Just deployed a field/object and it won't resolve? When a SOQL or Apex reference to a freshly-deployed field fails (e.g. No such column 'Foo__c', or complete_soql doesn't offer it) right after a deploy, the cached org describe is stale — call refresh_org_schema to invalidate it, then re-run the check before assuming a code error or renaming anything. This is the lever for post-deploy schema lag; reach for it before treating the failure as a bug in your query/class. (It only clears the local cache; it can't speed up server-side propagation, so if the org itself hasn't finished publishing the field, re-running after a moment is the fallback.)

LWC — not available in this build

The lwc.* tools (lwc.diagnostics, lwc.hover, lwc.definition, lwc.completion, lwc.workspace_symbols) are registered by the host but the LWC language server is not vendored in this plugin. Every lwc.* call returns an unavailable envelope. For LWC work, fall back to reading the component source/templates directly or deploy-compiling and reading the CLI errors.

Diagnostics / health

Tool Purpose Spawns?
lsp.health Read-only view of kill-switch mode, workspace, per-server state, circuit-breaker state, cold-spawn timing, apex-ls version No — never spawns

Coordinates everywhere are one-based (line/column). validate_soql diagnostic coordinates are relative to the query string, not a file — when a query came from extract_soql_from_apex, translate back using that query's range.

The Call / Fallback Contract

Every skill that calls an LSP tool follows the same three rules:

  1. Prefer the LSP tool over guessing. If a tool exists for the step (validate a query, compile-check a class, complete against the org schema), call it before falling back to hand-analysis.
  2. Treat an error envelope as "unavailable," never as "passed." A tool may return { error: <code> } instead of a result (see Error Codes). On any such code, record <tool>=unavailable: <code> in your report and continue down the fallback path — never report the input as valid/clean just because the check didn't run.
  3. Degrade, don't fail. The LSP is an accelerator, not a hard dependency. If the host isn't available at all, the salesforce-lsp tools simply won't exist — fall back to the CLI/manual path for that step and say so.

When the LSP host is absent

If the plugin/host isn't available, the MCP tools above are not registered, so a call to (e.g.) validate_soql will not resolve. Detect this the same way you detect an error envelope — the tool is unavailable — and use the documented fallback:

LSP tool unavailable Fallback
apex.diagnostics Deploy/compile via sf project deploy and read CLI errors
validate_soql Smoke-check by running the query read-only via sf data query --json (a parse error surfaces in the CLI error)
complete_soql sf sobject describe --sobject <O> --json for fields; author from the user's stated names
extract_soql_from_apex Read the file(s) and locate [SELECT … ] by hand
apex.completion / apex.hover Read the source directly
lwc.* (always unavailable here) Read the component source/templates directly, or deploy-compile and read CLI errors

Error Codes

A tool returns { error: <code> } (or, for complete_soql, a hint) instead of a result. Each maps to a recovery:

Code Meaning What to do
lsp_disabled The kill switch (SFDX_LSP) forbids this language Use the non-LSP fallback; or re-enable the LSP (see Debugging)
spawn_timeout The language server didn't come up in time Retry once; if it persists, fall back and run ${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor
circuit_open Repeated spawn failures tripped the breaker; calls are short-circuited Fall back now; investigate with lsp.health / ${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor
no_apex_workspace No classes/*.cls under any package dir — Apex tools won't spawn Expected in a non-Apex project; nothing to check
no_org_connected (complete_soql hint) org schema couldn't be resolved Keyword completion still works; ask for exact field/object names or connect an org. Do not surface __…_PLACEHOLDER labels as real fields

The first three are transient/config states shared by every spawning tool; the rest are expected, healthy states for a particular workspace/org/file context — not signs of a broken install. (no_lwc_bundles / unsupported_lwc_file are LWC-only codes; in this build the LWC server is not vendored, so lwc.* returns unavailable regardless.)

Debugging the LSP

Three layers, cheapest first:

  1. lsp.health (MCP tool). The fastest check — never spawns a child. Reports the kill-switch mode, resolved workspace, per-server status, circuit-breaker state, last cold-spawn timing, and the vendored apex-ls version. Ask Claude to "run lsp.health," or call the lsp.health tool directly.

  2. bin/lsp-doctor (CLI). A deeper, install-level diagnostic for support and onboarding. Verifies the committed bundles exist, the vendored apex-ls artifacts resolve, the org-schema cache is parseable, and each LSP child can actually spawn. Exits 0 when healthy, 1 with structured per-check output when something is wrong.

    "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor            # human-readable report
    "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --json     # machine-readable
    "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --no-spawn # skip child-spawn probes (CI/restricted)
    

    (In this build lsp-doctor will report the LWC server as missing — that is expected; only Apex + SOQL are vendored here.)

  3. SFDX_LSP_DEBUG=1. Emits single-line JSON telemetry (spawn timing, cache hits, circuit events, per-tool latency) to stderr. Off by default (zero overhead).

The kill switch — SFDX_LSP

The fast way to control or disable the LSP. Set the environment variable:

SFDX_LSP Effect
unset / all Every vendored LSP may spawn (default)
apex-only Only the Apex LSP may spawn; SOQL tools return lsp_disabled
disabled No LSP spawns; every LSP tool returns lsp_disabled

To rule the LSP in or out of a problem, set SFDX_LSP=disabled and re-run: if the issue persists it isn't the LSP, and skills will have fallen back to their non-LSP paths automatically. An unknown value defaults to all (with a warning) so a typo never silently disables the feature.

Pre-deploy diagnostics gate

A PreToolUse hook (bin/lsp-precheck) runs Apex diagnostics on the .cls/.trigger files a sf project deploy start/validate is about to push, and emits a decision. It is fail-open: any error (including a missing/slow LSP) allows the deploy. Mode is controlled by SFDX_LSP_DEPLOY_GATE (off | warn | block, default warn) — warn surfaces diagnostics without blocking; block denies a deploy that has Apex compile errors.

Verification

  • Asked "how do I use the Salesforce LSP tools?", this skill is the match and lists the tools, their inputs/outputs, and the fallback contract.
  • Appears in the /skills listing as platform-lsp-integrate.
  • Given an error code (e.g. no_apex_workspace), it explains the meaning and the correct recovery without treating the unrun check as a pass.

Cross-Skill Integration

Need Delegate to
Compile-check + analyze Apex you just wrote platform-apex-generate
Validate inline SOQL in .cls/.trigger validate_soql (this skill); fallback: run read-only via sf data query --json
Author & run a SOQL query against the org complete_soql + sf data query
Pre-deploy diagnostics gate behavior see "Pre-deploy diagnostics gate" above

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。