# Using Claude Code to create skills, commands, plans, ... for SWI-Prolog

**URL:** <https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420>\
**Category:** Discussion\
**Created:** [December 7, 2025, 7:05pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420 "2025-12-07T19:05:04Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [December 12, 2025, 2:21am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/7 "2025-12-12T02:21:09Z")

</div>

> [@jan](#):
>
> do you know whether Claude code integration uses the LSP protocol?

So by chance had the OUTPUT tab open instead of the TERMINAL tab in VS Code so decided to read the messages while Claude was working. Spotted LSP in the stream right after an SWI-Prolog \*.pl file was listed.

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/4/407425f6dbd8e135934d038882f6205572947902.png)

```prolog
2025-12-11 20:11:46.495 [info] [DiagnosticTracking] No new diagnostics found for c:\Users\Eric\Projects\Prolog_AI_Assistant_Research\lib\prolog_coverage_ai.pl
2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-12T02:11:46.634Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-12T02:11:46.634Z [DEBUG] Hooks: checkForNewResponses returning 0 responses

```

Looking at the entire OUTPUT found

```prolog
2025-12-11 15:26:17.497 [info] From claude: 2025-12-11T21:26:17.498Z [DEBUG] Total LSP servers loaded: 0

```

* * *

Asked Claude to create the following markdown document (which has not been verified). This sheds more light with details on my earlier [reply](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/5).

> **Claude Code LSP Integration Guide**
>
> # Claude Code LSP Integration Guide
> 
> **Last Updated:** 2025-12-12  
> **Audience:** Beginners to Prolog, LSP, and Claude Code  
> **Purpose:** Understanding if and how Claude Code can integrate with Language Server Protocol (LSP) for SWI-Prolog development
> 
> * * *
> 
> ## Table of Contents
> 
> 1. [What is LSP?](#what-is-lsp)
> 2. [What is Claude Code?](#what-is-claude-code)
> 3. [Understanding the Log Messages](#understanding-the-log-messages)
> 4. [Can Claude Code Integrate with LSP?](#can-claude-code-integrate-with-lsp)
> 5. [SWI-Prolog LSP Implementations](#swi-prolog-lsp-implementations)
> 6. [MCP Server Options for Enhanced Integration](#mcp-server-options-for-enhanced-integration)
> 7. [Comparison of LSP Integration Approaches](#comparison-of-lsp-integration-approaches)
> 8. [Claude Code for VS Code: Known Issues](#claude-code-for-vs-code-known-issues)
> 9. [Troubleshooting](#troubleshooting)
> 10. [Resources](#resources)
> 
> * * *
> 
> ## What is LSP?
> 
> **Language Server Protocol (LSP)** is a standardized protocol that allows code editors (like VS Code) to communicate with language-specific tools that provide:
> 
> - **Error checking** (syntax errors, type errors)
> - **Autocomplete** (intelligent code suggestions)
> - **Go to definition** (jump to where functions/predicates are defined)
> - **Find references** (see where code is used)
> - **Hover information** (documentation popups)
> - **Linting warnings** (code quality suggestions)
> 
> ### Why LSP Matters
> 
> Before LSP, every editor needed custom support for each programming language. LSP standardizes this:
> 
> ```prolog
> Editor (VS Code) <--> LSP Protocol <--> Language Server (Prolog LSP)
> 
> ```
> 
> This means one Prolog language server can work with any LSP-compatible editor.
> 
> ### LSP Diagnostics
> 
> **Diagnostics** are error messages, warnings, and hints about your code that the language server sends to your editor. When you see red squiggles under code with error messages, that’s LSP diagnostics in action.
> 
> * * *
> 
> ## What is Claude Code?
> 
> **Claude Code** is an AI-powered coding assistant that can:
> 
> - Read and analyze your codebase
> - Write and edit code
> - Debug problems
> - Answer questions about your code
> - Run tests and build commands
> 
> ### Claude Code Variants
> 
> 1. **CLI Tool** - Command-line interface for terminal use
> 2. **VS Code Extension** - Integrated into Visual Studio Code
> 3. **JetBrains Plugin** - For IntelliJ, PyCharm, etc.
> 
> ### How Claude Code Uses LSP
> 
> Claude Code can **integrate with LSP diagnostics** to:
> 
> - See errors and warnings in your code automatically
> - Understand what’s broken before you explain it
> - Provide more accurate fixes
> - Include diagnostic context in AI conversations
> 
> * * *
> 
> ## Understanding the Log Messages
> 
> When using Claude Code for VS Code, you may see messages like this in the **OUTPUT** tab:
> 
> ```prolog
> 2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
> 2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
> 2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.634Z [DEBUG] Hooks: Found 0 total hooks in registry
> 2025-12-11 15:26:17.497 [info] From claude: 2025-12-11T21:26:17.498Z [DEBUG] Total LSP servers loaded: 0
> 
> ```
> 
> ### Message Breakdown
> 
> #### Message Structure
> 
> ```prolog
> 2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
> │ │ │ │ │ │
> │ │ │ │ │ └─ Debug message
> │ │ │ │ └─ Claude Code's internal log level
> │ │ │ └─ Claude Code's timestamp (UTC)
> │ │ └─ Message source identifier
> │ └─ VS Code's log level
> └─ VS Code's timestamp (local time)
> 
> ```
> 
> #### Key Components
> 
> | Component | Meaning |
> | --- | --- |
> | **`[info] From claude:`** | Message originated from Claude Code extension |
> | **`[DEBUG]`** | Internal debug-level logging from Claude Code |
> | **`getLSPDiagnosticAttachments called`** | Claude Code is checking for LSP diagnostics to include in AI context |
> | **`Checking registry - 0 pending`** | No diagnostics found in the internal registry |
> | **`Total LSP servers loaded: 0`** | No LSP servers are currently connected to Claude Code |
> 
> ### What Does “getLSPDiagnosticAttachments” Mean?
> 
> This is an internal function that:
> 
> 1. **Runs when** : Claude Code prepares to send a message to the AI
> 2. **Purpose** : Gather any LSP diagnostics (errors/warnings) from your code
> 3. **Action** : Packages diagnostics as “attachments” to include in the conversation
> 4. **Result** : Returns empty if no diagnostics found
> 
> **Flow:**
> 
> ```prolog
> User sends message to Claude
> ↓
> Claude Code prepares AI request
> ↓
> getLSPDiagnosticAttachments() called
> ↓
> Checks LSP diagnostic registry
> ↓
> Finds: "0 pending" (no errors/warnings)
> ↓
> Message sent to AI without diagnostic context
> 
> ```
> 
> ### Why “0 LSP servers loaded”?
> 
> This message indicates **no LSP servers are connected** to Claude Code. This means:
> 
> - ✅ Claude Code’s LSP integration system is running
> - ❌ No language servers are connected to it
> - ⚠ Claude Code cannot see LSP diagnostics from your editor
> 
> **This is a configuration gap** , not a fundamental limitation.
> 
> * * *
> 
> ## Can Claude Code Integrate with LSP?
> 
> ### Short Answer
> 
> **Yes, but with limitations and workarounds needed.**
> 
> ### Detailed Answer
> 
> #### Built-in Support
> 
> Claude Code **version 2.0.30+** (October 31, 2024) includes:
> 
> - ✅ Basic LSP support system
> - ✅ Automatic diagnostic sharing in VS Code extension
> - ✅ `$ENABLE_LSP_TOOL=1` environment variable to enable LSP tool
> - ⚠ Still early/raw - bugs exist, limited documentation
> 
> #### Current Limitations (as of 2025-12-12)
> 
> 1. **VS Code Extension Paradox**
> 
> 2. **No UI Indication**
> 
> 3. **Limited Documentation**
> 
> ### Two Integration Levels
> 
> #### Level 1: VS Code Native LSP (Working)
> 
> ```prolog
> Your Code <--> Prolog LSP Server <--> VS Code
> │
> └─> Shows errors in Problems panel
> 
> ```
> 
> VS Code itself can use Prolog LSP servers to show you errors, regardless of Claude Code.
> 
> #### Level 2: Claude Code Access to LSP (Needs Configuration)
> 
> ```prolog
> Your Code <--> Prolog LSP Server <--> VS Code <--> Claude Code Extension
> │
> └─> Claude sees diagnostics
> 
> ```
> 
> This requires additional setup using MCP servers or waiting for improved built-in support.
> 
> * * *
> 
> ## SWI-Prolog LSP Implementations
> 
> ### Overview
> 
> There are two main LSP server implementations for SWI-Prolog:
> 
> | Implementation | Maturity | Recommended | Platform Support |
> | --- | --- | --- | --- |
> | [lsp\_server](https://github.com/jamesnvc/lsp_server) by jamesnvc | Mature | ✅ **Yes** | Linux, macOS, Windows (with caveats) |
> | [prolog\_lsp](https://github.com/hargettp/prolog_lsp) by hargettp | Experimental | ❌ No | All platforms (but immature) |
> 
> ### Option 1: lsp\_server (Recommended)
> 
> **Repository:** [GitHub - jamesnvc/lsp\_server: Language Server Protocol server for SWI-Prolog](https://github.com/jamesnvc/lsp_server)  
> **SWI-Prolog Pack:** ["lsp\_server" pack for SWI-Prolog](https://www.swi-prolog.org/pack/list?p=lsp_server)  
> **Maturity:** Production-ready
> 
> #### Features
> 
> - ✅ Find definitions
> - ✅ Find references
> - ✅ Hover documentation
> - ✅ Code completion
> - ✅ Diagnostics (errors/warnings)
> - ✅ Signature help
> 
> #### Installation
> 
> **Method 1: Using pack\_install**
> 
> ```prolog
> ?- pack_install(lsp_server).
> 
> ```
> 
> **Method 2: Using swipl command**
> 
> ```bash
> swipl pack install lsp_server
> 
> ```
> 
> #### Requirements
> 
> - SWI-Prolog **8.1.5 or newer** (for best results with “find references”)
> - Requires `xref_called/5` predicate (available in 8.1.5+)
> 
> #### Windows-Specific Configuration
> 
> ⚠ **IMPORTANT:** On Windows (not WSL), running the server via **stdio will NOT work**.
> 
> **Solution:** Run the server over a **socket** instead:
> 
> ```bash
> # Start lsp_server on a specific port
> swipl -g "lsp_server:main([port, 5007])" -t halt
> 
> ```
> 
> **As of version 2.5.0** , socket mode is supported via command-line arguments:
> 
> ```bash
> port <port_number>
> 
> ```
> 
> instead of `stdio`.
> 
> #### VS Code Extension: swi-lsp
> 
> **Marketplace:** [swi-lsp - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=lilr.swi-lsp)
> 
> This extension provides VS Code integration for `lsp_server`.
> 
> **Installation:**
> 
> 1. Open VS Code
> 2. Go to Extensions (Ctrl+Shift+X)
> 3. Search for “swi-lsp”
> 4. Click Install
> 
> **Configuration:** See the extension’s README for connecting to the LSP server.
> 
> * * *
> 
> ### Option 2: prolog\_lsp (Experimental)
> 
> **Repository:** [GitHub - hargettp/prolog\_lsp: Language Server for Prolog](https://github.com/hargettp/prolog_lsp)  
> **SWI-Prolog Pack:** ["prolog\_lsp" pack for SWI-Prolog](https://www.swi-prolog.org/pack/list?p=prolog_lsp)  
> **Maturity:** ⚠ Experimental (not recommended for production)
> 
> #### Status
> 
> From the author:
> 
> > “This project is very immature and not at all recommended for daily production use.”
> 
> #### When to Consider
> 
> - You want to contribute to LSP development
> - You’re experimenting with alternative implementations
> - You need features not yet in lsp\_server
> 
> * * *
> 
> ## MCP Server Options for Enhanced Integration
> 
> **Model Context Protocol (MCP)** servers can bridge the gap between Claude Code and LSP diagnostics.
> 
> ### What is MCP?
> 
> MCP is a protocol that allows AI assistants like Claude to access external tools and data sources. MCP servers act as middleware that:
> 
> - Connect Claude Code to LSP servers
> - Expose LSP features as tools Claude can use
> - Work around limitations in Claude Code’s built-in LSP support
> 
> ### Available MCP Servers for LSP Integration
> 
> #### 1. cclsp (Claude Code LSP)
> 
> **Repository:** [GitHub - ktnyt/cclsp: Claude Code LSP: enhance your Claude Code experience with non-IDE dependent LSP integration.](https://github.com/ktnyt/cclsp)  
> **MCP Market:** [https://mcpmarket.com/server/cclsp](https://mcpmarket.com/server/cclsp)
> 
> ##### Features
> 
> - ✅ Pull current diagnostics using `textDocument/diagnostic`
> - ✅ Find definitions, references, rename symbols
> - ✅ Server restart capabilities
> - ✅ Intelligent position handling (tries multiple combinations)
> - ✅ Robust symbol resolution
> 
> ##### Why It Helps
> 
> Solves the common problem where AI agents struggle with accurate line/column numbers when communicating with LSP servers.
> 
> ##### Use Case
> 
> You want Claude Code to have **direct access** to LSP features regardless of IDE limitations.
> 
> * * *
> 
> #### 2. tritlo/lsp-mcp
> 
> **Playbooks:** [LSP MCP server for AI agents](https://playbooks.com/mcp/tritlo-lsp)
> 
> ##### Features
> 
> - ✅ Hover information
> - ✅ Code completions
> - ✅ Diagnostics
> - ✅ Generic LSP feature access for LLMs
> 
> ##### Why It Helps
> 
> Provides a clean interface for AI agents to query LSP servers for any language.
> 
> ##### Use Case
> 
> You want a **language-agnostic** MCP server that works with multiple LSP servers.
> 
> * * *
> 
> #### 3. @juanpprieto/claude-lsp
> 
> **NPM Package:** [https://www.npmjs.com/package/@juanpprieto/claude-lsp](https://www.npmjs.com/package/@juanpprieto/claude-lsp)
> 
> ##### Features
> 
> - ✅ Hook-based diagnostic injection
> - ✅ Real-time code analysis
> - ✅ TypeScript LSP integration
> - ✅ ESLint checking
> - ✅ Prettier formatting
> - ✅ GraphQL checks
> 
> ##### Why It Helps
> 
> Automatically injects diagnostics into Claude’s context using hooks, so Claude sees:
> 
> - Type errors
> - Lint warnings
> - Formatting issues
> 
> ##### Use Case
> 
> You want **automatic, real-time** diagnostic sharing without manual intervention.
> 
> * * *
> 
> ### Comparison of MCP Servers
> 
> | Feature | cclsp | tritlo/lsp-mcp | @juanpprieto/claude-lsp |
> | --- | --- | --- | --- |
> | **Diagnostics** | ✅ | ✅ | ✅ |
> | **Definitions** | ✅ | ✅ | ❓ |
> | **References** | ✅ | ✅ | ❓ |
> | **Hover Info** | ✅ | ✅ | ❓ |
> | **Completions** | ❓ | ✅ | ✅ |
> | **Auto-injection** | ❌ | ❌ | ✅ (via hooks) |
> | **Multi-language** | ✅ | ✅ | 🔸 (JS/TS focused) |
> | **Position handling** | ✅ (robust) | ✅ | ✅ |
> | **Server restart** | ✅ | ❓ | ❌ |
> | **Prolog support** | ✅ (any LSP) | ✅ (any LSP) | ❓ (JS/TS focused) |
> 
> **Legend:**
> 
> - ✅ = Supported
> - ❌ = Not supported
> - ❓ = Unknown/unclear
> - 🔸 = Partial support
> 
> * * *
> 
> ## Comparison of LSP Integration Approaches
> 
> ### Overview Table
> 
> | Approach | Setup Complexity | Claude Access | Cost | Maturity | Platform Support |
> | --- | --- | --- | --- | --- | --- |
> | **VS Code Native Only** | Low | ❌ None | Free | Mature | All |
> | **Built-in Claude Code LSP** | Low-Medium | 🔸 Limited | Free | Early/Raw | All |
> | **MCP Server (cclsp)** | Medium | ✅ Full | Free | Moderate | All |
> | **MCP Server (tritlo)** | Medium | ✅ Full | Free | Moderate | All |
> | **MCP Server (@juanpprieto)** | Medium-High | ✅ Auto | Free | Moderate | All |
> 
> ### Detailed Comparison
> 
> #### 1. VS Code Native LSP Only
> 
> **Setup:**
> 
> ```prolog
> Install Prolog LSP extension (swi-lsp) → Configure → Done
> 
> ```
> 
> **Pros:**
> 
> - ✅ Simple setup
> - ✅ Works independently of Claude Code
> - ✅ Well-documented
> - ✅ Stable
> 
> **Cons:**
> 
> - ❌ Claude Code **cannot** see diagnostics
> - ❌ No AI-assisted error fixing
> - ❌ Manual error explanation needed
> 
> **Best For:** Users who want VS Code LSP features but don’t need Claude to access diagnostics.
> 
> * * *
> 
> #### 2. Built-in Claude Code LSP Support
> 
> **Setup:**
> 
> ```bash
> export ENABLE_LSP_TOOL=1
> # Or set in VS Code settings
> 
> ```
> 
> **Pros:**
> 
> - ✅ No additional software needed
> - ✅ Official support from Anthropic
> - ✅ Automatic diagnostic sharing (in theory)
> 
> **Cons:**
> 
> - ⚠ Early/raw implementation (as of 2025-12)
> - ⚠ Bugs in different LSP operations
> - ❌ No documentation
> - ❌ No UI indication of status
> - ❌ VS Code extension missing MCP tool
> 
> **Best For:** Early adopters willing to work through limitations while the feature matures.
> 
> * * *
> 
> #### 3. MCP Server Integration (cclsp)
> 
> **Setup:**
> 
> ```bash
> # Install cclsp MCP server
> npm install -g cclsp
> 
> # Configure in Claude Code settings
> # Point to your Prolog LSP server
> 
> ```
> 
> **Pros:**
> 
> - ✅ Full LSP feature access
> - ✅ Robust position handling
> - ✅ Works around IDE limitations
> - ✅ Server restart capabilities
> - ✅ Language-agnostic
> 
> **Cons:**
> 
> - ⚠ Additional software to install
> - ⚠ More complex configuration
> - ⚠ Requires understanding of MCP
> 
> **Best For:** Power users who want complete LSP integration and are comfortable with configuration.
> 
> * * *
> 
> #### 4. MCP Server Integration (tritlo/lsp-mcp)
> 
> **Setup:**
> 
> ```bash
> # Install and configure tritlo/lsp-mcp
> # Connect to Prolog LSP server
> 
> ```
> 
> **Pros:**
> 
> - ✅ Generic LSP interface
> - ✅ Multi-language support
> - ✅ Hover, completions, diagnostics
> 
> **Cons:**
> 
> - ⚠ Additional software to install
> - ⚠ Configuration complexity
> - ❓ Less documentation than cclsp
> 
> **Best For:** Users working with multiple languages who want one MCP server for all LSP interactions.
> 
> * * *
> 
> #### 5. Hook-based Auto-injection (@juanpprieto/claude-lsp)
> 
> **Setup:**
> 
> ```bash
> npm install @juanpprieto/claude-lsp
> 
> # Configure hooks in Claude Code
> # Set up automatic injection
> 
> ```
> 
> **Pros:**
> 
> - ✅ **Automatic** diagnostic injection
> - ✅ Real-time analysis
> - ✅ No manual triggering needed
> - ✅ Hook-based workflow integration
> 
> **Cons:**
> 
> - ⚠ Most complex setup
> - ⚠ Primarily JS/TS focused (Prolog support unclear)
> - ⚠ Requires hook configuration knowledge
> 
> **Best For:** TypeScript/JavaScript developers who want fully automatic diagnostic sharing; Prolog support uncertain.
> 
> * * *
> 
> ### Decision Matrix
> 
> **Choose VS Code Native Only if:**
> 
> - You only need LSP features in your editor
> - You don’t need Claude to see diagnostics
> - You want the simplest setup
> 
> **Choose Built-in Claude Code LSP if:**
> 
> - You’re okay with early-stage software
> - You want official support
> - You can wait for maturity improvements
> 
> **Choose cclsp MCP Server if:**
> 
> - You need full LSP feature access in Claude
> - You want robust, reliable integration
> - You’re comfortable with configuration
> 
> **Choose tritlo/lsp-mcp if:**
> 
> - You work with multiple languages
> - You want a generic LSP solution
> - You prefer flexibility over specialization
> 
> **Choose @juanpprieto/claude-lsp if:**
> 
> - You primarily work with TypeScript/JavaScript
> - You want automatic diagnostic injection
> - You’re willing to invest in complex setup
> 
> * * *
> 
> ## Claude Code for VS Code: Known Issues
> 
> This section documents specific issues when using Claude Code through the VS Code chat interface.
> 
> ### Issue 1: Missing MCP IDE Diagnostics Tool
> 
> **Reference:** [Issue #8635](https://github.com/anthropics/claude-code/issues/8635)
> 
> **Problem:**
> 
> - CLI version of Claude Code has `mcp __ide__ getDiagnostics` tool
> - VS Code extension is **missing** this tool
> - Paradox: External CLI has better IDE access than native extension
> 
> **Impact:**
> 
> - VS Code extension cannot retrieve Pylance/LSP diagnostics via MCP
> - Reduces effectiveness compared to CLI version
> - “Fix with Claude Code” feature may not work properly
> 
> **Status:** Open issue (as of 2025-12-12)
> 
> **Workaround:**
> 
> - Use CLI version with `--ide` flag to connect to VS Code
> - Use MCP servers (cclsp, tritlo/lsp-mcp) to bridge the gap
> - Wait for official fix
> 
> * * *
> 
> ### Issue 2: LSP Integration Worse Than CLI
> 
> **Reference:** [Issue #8635](https://github.com/anthropics/claude-code/issues/8635) (same issue)
> 
> **Problem:**
> 
> > “The CLI version of Claude Code can connect to IDEs and access diagnostics. But the VSCode Extension (which runs _inside_ the IDE) has _worse_ IDE integration.”
> 
> **Expected Behavior:**
> 
> - VS Code extension should have **better** LSP access
> - Should see all diagnostics automatically
> - Should integrate seamlessly with native LSP features
> 
> **Actual Behavior:**
> 
> - Extension shows “Total LSP servers loaded: 0”
> - Cannot access diagnostics that VS Code itself can see
> - Requires workarounds to access native IDE features
> 
> * * *
> 
> ### Issue 3: “Fix with Claude Code” Action Broken
> 
> **Reference:** [Issue #2269](https://github.com/anthropics/claude-code/issues/2269)
> 
> **Problem:**
> 
> - “Fix with Claude Code” action in VS Code doesn’t work properly
> - Diagnostic information not passed correctly to Claude
> - May fail silently or provide incomplete context
> 
> **Impact:**
> 
> - Quick-fix workflow broken
> - Must manually describe errors to Claude
> - Reduces productivity
> 
> **Workaround:**
> 
> - Manually copy error messages to Claude chat
> - Use terminal/CLI commands to run diagnostics
> - Wait for official fix
> 
> * * *
> 
> ### Issue 4: No UI Indication of LSP Server Status
> 
> **Problem:**
> 
> - No visual feedback in VS Code about LSP server connections
> - No way to know if LSP integration is working
> - Must check OUTPUT tab logs to debug
> 
> **Impact:**
> 
> - Users unaware of connection issues
> - Difficult to troubleshoot
> - “0 LSP servers loaded” discovered only through logs
> 
> **Workaround:**
> 
> - Regularly check OUTPUT tab → Select “Claude Code” source
> - Look for debug messages about LSP servers
> - Monitor for “Total LSP servers loaded: X” messages
> 
> * * *
> 
> ### Issue 5: Early/Raw LSP Support
> 
> **Reference:** [Issue #5495](https://github.com/anthropics/claude-code/issues/5495) discussion
> 
> **Problem:**
> 
> - LSP support added in v2.0.30 but still immature
> - Bugs in different LSP operations
> - Missing documentation
> - No standardized configuration
> 
> **Known Bugs:**
> 
> - Socket vs stdio connection issues
> - Server initialization failures
> - Position/offset calculation errors
> - Timeout issues (especially in JetBrains IDEs)
> 
> **Workaround:**
> 
> - Use `$ENABLE_LSP_TOOL=1` environment variable
> - Report bugs to GitHub issues
> - Use MCP servers for more stable integration
> - Contribute to community testing
> 
> * * *
> 
> ### Issue 6: Windows-Specific Problems
> 
> **Problem:**
> 
> - Prolog LSP server (`lsp_server`) doesn’t support stdio on Windows
> - Must use socket mode instead
> - Configuration more complex than Linux/macOS
> 
> **Impact:**
> 
> - Windows users need extra configuration steps
> - May encounter connection errors with default settings
> 
> **Solution:**
> 
> - Always use socket mode on Windows:
> 
> ```bash
> swipl -g "lsp_server:main([port, 5007])" -t halt
> 
> ```
> 
> - Configure VS Code extension to connect via socket
> - See [lsp\_server documentation](https://www.swi-prolog.org/pack/file_details/lsp_server/vscode/README.md)
> 
> * * *
> 
> ### Known Workarounds Summary
> 
> | Issue | Workaround | Effort | Effectiveness |
> | --- | --- | --- | --- |
> | Missing MCP tool | Use CLI with `--ide` flag | Medium | ✅ Good |
> | Missing MCP tool | Use cclsp/tritlo MCP server | Medium-High | ✅ Excellent |
> | Poor LSP integration | Use MCP servers | Medium-High | ✅ Excellent |
> | “Fix with Claude” broken | Manual error copying | Low | 🔸 Partial |
> | No UI indication | Monitor OUTPUT logs | Low | 🔸 Diagnostic only |
> | Windows stdio issues | Use socket mode | Medium | ✅ Good |
> 
> * * *
> 
> ## Troubleshooting
> 
> ### Problem: “Total LSP servers loaded: 0”
> 
> **Symptoms:**
> 
> ```prolog
> [DEBUG] Total LSP servers loaded: 0
> [DEBUG] LSP Diagnostics: Checking registry - 0 pending
> 
> ```
> 
> **Causes:**
> 
> 1. No Prolog LSP server installed in VS Code
> 2. LSP server installed but not connected to Claude Code
> 3. Claude Code’s LSP integration not enabled
> 
> **Solutions:**
> 
> **Step 1: Install Prolog LSP Server**
> 
> ```bash
> # Install lsp_server pack
> swipl -g "pack_install(lsp_server)" -t halt
> 
> # Or install VS Code extension
> # Search "swi-lsp" in VS Code Extensions marketplace
> 
> ```
> 
> **Step 2: Enable Claude Code LSP Support**
> 
> ```bash
> # Set environment variable
> export ENABLE_LSP_TOOL=1
> 
> # Or in VS Code settings.json
> {
> "claude-code.enableLSP": true
> }
> 
> ```
> 
> **Step 3: Verify LSP Server Running**
> 
> - Open a Prolog file in VS Code
> - Check Problems panel (Ctrl+Shift+M) for diagnostics
> - If VS Code shows diagnostics, LSP server is working
> 
> **Step 4: Install MCP Server (Alternative)**
> 
> ```bash
> # Install cclsp
> npm install -g cclsp
> 
> # Configure in Claude Code MCP settings
> 
> ```
> 
> * * *
> 
> ### Problem: No Diagnostics Showing in VS Code
> 
> **Symptoms:**
> 
> - No errors/warnings in Problems panel
> - Red squiggles not appearing under code
> - LSP server seems not to work
> 
> **Solutions:**
> 
> **Check 1: Is the LSP Extension Installed?**
> 
> - Go to Extensions (Ctrl+Shift+X)
> - Search “swi-lsp” or “prolog”
> - Install if missing
> 
> **Check 2: Is the LSP Server Running?**
> 
> On **Linux/macOS** :
> 
> ```bash
> ps aux | grep lsp_server
> 
> ```
> 
> On **Windows** :
> 
> ```powershell
> Get-Process | Select-String "swipl"
> 
> ```
> 
> **Check 3: VS Code Output Logs**
> 
> - Open OUTPUT tab (Ctrl+Shift+U)
> - Select “SWI-Prolog Language Server” from dropdown
> - Look for error messages
> 
> **Check 4: Restart LSP Server**
> 
> - Open VS Code Command Palette (Ctrl+Shift+P)
> - Type “Reload Window”
> - Or restart VS Code entirely
> 
> * * *
> 
> ### Problem: Windows Socket Connection Errors
> 
> **Symptoms:**
> 
> - LSP server fails to start
> - “Connection refused” errors
> - stdio-related errors
> 
> **Solution:**
> 
> **Must use socket mode on Windows:**
> 
> ```bash
> # Start LSP server on specific port
> swipl -g "lsp_server:main([port, 5007])" -t halt
> 
> ```
> 
> **Configure VS Code extension** (`settings.json`):
> 
> ```json
> {
> "swi-lsp.server.host": "localhost",
> "swi-lsp.server.port": 5007
> }
> 
> ```
> 
> * * *
> 
> ### Problem: Claude Code Can’t See Diagnostics VS Code Shows
> 
> **Symptoms:**
> 
> - VS Code Problems panel shows errors
> - Claude Code shows “0 pending” diagnostics
> - LSP server working but Claude can’t access it
> 
> **Root Cause:**
> 
> - VS Code extension missing `mcp __ide__ getDiagnostics` tool
> - Claude Code’s LSP integration not connected to VS Code’s LSP
> 
> **Solutions:**
> 
> **Option 1: Use MCP Server**
> 
> ```bash
> npm install -g cclsp
> # Configure to connect to your Prolog LSP server
> 
> ```
> 
> **Option 2: Use CLI with IDE Connection**
> 
> ```bash
> claude --ide vscode
> 
> ```
> 
> **Option 3: Wait for Official Fix**
> 
> - Track [Issue #8635](https://github.com/anthropics/claude-code/issues/8635)
> - Update to latest Claude Code version when fixed
> 
> * * *
> 
> ### Problem: “Fix with Claude Code” Does Nothing
> 
> **Symptoms:**
> 
> - Right-click on error → “Fix with Claude Code”
> - Nothing happens or error appears
> - Diagnostic not passed to Claude
> 
> **Solution:**
> 
> **Manual Workaround:**
> 
> 1. Copy the error message from Problems panel
> 2. Open Claude Code chat
> 3. Paste error and ask for fix
> 4. Apply fix manually
> 
> **Permanent Solution:**
> 
> - Wait for [Issue #2269](https://github.com/anthropics/claude-code/issues/2269) fix
> - Use MCP server integration instead
> 
> * * *
> 
> ## Resources
> 
> ### Official Documentation
> 
> - **Claude Code Docs:** [Claude Code overview - Claude Code Docs](https://code.claude.com/docs/en/overview)
> - **Claude Code VS Code:** [Visual Studio Code - Claude Code Docs](https://code.claude.com/docs/en/vs-code)
> - **Anthropic API Docs:** [https://docs.anthropic.com/](https://docs.anthropic.com/)
> 
> ### SWI-Prolog LSP Implementations
> 
> - **lsp\_server pack:** ["lsp\_server" pack for SWI-Prolog](https://www.swi-prolog.org/pack/list?p=lsp_server)
> - **lsp\_server GitHub:** [GitHub - jamesnvc/lsp\_server: Language Server Protocol server for SWI-Prolog](https://github.com/jamesnvc/lsp_server)
> - **lsp\_server VS Code README:** [Pack lsp\_server -- vscode/README.md](https://www.swi-prolog.org/pack/file_details/lsp_server/vscode/README.md)
> - **prolog\_lsp pack:** ["prolog\_lsp" pack for SWI-Prolog](https://www.swi-prolog.org/pack/list?p=prolog_lsp)
> - **prolog\_lsp GitHub:** [GitHub - hargettp/prolog\_lsp: Language Server for Prolog](https://github.com/hargettp/prolog_lsp)
> 
> ### VS Code Extensions
> 
> - **swi-lsp Extension:** [swi-lsp - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=lilr.swi-lsp)
> - **VSC-Prolog Extension:** [VSC-Prolog - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=arthurwang.vsc-prolog)
> 
> ### MCP Servers
> 
> - **cclsp GitHub:** [GitHub - ktnyt/cclsp: Claude Code LSP: enhance your Claude Code experience with non-IDE dependent LSP integration.](https://github.com/ktnyt/cclsp)
> - **cclsp MCP Market:** [https://mcpmarket.com/server/cclsp](https://mcpmarket.com/server/cclsp)
> - **tritlo/lsp-mcp:** [LSP MCP server for AI agents](https://playbooks.com/mcp/tritlo-lsp)
> - **@juanpprieto/claude-lsp:** [https://www.npmjs.com/package/@juanpprieto/claude-lsp](https://www.npmjs.com/package/@juanpprieto/claude-lsp)
> 
> ### GitHub Issues
> 
> - **Issue #8635 - Missing MCP IDE Diagnostics:** [[BUG] VSCode Extension missing MCP IDE Diagnostics tool and /bug command · Issue #8635 · anthropics/claude-code · GitHub](https://github.com/anthropics/claude-code/issues/8635)
> - **Issue #2269 - Fix with Claude Code Broken:** [[BUG] "Fix with Claude Code" action is broken in VSCode · Issue #2269 · anthropics/claude-code · GitHub](https://github.com/anthropics/claude-code/issues/2269)
> - **Issue #5495 - Enable VSCode LSP APIs:** [Enable VSCode LSP APIs: 100-1000x Performance Improvement for Code Navigation · Issue #5495 · anthropics/claude-code · GitHub](https://github.com/anthropics/claude-code/issues/5495)
> - **Issue #741 - Claude Code LSP Integration (Rust example):** [Claude Code integration with LSP (with example for Rust) · Issue #741 · anthropics/claude-code · GitHub](https://github.com/anthropics/claude-code/issues/741)
> - **Issue #3085 - getDiagnostics Timeout (JetBrains):** [[BUG] `ide:getDiagnostics` times out if file is not active in Jetbrains IDE · Issue #3085 · anthropics/claude-code · GitHub](https://github.com/anthropics/claude-code/issues/3085)
> 
> ### LSP Protocol Documentation
> 
> - **LSP Official Spec:** [Official page for Language Server Protocol](https://microsoft.github.io/language-server-protocol/)
> - **VS Code LSP Guide:** [Language Server Extension Guide | Visual Studio Code Extension API](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide)
> - **LSP Tutorial:** [https://www.toptal.com/javascript/language-server-protocol-tutorial](https://www.toptal.com/javascript/language-server-protocol-tutorial)
> 
> ### Community Resources
> 
> - **Piebald-AI LSP Marketplace:** [GitHub - Piebald-AI/claude-code-lsps: Claude Code Plugin Marketplace with LSP servers (requires tweakcc currently)](https://github.com/Piebald-AI/claude-code-lsps)
> - **Awesome Claude Code:** [GitHub - hesreallyhim/awesome-claude-code: [FOR USERS HAVING PERFORMANCE ISSUES: USE README\_BACKUP INSTEAD] A curated list of awesome commands, files, and workflows for Claude Code](https://github.com/hesreallyhim/awesome-claude-code)
> 
> * * *
> 
> ## Appendix: Example VS Code Configuration
> 
> ### settings.json for SWI-Prolog LSP
> 
> ```json
> {
> // SWI-Prolog LSP Server Configuration
> "swi-lsp.server.enabled": true,
> "swi-lsp.server.host": "localhost",
> "swi-lsp.server.port": 5007,
> 
> // Claude Code Configuration
> "claude-code.enableLSP": true,
> "claude-code.debug": true,
> 
> // Prolog File Associations
> "files.associations": {
> "*.pl": "prolog",
> "*.pro": "prolog"
> }
> }
> 
> ```
> 
> ### Environment Variables
> 
> ```bash
> # Enable Claude Code LSP tool
> export ENABLE_LSP_TOOL=1
> 
> # Enable debug logging
> export CLAUDE_CODE_DEBUG=1
> 
> ```
> 
> * * *
> 
> ## Appendix: Starting LSP Server Manually
> 
> ### Linux/macOS
> 
> ```bash
> #!/bin/bash
> # start-prolog-lsp.sh
> 
> # Start lsp_server in stdio mode
> swipl -g "lsp_server:main([stdio])" -t halt
> 
> ```
> 
> ### Windows (Socket Mode Required)
> 
> ```powershell
> # start-prolog-lsp.ps1
> 
> # Start lsp_server in socket mode
> & "C:\Program Files\swipl\bin\swipl.exe" -g "lsp_server:main([port, 5007])" -t halt
> 
> ```
> 
> * * *
> 
> ## Summary
> 
> ### Key Takeaways
> 
> 1. **LSP is a protocol** that connects editors to language-specific tools for error checking, autocomplete, and more.
> 
> 2. **Claude Code can integrate with LSP** , but support is early/raw as of 2025-12-12.
> 
> 3. **“Total LSP servers loaded: 0”** means no LSP servers are connected to Claude Code - this is a configuration issue, not a limitation.
> 
> 4. **For SWI-Prolog** , use `lsp_server` by jamesnvc (mature) or the `swi-lsp` VS Code extension.
> 
> 5. **Windows users must use socket mode** - stdio doesn’t work for `lsp_server` on Windows.
> 
> 6. **VS Code extension has limitations** - missing MCP tool, worse than CLI version.
> 
> 7. **MCP servers (cclsp, tritlo/lsp-mcp)** provide workarounds for Claude Code’s LSP integration gaps.
> 
> 8. **Multiple integration approaches** exist - choose based on complexity tolerance and feature needs.
> 
> ### Quick Start Checklist
> 
> - Install SWI-Prolog (if not already installed)
> - Install `lsp_server` pack: `?- pack_install(lsp_server).`
> - Install `swi-lsp` VS Code extension
> - Configure socket mode (Windows) or stdio mode (Linux/macOS)
> - Verify LSP works in VS Code (check Problems panel)
> - Choose Claude Code integration approach:
> - Built-in (simple, limited)
> - MCP server (complex, full-featured)
> 
> - Enable `ENABLE_LSP_TOOL=1` if using built-in
> - Test: Open Prolog file with errors, check if Claude sees them

---

_[View the full topic](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420)._
