agentleFS
plumbkitplumbkit/plumb/.claude/skills/add-lsp-adapter/SKILL.md

add-lsp-adapter

Skill4 starsChanged 4 months agoMITView on GitHub

Add or validate a language-server adapter in plumb — the base.Adapter shape, the promotion hazard, the conformance and error-contract harnesses, and the experimental-to-validated promotion rule. Use when adding a language or debugging an adapter's diagnostics round-trip.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create internal/lsp/adapters/<name>/ with a doc.go stating the adapter's validation status (Experimental or Validated — see the promotion …

    line 14
  2. Very specific:

    Write adapter.go: type Adapter struct{ *base.Adapter }, var _ lsp.Client = (*Adapter)(nil), func New(conn jsonrpc.Caller) *Adapter { return …

    line 16
  3. Very specific:

    Test: unit tests with internal/lsp/jsonrpc/mock.go covering what this adapter adds (not the inherited base).

    line 34

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Adding an LSP adapter to plumb

An adapter embeds *base.Adapter (internal/lsp/adapters/base), which supplies all 23 lsp.Client methods, and shadows only what its server does differently. rust is the minimal worked example (46 lines); full guide in docs/adding-an-lsp.md.

The 5 steps

  1. Create internal/lsp/adapters/<name>/ with a doc.go stating the adapter's validation status (Experimental or Validated — see the promotion rule below).
  2. Write adapter.go: type Adapter struct{ *base.Adapter }, var _ lsp.Client = (*Adapter)(nil), func New(conn jsonrpc.Caller) *Adapter { return &Adapter{Adapter: base.New(conn, "<binary-name>")} }, and DefaultInitParams — the one genuinely per-server function. Do NOT hand-write the 23 methods.
  3. Shadow only the methods your server does differently, calling through with a.Adapter.X(ctx, params). Escape hatches are package-level FUNCTIONS — base.Call[T], base.CallPtr[T], base.CallRaw, base.Notify, base.Wrap. Never add an exported method to base.Adapter: Go promotes it into all nine adapters and internal/cli resolves optional capabilities structurally, so one stray method silently opts every server into a capability it does not have. An adapter-only capability (e.g. pull diagnostics) is declared in the adapter's own package.
  4. base.New installs BOTH transport handlers (notification fan-out + server-request handler); dispatch and handleServerRequest are unexported, so there is nothing to register and nothing to forget. Server-specific work left to you: init options, workspace model, and — for a server that answers only for open documents — a base.OpenTracker held as a NAMED field (never embedded) with an Ensure call in each affected method and a Refresh in DidChangeWatchedFiles. The set of methods needing it differs per server; do not copy another adapter's.
  5. Test: unit tests with internal/lsp/jsonrpc/mock.go covering what this adapter adds (not the inherited base); conformance.RunConformance for the protocol contract; and conformance.RunErrorContract for the "<server> <label>: <cause>" strings. Lazy-open adapters also call conformance.RunLazyOpenErrorContract.

The experimental → validated promotion rule

An adapter stays Experimental until the DidChangeWatchedFiles+DidOpen → publishDiagnostics round-trip runs green against a real server binary, in an integration test gated //go:build integration — mock-transport unit tests passing is not enough to promote. Update the adapter's doc.go and the validation table in docs/adding-an-lsp.md ("## Validation levels") when a real-binary retest goes green.

Recurring gotchas (from the adapter validation table)

  • Some servers resolve nothing for an unopened document. zls needs the file opened via didOpen before any per-document query (documentSymbol, definition, references, hover, hierarchy prepares) resolves. Fix: base.OpenTracker — open lazily on first query, close on a watched-file change. sourcekit-lsp, vscode-html-language-server and kotlin-lsp are the others — but the set of methods differs per server and must be MEASURED, not copied: kotlin-lsp needs it for documentSymbol alone and answers everything else unopened.
  • Some servers publish nothing unless the client advertises textDocument.publishDiagnostics. typescript-language-server does not implement pull diagnostics (textDocument/diagnostic returns -32601) — it silently produces no diagnostics at all if that client capability isn't declared in DefaultClientCapabilities(). If a new adapter's diagnostics round-trip test fails with no published diagnostics and no error, check this first before chasing a pull-diagnostics theory.
  • Some servers need a real project layout, not a bare temp workspace, to produce diagnostics at all (kotlin-lsp needs a resolvable Gradle/Maven project — a build that actually completes, not just the files) — a same-symptom failure with a different root cause from the two gotchas above.
  • And some genuinely do not push. kotlin-lsp sends zero publishDiagnostics however the client is configured, and answers textDocument/diagnostic in under a second. Rule them out in this order — client capability, then project realness, then pull — because all three present identically as "no diagnostics". A green PULL round-trip promotes an adapter exactly as a push one does.

Level-3 reference

Full step-by-step guide, including the promotion hazard and the three worked examples (rust / typescript / swift): docs/adding-an-lsp.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.