/salesforce-development:platform-lsp-integratefrom Salesforce Development
Reference for Salesforce LSP MCP tools and error handling. Explains apex.diagnostics, validate_soql, complete_soql, and unavailability codes like lsp_disabled or no_org_connected.
Ships in Salesforce Development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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.
Plugin required. This skill runs commands that ship with its plugin, and a standalone npx skills add install doesn't include them. If one of those commands isn't found, or CLAUDE_PLUGIN_ROOT is empty, tell the user this skill needs its plugin installed. Don't improvise a replacement for the command. Where a step says what to do when its command fails, do that.
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-lsphost ships the Apex language server (@salesforce/apex-ls) and the SOQL language server. The LWC language server is intentionally not bundled in this plugin — thelwc.*tools are registered by the host but will always return anunavailable-class envelope here. Treat anylwc.*call as unavailable and use the fallback (read the component source / deploy-compile).
apex.diagnostics, validate_soql,
complete_soql, etc.) or how to read its output.lsp_disabled, spawn_timeout,
circuit_open, no_apex_workspace, no_org_connected) and you need to know
what it means and how to recover.lsp.health,
${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor, the kill switch).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.
| 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 |
| 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', orcomplete_soqldoesn't offer it) right after a deploy, the cached org describe is stale — callrefresh_org_schemato 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.)
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.
| 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.
Every skill that calls an LSP tool follows the same three rules:
{ 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.salesforce-lsp tools simply won't
exist — fall back to the CLI/manual path for that step and say so.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 |
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.)
Three layers, cheapest first:
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.
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.)
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).
SFDX_LSPThe 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.
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.
/skills listing as platform-lsp-integrate.no_apex_workspace), it explains the meaning and the
correct recovery without treating the unrun check as a pass.| 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 |
What SKILL.md sets; muted values are Claude Code's defaults
38 skills in this plugin
/automation-flow-generateGenerate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as "when a record is created", "trigger daily at", "send an email when", "update the field when", "automate", "workflow", or "flow XML/metadata". This is the only skill for Salesforce Flow generation./dx-org-manageUse to EXECUTE Salesforce org operations immediately via the sf CLI (this skill runs them, it does NOT generate scripts): create scratch orgs (from edition, definition file, snapshot, or org shape), list/display/resume/delete scratch orgs, open orgs in browser. Trigger: 'create scratch org', 'create org from snapshot', 'delete scratch org', 'open my org'. Do NOT use for switching the default org (use dx-org-switch), deploying metadata (use platform-metadata-deploy), or creating/checking/listing/deleting org snapshots (use dx-org-snapshot-manage)./dx-project-createScaffold a Salesforce DX project from any template (standard, agent, analytics, React/Angular/Vue app), move the session in, connect an org, enable source tracking. Use to create a Salesforce/SFDX project. DO NOT TRIGGER for: existing UI-bundle apps (experience-ui-bundle-frontend-generate); UI-bundle scaffold in a larger build (experience-ui-bundle-project-generate, experience-ui-bundle-app-coordinate); tool checks (platform-environment-validate); org login (login); scratch orgs (dx-org-manage)./platform-apex-anonymous-runRuns anonymous Apex against the connected org (.apex file or pasted snippet), capturing the debug log, surfacing errors. Triggers on "run this anonymous apex", "execute this script against my org", "what does this code return", or "execute scripts/foo.apex". Wraps scripts in savepoint+rollback; warns before running in production. DO NOT TRIGGER for authoring .cls/.trigger files (platform-apex-generate), Apex unit tests (platform-apex-test-run), or debug-log analysis (platform-apex-logs-debug)./platform-apex-generatePrimary Apex authoring skill for class generation, refactoring, and review. ALWAYS ACTIVATE when the user mentions Apex, .cls, triggers, or asks to create/refactor a class (service, selector, domain, batch, queueable, schedulable, invocable, DTO, utility, interface, abstract, exception, REST resource). Use this skill for requests involving SObject CRUD, mapping collections, fetching related records, scheduled jobs, batch jobs, trigger design, @AuraEnabled controllers, @RestResource endpoints, custom REST APIs, or code review of existing Apex./platform-apex-logs-debugSalesforce 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).npx claudepluginhub forcedotcom/sf-skills --plugin salesforce-developmentOther plugins' skills for the same job