[FEATURE] Add LSP diagnostics support to the LSP tool

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Dec 24, 2025 · closed Feb 4, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

The current LSP tool provides code navigation capabilities (goToDefinition, findReferences, hover, documentSymbol, workspaceSymbol, goToImplementation, call hierarchy) but is missing diagnostics support.

To detect type errors, Claude Code must run the full compiler (tsc, bun run typecheck, etc.). For large TypeScript codebases, this is prohibitively slow—often 10-60+ seconds per invocation. This creates a poor feedback loop when making iterative changes.

The LSP language server is already running to power navigation features. It maintains an in-memory representation of the project's type graph and can provide diagnostics incrementally in milliseconds. We're just not tapping into this capability.

Proposed Solution

Add LSP diagnostics operations:

// File-level diagnostics
LSP({
operation: "diagnostics",
filePath: "/path/to/file.ts",
line: 1, // required by current API but could be ignored
character: 1 // required by current API but could be ignored
})
// Returns: Array of { line, character, severity, message, code, source }

// Optionally, workspace-wide diagnostics
LSP({
operation: "workspaceDiagnostics",
filePath: ".", // workspace root
line: 1,
character: 1
})

This would leverage textDocument/publishDiagnostics (push model) or textDocument/diagnostic (pull model, LSP 3.17+) from the underlying language server.

Alternative Solutions

  1. Continue using tsc - Works but is slow for large projects and duplicates work the language server already does
  2. Use tsc --incremental - Faster on subsequent runs but still requires disk I/O for .tsbuildinfo and process spawning overhead, and again duplicates what LSP is already doing.

Priority

Medium - Would be very helpful

Feature Category

Performance and speed

Use Case Example

Workflow when editing a TypeScript file:

  1. Claude Code edits src/api/handler.ts
  2. Immediately calls LSP({ operation: "diagnostics", filePath: "src/api/handler.ts" })
  3. Gets back in ~100ms: [{ line: 42, message: "Property 'foo' does not exist on type 'Bar'" }]
  4. Fixes the error and re-checks incrementally
  5. Proceeds only when diagnostics are clean

Without this feature, step 2 requires running tsc --noEmit which takes 30+ seconds on a large codebase, making rapid iteration impractical.

Additional Context

  • The navigation LSP features already work well—this is an incremental addition using the same infrastructure
  • Diagnostics are a core LSP capability supported by all major language servers (TypeScript, Rust Analyzer, gopls, Pyright, etc.)
  • This would benefit any typed language workflow, not just TypeScript
  • The language server's incremental update model means only changed files and their dependents are re-checked

View original on GitHub ↗

4 Comments

bennypowers · 7 months ago

For some additional context on why this feature is more than just a "nice to have":

gopls provides diagnostics with fixes to refactor common patterns to more idiomatic or more performant equivalents. These are not picked up by go vet or by the compiler, but do produce LSP squigglies.

For example, claude code regularly produces interface{} types, which gopls notes can and should be refactored to any. go vet won't pick those up, so squigglies will remain in the editor.

It would therefore be ideal for claude code to read these diagnostics and automatically apply code actions like these, even if only when requested specifically in CLAUDE.md

hughescr · 7 months ago

I think it's actually possible this exists silently and undocumented. My agent started complaining about typescript errors that I didn't tell it about as though it had diagnostic output - but it was bogus errors that weren't there in reality so I think the diagnostics are maybe running but ignoring tsconfig or something maybe? Or otherwise only partially working. But the whole operation is hidden so hard to know what exactly it's doing.

k-kohey · 6 months ago

I’d like to voice my support for this issue. This is particularly important for mobile development, where long compilation times make a fast feedback loop difficult

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.