# LSP Diagnostics

> TunaCode provides automatic LSP diagnostics feedback when files are written or updated.

- Skill: `tools-only/lsp-diagnostics` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/lsp-diagnostics`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/lsp-diagnostics/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/lsp-diagnostics

---


# LSP Diagnostics

TunaCode provides automatic LSP diagnostics feedback when files are written or updated.

## File Map

```
tools/
├── lsp/                          # LSP implementation (tools layer)
│   ├── __init__.py               # get_diagnostics(), format_diagnostics()
│   ├── client.py                 # LSPClient - JSON-RPC over stdio
│   └── servers.py                # Server command mapping by extension
├── write_file.py                 # Calls tools.lsp after writing
└── update_file.py                # Calls tools.lsp after updating
```

## How It Works

When `write_file` or `update_file` tools are called:
1. File operation completes
2. Language server spawns (ruff, tsserver, gopls, etc.)
3. Diagnostics fetched for the file
4. Results appended to tool output

## Configuration

Enable/disable in `~/.tunacode/config.yaml`:

```yaml
settings:
  lsp:
    enabled: true
    timeout: 5.0
```

## Requirements

Install language servers for your languages:

- **Python**: `pip install ruff`
- **TypeScript/JavaScript**: `npm install -g typescript-language-server`
- **Go**: `go install golang.org/x/tools/gopls@latest`
- **Rust**: `rustup component add rust-analyzer`

## Output Format

```
<file_diagnostics>
ACTION REQUIRED: 2 error(s) found - fix before continuing
Error (line 15): undefined name 'x'
Error (line 23): missing return statement
</file_diagnostics>
```

The agent receives this as contextual feedback and decides how to respond.

## Architecture

LSP lives in `tools/lsp/` as a tool-layer concern:
- `tools.lsp.get_diagnostics()` - fetch diagnostics
- `tools.lsp.format_diagnostics()` - format for output
- `tools.write_file` and `tools.update_file` call these automatically

