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

In short, yes it is possible.

Using LSP with LLMs is quite common. Claude Code doesn’t use LSP directly (see reply below), but LSP can be integrated with Claude Code through extension mechanisms such as MCP (Model Context Protocol).


TL;DR

Your question is excellent and was one of the first things I explored when considering SWI-Prolog development with Anthropic Claude Code.

AFAIK, there is no built-in integration of an LSP server with Claude Code.

Search of Claude Code source for LSP

I searched the GitHub Anthropic Claude Code repository and found a reference to LSP: claude-code/plugins/plugin-dev/commands/create-plugin.md at ace0a827787630fd23857b43c3e63bba12bb57d3 · anthropics/claude-code · GitHub

Claude Code does provide ways to add more tools such as MCP:

Give Claude more tools

Claude has access to your shell environment, where you can build up sets of convenience scripts and functions for it just like you would for yourself. It can also leverage more complex tools through MCP and REST APIs.

Source: https://www.anthropic.com/engineering/claude-code-best-practices

Real-world example

The Lean 4 programming language has an LSP implementation via MCP that is part of the recommended setup:

For using all of this with Claude Code Agent Skills

My experience with SWI-Prolog and Claude Code

After exploring the LSP specification, I found that while LSP is valuable for human-in-the-loop coding, it wasn’t essential for my current workflow. Anthropic’s Sonnet and Opus models are quite capable of:

  • Generating complete SWI-Prolog source files
  • Compiling code and fixing compilation errors
  • Running code and addressing runtime errors

In practice, my workflow is: create a detailed Plan with significant human input, approve the plan, then let Claude Code work autonomously while manually reviewing each edit to verify the reasoning and catch any errors early.

I also asked Claude directly about LSP integration with Claude Code, and it confirmed that an MCP bridge is the preferred approach.


Example of Claude fixing run time bug

Screen capture of Claude Code hitting a run time error, thinking about it, identifying a fix, proposing a code change and asking to make the edit.

Note: In the prompt for creating the plan and the same conversation with the fix was

fetch: https://www.swi-prolog.org/pldoc/man?section=consulting

so that Claude would have that knowledge in the context window. I suspect that if that were not in the context of the prompt that the proposed change might have missed using source_file/2.

In other words, years of experience with SWI-Prolog is what enables the created plans to be effective, I assure you many plans need adjustments and sometimes are just tossed after four attempts to get them headed in the right direction.

2 Likes