[FEATURE] Add LSP diagnostics support to the LSP tool

Resolved 💬 4 comments Opened Dec 24, 2025 by hughescr 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 ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗