# 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:** 20\
**Page:** 1

<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 7, 2025, 7:05pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/1 "2025-12-07T19:05:04Z")

</div>

For the past few weeks, I’ve been using [Claude Code for VS Code](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code) to program in SWI-Prolog with more success than failure.

Over the years, many developers have had limited success using LLMs from companies such as [OpenAI](https://openai.com/news/), [Anthropic](https://www.anthropic.com/news), [Google](https://blog.google/technology/ai/), and [Meta](https://ai.meta.com/) to assist with Prolog coding, more specifically, SWI-Prolog.

I’m seeking to connect with others who are working not just with the LLM itself, but more specifically with [skills](https://www.claude.com/blog/skills), and to a lesser extent [plan mode](https://code.claude.com/docs/en/common-workflows#use-plan-mode-for-safe-code-analysis) for creating plans and [slash commands](https://code.claude.com/docs/en/slash-commands) for use with Claude Code.

* * *

**My Current Project**

The project includes several main Prolog files (\*.pl) and many corresponding tests ([\*.plt](https://www.swi-prolog.org/pldoc/man?section=testfiles)) with [test fixtures](https://en.wikipedia.org/wiki/Test_fixture#Software). It also uses some less common SWI-Prolog libraries such as [library(persistency)](https://www.swi-prolog.org/pldoc/man?section=persistency) and [library(prolog\_coverage)](https://www.swi-prolog.org/pldoc/man?section=prologcoverage).

I’ve created a few basic slash commands for Git to handle common tasks related to branching and merging, as well as to help Claude locate `swipl` (since the path isn’t stored in my Windows PATH environment variable).

I’ve developed around 50 skills, some of which are worth their weight in gold—particularly with test _Use Module Qualification for Internals_. That is something that initial training for LLMs did not seem to learn, thus the skill augments the initial knowledge.

I should note that I’m no expert on using Claude, but I do manage to consistently become more effective with continued usage and understanding.

If you’re using Claude in a similar manner or want to learn more, please join the discussion!

---

<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 8, 2025, 3:56pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/2 "2025-12-08T15:56:24Z")

</div>

If you are interested in using skills and do not use Claude Code then this GitHub repo might bridge the gap

> **[GitHub - obra/superpowers: Claude Code superpowers: core skills library](https://github.com/obra/superpowers/tree/main)**
>
> main

e.g. to use with Codex

[https://github.com/obra/superpowers/blob/154d664373569a83289684d7b01742a82cca4eaf/docs/README.codex.md](https://github.com/obra/superpowers/blob/154d664373569a83289684d7b01742a82cca4eaf/docs/README.codex.md)

Note: I have not used this repo, it does have 9K+ stars.

* * *

If you want a challenge for your fist AI skill for use with SWI-Prolog, which is one that I’ve had some success, try getting generated SWI-Prolog code to correctly use the appropriate [comparison operator](https://www.swi-prolog.org/pldoc/man?section=compare) when needed (e.g., for [conditionals](https://www.swi-prolog.org/pldoc/man?predicate=-%3E/2), [assertions](https://www.swi-prolog.org/pldoc/man?predicate=assertion/1), etc.) and to use [unification](https://www.swi-prolog.org/pldoc/man?section=compare) when appropriate.

Note, I would not be surprised if this skill will have to be specialized for different LLM models. This is one of the reasons to discuss these with others.

* * *

Have been using Claude Sonnet 4.5 mostly for SWI-Prolog coding with success. Switching to Haiku 4.5 was a disaster, it actually gave up on something that I thought was simple and switched to using Bash. Opus 4.5 works but expect to see the token usage jump significantly.

One of my hopes with all the skills is to give even Haiku 4.5 enough extra SWI-Prolog knowledge to create SWI-Prolog code. Many of the same problems keep reemerging and skills should/can be used to resolve them, just have to keep pushing forward.

Opus - Most capable for complex work.  
Sonnet - Best for everyday tasks.  
Haiku - Fastest for quick answers.

To track token usage with Claude, using the web chat interface or the desktop app, in the lower left click on the account icon, typically a circle with a letter in the middle. Then click Settings, then Usage.

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

---

<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 10, 2025, 1:24pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/3 "2025-12-10T13:24:12Z")

</div>

In working with AI, which I include both Prolog and LLMs in such a set, it pays to understand that how humans problem solve and AI problem solve at times are similar and at times are different.

Many know about apropos/1 and help/1 in SWI-Prolog but may prefer to use the full [documentation](https://www.swi-prolog.org/pldoc/doc_for?object=root) first. However if one has worked with Claude Code one will quickly see how often it uses basic low level command line tools, e.g. [grep](https://man7.org/linux/man-pages/man1/grep.1.html), [repgrep](https://github.com/BurntSushi/ripgrep), [glob](https://man7.org/linux/man-pages/man3/glob.3.html), [bash](https://linux.die.net/man/1/bash), to accomplish finding needed information quickly and effectively. In that same light the use of apropos/1 and help/1 are also of value as a skill for Claude Code.

However those tools are designed to output information for human use and an AI often gets by on just the facts. For example in looking for meta-predicates, if there were a separate AI tool to just list the signature it could go a long way to saving many [tokens](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them).

Instead of giving this to the AI

```prolog
catch(:Goal, +Catcher, :Recover) [ISO]
    Behaves as call/1 if no exception is raised when executing Goal. If an exception is raised
    using throw/1 while Goal executes, and the Goal is the innermost goal for which Catcher
    unifies with the argument of throw/1, all choice points generated by Goal are cut, the
    system backtracks to the start of catch/3 while preserving the thrown exception term, and
    Recover is called as in call/1.

    As of version 9.3.13, constraints (attributed variables) in Catcher are respected. If
    evaluating the constraint raises an exception, the most urgent exception is preserved (see
    section 4.10.2) and searching for a matching catch/3 call is continued. If both exceptions
    are equally urgent, the exception raised by the constraint evaluation is preserved.

    The overhead of calling a goal through catch/3 is comparable to call/1. Recovery from an
    exception is much slower, especially if the exception term is large due to the copying
    thereof or is decorated with a stack trace using, e.g., the library library(prolog_stack)
    based on the prolog_exception_hook/5 hook predicate to rewrite exceptions.
true.

```

just give it this

```prolog
catch(:Goal, +Catcher, :Recover)

```

Currently creating a Claude code script based on this idea.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 11, 2025, 9:03am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/4 "2025-12-11T09:03:53Z")

</div>

There are two things that may help:

```
?- man_object_property(Obj, summary(Summary)).

```

which you get from `library(pldoc/man_index)`. This gives you the short summaries.

Then, SWISH provides `lib/template_hint.pl`, which provides man\_predicate\_info/2. The file is nearly stand-alone in SWISH. It might be worthwhile to move this part of the functionality to PlDoc? It is used to support SWISH template hinting, but that is of course something that can be useful for every development tool.

This is interesting work. As a side note, do you know whether Claude code integration uses the LSP protocol? I’m currently adding support to Prolog’s development tools to act as LSP client. The original aim of this is to be able to add external tooling for AI completion, spell checking, etc. For debug the interaction I now use it with `clangd` to enhance the C mode of the editor. That works remarkably well 🙂

---

<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 11, 2025, 12:22pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/5 "2025-12-11T12:22:11Z")

</div>

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

In short, yes it is possible.

Using LSP with LLMs is quite common. Claude Code ~~doesn’t use LSP directly~~ (see [reply](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/7) below), but LSP can be integrated with Claude Code through extension mechanisms such as [MCP](https://www.anthropic.com/news/model-context-protocol) (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](https://github.com/anthropics/claude-code/blob/ace0a827787630fd23857b43c3e63bba12bb57d3/plugins/plugin-dev/commands/create-plugin.md?plain=1#L215)

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](https://www.anthropic.com/engineering/claude-code-best-practices)

**Real-world example**

The [Lean 4](https://lean-lang.org/) programming language has an LSP implementation via MCP that is part of the recommended setup:

- MCP server: [GitHub - oOo0oOo/lean-lsp-mcp: Lean Theorem Prover MCP](https://github.com/oOo0oOo/lean-lsp-mcp)

For using all of this with [Claude Code Agent Skills](https://code.claude.com/docs/en/skills)

- Skills integration: [GitHub - cameronfreer/lean4-skills: Claude skills for Lean 4 theorem proving](https://github.com/cameronfreer/lean4-skills/tree/main)

**My experience with SWI-Prolog and Claude Code**

After exploring the [LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/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](https://code.claude.com/docs/en/common-workflows#use-plan-mode-for-safe-code-analysis) 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.
> 
> ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/0/085f8723811f40c3541032056c3b33c73a5b9d4c.png)
> 
> 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.

---

<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 11, 2025, 10:14pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/6 "2025-12-11T22:14:43Z")

</div>

The following is a Claude generated plan. Plans are created using markdown and the exact file contents of the plan are pasted below, no changes needed since Discourse can display the markdown.

The plan was created in VScode with [Claude Code for VS Code](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code)  
Model: Opus 4.5  
Plan mode: active  
Thinking: On

In my workflow after the changes are working as expected, including changes needed that were not in the plan, I run a skill that checks my current local skills and if anything was learned that may be of value as a new skill or addition to existing skills will create a plan to add/update the local skills.

Thus Claude learns new skills from my mistakes, fixing overlooked details, etc.

* * *

* * *

# Plan: Add Directive Filtering to prolog\_coverage\_ai

## Summary of Changes

| File | Change |
| --- | --- |
| `lib/prolog_coverage_ai.pl` | Rename module, add `skip_directive_clauses/1` option, modify `line_annotation` |
| `scripts/run_coverage_tests.pl` | Import local module, use new option |

## Goal

Create a local copy of `prolog_coverage.pl` renamed as `prolog_coverage_ai` module, with a new option to filter out `###` (uncovered) annotations for `persistent/1` directives.

## Problem Analysis

The `persistent/1` directive uses term expansion to generate multiple predicates at compile time. The coverage system sees:

1. The directive itself - marked as `###` (never “executed” at runtime)
2. The generated predicates - these ARE executed and show `++N` counts

The `###` is misleading since directives aren’t runtime-executed code.

## Call Chain for `###` Annotations

```prolog
show_coverage/1 (line 280)
  └─ file_coverage/3 (line 313)
       └─ file_details/4 (line 427)
            └─ detailed_report/4 (line 723)
                 └─ line_annotation/4 (line 745) ← Creates ### annotation

```

Key code at line 745-748:

```prolog
line_annotation(File, uncovered, Clause, Annotation) :-
    !,
    clause_or_set_source_location(Clause, File, Line),
    Annotation = (Line-ansi(error,###))-3.

```

## Implementation Plan

### Step 1: Rename Module

- Change module declaration from `prolog_coverage` to `prolog_coverage_ai`
- File: `lib/prolog_coverage_ai.pl`

### Step 2: Add New Option

Add option `skip_directive_clauses(+Predicates)` where Predicates is a list like `[persistent/1]`.

**2a. Update predicate\_options declaration (~line 138):**

```prolog
:- predicate_options(show_coverage/1, 1,
                     [ ...existing options...,
                       skip_directive_clauses(list) % NEW
                     ]).

```

**2b. Update module documentation (~line 256, after the annotation table):**  
Add to the show\_coverage/1 documentation:

```prolog
% - skip_directive_clauses(+Directives)
% A list of Directive/Arity terms. Clauses whose source line
% contains a matching directive (e.g., `:- persistent(...)`) will
% not be marked with `###` even if uncovered. This is useful for
% term-expanding directives like persistent/1 where the directive
% itself is not runtime code but generates runtime predicates.
% Example: `skip_directive_clauses([persistent/1])`

```

### Step 3: Modify line\_annotation/4 (line 745)

Add a clause that checks if we should skip this uncovered clause:

```prolog
line_annotation(File, uncovered, Clause, Annotation, Options) :-
    option(skip_directive_clauses(Directives), Options, []),
    Directives \== [],
    clause_is_directive(Clause, File, Directives),
    !,
    fail. % Skip this clause - no annotation generated
line_annotation(File, uncovered, Clause, Annotation, _Options) :-
    !,
    clause_or_set_source_location(Clause, File, Line),
    Annotation = (Line-ansi(error,###))-3.

```

### Step 4: Add Helper Predicate clause\_is\_from\_directive/3

```prolog
%% clause_is_from_directive(+Clause, +File, +Directives) is semidet.
% True if Clause's source line matches a directive pattern.
% Directives is a list like [persistent/1, discontiguous/1].
clause_is_from_directive(Clause, File, Directives) :-
    clause_or_set_source_location(Clause, File, Line),
    catch(file_line_text(File, Line, LineText), _, fail),
    member(Directive/_Arity, Directives),
    format(atom(Pattern), ':- ~w(', [Directive]),
    sub_atom(LineText, _, _, _, Pattern).

%% file_line_text(+File, +LineNo, -Text) is det.
% Read specific line from file. Uses file_text/2 already in module.
file_line_text(File, LineNo, Text) :-
    file_text(File, String),
    split_string(String, "\n", "", Lines),
    nth1(LineNo, Lines, Text).

```

**Note** : The `file_text/2` predicate already exists in the module (line 888) for reading file content.

### Step 5: Thread Options Through Call Chain

Predicates needing modification to pass Options:

1. **detailed\_report/4** (line 723) - already has Options, passes to line\_annotation
2. **line\_annotation/4** (line 745) - change to line\_annotation/5 with Options param

The `convlist/3` calls at lines 726-727 need updating:

```prolog
% Before:
convlist(line_annotation(File, uncovered), Uncovered, Annot1),

% After:
convlist(line_annotation(File, uncovered, Options), Uncovered, Annot1),

```

Note: `convlist/3` uses a goal with arity N, calling it with N+2 args. So `line_annotation/5` works as `line_annotation(File, uncovered, Options)` + 2 args from convlist = 5 args total.

### Step 6: Update run\_coverage\_tests.pl

Change import and add new option:

```prolog
:- use_module('lib/prolog_coverage_ai').

% In show_coverage_safe/1:
show_coverage([color(false), skip_directive_clauses([persistent/1]) | Options])

```

## Files to Modify

1. `lib/prolog_coverage_ai.pl` - Main changes (rename + new filtering)
2. `scripts/run_coverage_tests.pl` - Use local module with new option

## Testing

Run: `swipl scripts/run_coverage_tests.pl 2>&1 | tee coverage_test_results.log`  
Verify: `cov/introspection_engine.pl.cov` no longer shows `###` for `persistent/1` lines

* * *

* * *

Here is an example of things I missed in the plan or just in situational awareness

1. Noting that the test take 10 minutes to run, so in inspecting the command added as a reply.

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/5/582427e78378a307c49fee2ddd01f476760ce0ab.png)

1. Forgot to check my token usage which ran out in the middle of running the tests. Normally I will not reply which leaves the process ready to go once the limit resets. Resuming a session for token limit reached can sometimes use 5% of all tokens, ouch.

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

1. Should have noted in the plan that I would manually run the test and check the results. Doing so stops the AI from wasting tokens in a loop checking for the test to end.

2. Should have switched the LMM model from Opus 4.5 to the cheaper model Sonnet 4.5 which is easily capable of doing the code changes and using a lot less tokens and turning thinking off.

In checking the `cov` file to verify that the ### are filtered out for persistent/1 directives

```prolog
   90 ++20 ⮰
      ++4,727 ⮰
      ++21,486 ⮰
      +55,950-20 :- persistent(pred_def(name:atom, arity:integer, module:atom, file:atom, line:integer)).

```

the code works as expected.

However since my knowledge of all of the places where this specific case would be of use more generally, or adjusted as needed, I do not plan to submit a PR.

Also since there is nothing that would be new as a Claude skill will skip running the check for possible skills.

[prolog\_coverage\_ai.pl](https://swi-prolog.discourse.group/uploads/short-url/7vPDzGtvEQeWRRbLkanF4fknlSe.pl) (45.8 KB)

---

<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

---

<div class="post-metadata">

**Author:** ![bauhaus911](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bauhaus911](https://swi-prolog.discourse.group/u/bauhaus911)\
**Post date:** [December 14, 2025, 10:07pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/9 "2025-12-14T22:07:23Z")

</div>

> [@EricGT](#):
>
> can

Here is my experience creating a python app that communicated with a SWI-Prolog database that used a local (running on my game gpu) llm via ollama to make queries on my Prolog knowledge base. I’m a retired s/w dev but have only a beginner level of experience in Python and zero expertise with Prolog. Claude Code wrote it all for me (Sonnet 4.x). This was pre-skills.

> **[Boosting performance of local AI models](https://www.linkedin.com/pulse/boosting-performance-local-ai-models-bart-jenkins-g18ye/?trackingId=ADEycbW4a%2BgvrI9eCP9yOw%3D%3D)**
>
> Can you combine open-source AI models with another technology to boost their reasoning performance in consumer hardware? TL;DR--Answer is Yes. Now that I have lots of time on my hands (companies are not beating a path to my door), I wanted to explore...

I need to circle back around and see where skills might fit in (and plans).

---

<div class="post-metadata">

**Author:** ![abaljeu](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/abaljeu/32/136_2.png) [@abaljeu](https://swi-prolog.discourse.group/u/abaljeu)\
**Post date:** [December 15, 2025, 2:20pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/10 "2025-12-15T14:20:38Z")

</div>

I hadn’t read about Claude Skills before, so thanks for the tip. I use Claude Code often. I deliberately don’t use Plan Mode. I’ve found it just makes things harder, and the easier way is to ask Claude to write a plan while in Agent mode. Then I just get a text file, and I can more easily review and edit the plan.

---

<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 15, 2025, 9:48pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/11 "2025-12-15T21:48:05Z")

</div>

Seems that OpenAI may be implementing Plans and skills for Codex.

> <https://github.com/openai/codex/blob/2c6995ca4dfc23b93db311b59c1b4ead464658b1/docs/skills.md>

> **[Plan / Spec Mode · openai codex · Discussion #7355](https://github.com/openai/codex/discussions/7355)**
>
> The Codex team has received many requests for some form of a planning or spec’ing mode. We’ve been experimenting with several concepts internally, and before we finalize a design, we’d love to get ...

---

<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 15, 2025, 9:56pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/12 "2025-12-15T21:56:17Z")

</div>

> [@abaljeu](#):
>
> Then I just get a text file, and I can more easily review and edit the plan.

FYI - Plan mode will create a markdown file in `~/.claude/plans`. It creates a new name of three words not related to the plan and will reuse/overwrite the plan if a new plan is created in the same conversation. However if you check for the latest timestamp of file in the directory right after you create a plan, you can look at it, e.g. in VS Code with a markdown extension that has a preview mode.

I often copy the plan files into a coding project as part of a Git feature branch.

---

<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 20, 2025, 8:07pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/13 "2025-12-20T20:07:02Z")

</div>

The latest Claude Code update adds some LSP changes

- Added LSP (Language Server Protocol) tool for code intelligence features like go-to-definition, find references, and hover documentation

> **[Release v2.0.74 · anthropics/claude-code](https://github.com/anthropics/claude-code/releases/tag/v2.0.74)**
>
> What's changed
> 
> Added LSP (Language Server Protocol) tool for code intelligence features like go-to-definition, find references, and hover documentation
> Added /terminal-setup support for Kitty, Ala...

---

<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 22, 2025, 3:53pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/14 "2025-12-22T15:53:56Z")

</div>

The official pages for Skills from Anthropic and OpenAI and the open standard.

## Open Standard - Agent Skills

> **[Overview - Agent Skills](https://agentskills.io/home)**
>
> A simple, open format for giving agents new capabilities and expertise.

## Anthropic

> **[GitHub - anthropics/skills: Public repository for Agent Skills](https://github.com/anthropics/skills)**
>
> Public repository for Agent Skills

## OpenAI

> **[Agent Skills](https://developers.openai.com/codex/skills)**
>
> Give Codex new capabilities and expertise

---

<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:** [March 13, 2026, 5:47am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/15 "2026-03-13T05:47:06Z")

</div>

> [@Progressing the SWI-Prolog environment](https://swi-prolog.discourse.group/t/progressing-the-swi-prolog-environment/9090/62):
>
> Claude however managed to find a dirty but simple and effective work around.

Are you using separate so called memory files to keep track of what Claude learns that is of value?

* * *

**Using a Memory File with Claude in IDE Projects**

When working in a project folder with an IDE, keep a `MEMORY.md` file in the project root alongside a `.claude/CLAUDE.md` file. The `CLAUDE.md` should instruct Claude to update `MEMORY.md` whenever it learns something significant that has been verified — for example, by successfully running a test.

A few things to be aware of: Claude may also create and use `CLAUDE.md` and/or `MEMORY.md` at the user account level (e.g., `~/.claude/`) rather than inside the project folder. To confirm which files are being updated, watch the file paths during writes, or simply read the files directly since they’re standard markdown.

When set up correctly, this approach keeps Claude focused on the current problem and what has already worked, preventing it from backtracking — and ensuring that key context isn’t lost during session compression.

* * *

**Model Notes**

Claude Haiku 4.5 now handles SWI-Prolog at a solid basic level, making it a good daily driver for routine coding tasks. For planning or serious debugging, Sonnet or Opus is still the better choice — but Haiku 4.5 is notably more token-efficient for everyday use.

ChatGPT can also work with SWI-Prolog, though it generally requires more scaffolding and prompting to get comparable results. That said, it’s worth exploring if you’re spending more time in that ecosystem.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 13, 2026, 8:50am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/16 "2026-03-13T08:50:31Z")

</div>

> [@EricGT](#):
>
> Are you using separate so called memory files to keep track of what Claude learns that is of value?

No. As yet, I’m a very basic user. I just run `claude` in a terminal and so far used it to fix two C level issues in xpce by pointing it at the function and telling it how it misbehaved. One was a possible loop in PceEmacs dabbrev expansion after the code had been extended to include multiple candidate sources. It correctly found the cause, came with a patch that made the already too complex code even more complex and thus I restructured the code and had it reviewed by Claude. It agreed. Not sure how valuable that is … The other was the file dialog issue on Windows. I told it the behaviour and the fact that the code worked using SDL3.2 and no longer on SDL3.4. It crunched for 15 mn, analysing the SDL3 changes, issue reports on SDL and the xpce code. Found it was a known problem with a still open PR. Figured out how to work around it in the xpce code by checking the misspelled SDL error message as a fake (error) callback that could be ignored. Not bad (at all).

The main problem is that it keeps asking questions on which commands to run. I’ll put it in a Docker container with minimal rights based on VSCode integration using Docker.

For now, my conclusion based on this and your contributions using Claude is that it is quite capable of fixing things, but it often does so in an ugly way, making the code less rather than more maintainable. Of course, that is now. In a year’s time it might be very different.

---

<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:** [March 13, 2026, 11:18am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/17 "2026-03-13T11:18:00Z")

</div>

> [@jan](#):
>
> Found it was a known problem with a still open PR.

It’s worth noting in a project memory file that searching for known issues (both open and closed) and PRs is recommended when bug fixing by giving the path to the issue page and noting to use search when needed.

> [@jan](#):
>
> The main problem is that it keeps asking questions on which commands to run

I don’t encounter this issue personally. I use VSCode with both the OpenAI Codex and Anthropic’s Claude Code extensions active via the in IDE chat window so they can see the entire project. I also have several different terminals available:

- Windows Command Prompt
- Git Bash
- MSVC build environment (based on Windows Command Prompt)
- Windows PowerShell (user and admin)
- MSYS2

I do regularly run into problems where the AI can not find the command because it can not be found via the PATH variable in which case I just give the fill path to the command in the memory file.

> [@jan](#):
>
> I’ll put it in a Docker container with minimal rights based on VSCode integration using Docker.

I don’t run AI tools in containers beyond those that the AI tools themselves set up during installation. I do know that Claude Code has a virtual machine setup (rootfs.vhdx) as a safe environment, which requires 9.7 GB of disk space.

> [@jan](#):
>
> it often does so in an ugly way

[Skills](https://support.claude.com/en/articles/12512176-what-are-skills) are one way to get generated code to change. However, skills are tricky to setup properly, and having too many active can cause them to interfere with each other. I also avoid creating or modifying skills while working on anything requiring planning or debugging, as they complicate the process.

* * *

**Have you tried using plan mode?** [Plan mode](https://code.claude.com/docs/en/common-workflows#use-plan-mode-for-safe-code-analysis) has a nice benefit: it shouldn’t modify any files and will create a markdown document that serves as a starting point for changes such as bug fixes or feature branches. I’ve only seen plan mode modify a file when I explicitly noted during the plan that files should be updated—so that was my own mistake.

* * *

If you have questions or such just ask in the forum or in a private message. 🙂

---

<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:** [March 13, 2026, 12:25pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/18 "2026-03-13T12:25:07Z")

</div>

FYI

# Anthropic Sandbox Runtime (srt)

A lightweight sandboxing tool for enforcing filesystem and network restrictions on arbitrary processes at the OS level, without requiring a container.

`srt` uses native OS sandboxing primitives (`sandbox-exec` on macOS, `bubblewrap` on Linux) and proxy-based network filtering. It can be used to sandbox the behaviour of agents, local MCP servers, bash commands and arbitrary processes.

> **[GitHub - anthropic-experimental/sandbox-runtime: A lightweight sandboxing tool for enforcing...](https://github.com/anthropic-experimental/sandbox-runtime)**
>
> A lightweight sandboxing tool for enforcing filesystem and network restrictions on arbitrary processes at the OS level, without requiring a container.

---

<div class="post-metadata">

**Author:** ![thetyster](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/thetyster/32/7929_2.png) [@thetyster](https://swi-prolog.discourse.group/u/thetyster)\
**Post date:** [April 15, 2026, 3:46pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/19 "2026-04-15T15:46:25Z")

</div>

Hello! New to Prolog and new to the forum.

Over the last few months I’ve become obsessed with Prolog and Lean4 as logical modelers and provers. I spend a few hours each week combing through the internet trying to find others who are using these languages with modern LLMs.  
@EricGT as far as I know, you are the only person in the world who has a [public repository](https://github.com/EricGT/SWI-Prolog-skills) using the words ‘prolog’ and ‘skills’ together aimed at assisting LLMs. I’m very interested in learning more about what you’ve been working on.

Presently, my work with llms (recently mostly anthropic models) has been focused on getting these models to do two things well; three things adequately:

1. Create a knowledge base describing an existing logical system. Where applicable to codebases, use the C4 model as an ontology. (still refining this)
2. Use Prolog as a chain-of-thought reasoning step to explore a hypothesis related to the existing logical system.
3. Prove a hypothesis if possible. (this is currently working better with lean)

I have been amazed at how effective my earliest attempts at using this process with production code has been.

That said, I have so much to learn still. Specifically, when it comes to the Prolog language or using the SWI-Prolog tools.

I am interested in anything which can help an llm to:

- Write more sustainable Prolog knowledge bases.
- Express logical systems with incrementally more granularity.
- Help llms write better queries.  
-Help llms create stronger proofs (seems to be fundamentally tied to a good predicate system hence using C4 ontologies sometimes (WIP))

Right now, my Agent Skills have a SWI-Prolog reference wiki attached to them. This was generated with Haiku. Here is what I have in the index:

* * *

| Extension | Problem It Solves | Enable With |
| --- | --- | --- |
| Tabling | Infinite loops & redundant recomputation in recursion | `:- table pred/arity.` |
| CLP(FD) | Constraint satisfaction over integers | `:- use_module(library(clpfd)).` |
| CLP(B) | Boolean satisfiability & counting | `:- use_module(library(clpb)).` |
| CLP(Q/R) | Constraints over rationals/reals | `:- use_module(library(clpq)).` or `library(clpr)` |
| Modules | Namespace collisions in large programs | `:- module(Name, [Exports]).` |
| DCG | Verbose parsing/grammar code | `-->` notation (built-in) |
| Coroutining | Goals evaluated before bindings are ready | `freeze/2`, `when/2`, `dif/2` (built-in) |
| Attributed Variables | Attaching metadata to unbound variables | `put_attr/3`, `get_attr/3` (built-in) |
| Meta-predicates | Collecting/transforming multiple solutions | `library(apply)`, `library(aggregate)` |
| Threading | Single-threaded bottlenecks | `library(thread)` |
| Dynamic Predicates | Runtime knowledge base modification | Built-in |
| Dicts | Key-value data structures | Built-in (SWI 7+) |
| Persistency | Persisting dynamic predicates to disk | `:- use_module(library(persistency)).` |
| HTTP/JSON | Web I/O and structured data | `library(http/json)`, `library(http/http_server)` |
| PCRE | Regular expressions | `:- use_module(library(pcre)).` |
| Record | Named compound term accessors | `:- use_module(library(record)).` |
| Option Lists | Handling keyword-style options | `:- use_module(library(option)).` |
| Debugging | Debug messages, profiling, clause inspection | `library(debug)` |
| Pack System | Installing third-party libraries | `pack_install/1` (built-in) |

In my experience, the best Agent skills work like stateless functions. They do one thing well.  
Other ‘parent’ skills focus on chaining together these ‘atom skills’ into viable workflows.

I have lots of information and knowledge gaps in this domain. But, I would very much like to collaborate on any skills which improve generated prolog. Especially for the purposes of use as a Chain of Thought reasoning tool for AI.

@EricGT:

1. Have you created any Agent skills which might help LLMs with using Prolog KBs in CoT reasoning or problem analysis? If so, would you mind sharing?
2. Are there any particular strategies which have worked well for you in helping LLMs approach Prolog KBs and proofs?

---

<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:** [April 15, 2026, 6:49pm UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/20 "2026-04-15T18:49:23Z")

</div>

I explored something similar several months ago with SWI-Prolog skills. One issue I ran into was token overhead: loading a large set of skills (~80) consumed tokens just to process the frontmatter. Because of that, I moved away from keeping many skills preloaded.

My current approach is more selective:

- pass a skill as a file when needed (explicitly noting it is a skill), or
- convert the skill into a slash command

I still think skills are essential, but the ergonomics around how they are loaded and accessed likely need refinement.

I also looked briefly at plugins and agent-style packaging. For my use case, they mainly acted as a distribution layer for skills and slash commands. That is useful, but it did not justify the added complexity relative to just invoking what I need directly.

On model usage, I tend to be conservative with tokens:

- use Haiku for routine SWI-Prolog tasks and mixed-language work
- switch to Opus (with thinking enabled) for complex planning, then return to Haiku for execution

For harder planning tasks, it is easy to exhaust a multi-hour token budget very quickly.

More recently, instead of relying heavily on skills, I often pass URLs to relevant SWI-Prolog documentation pages. This uses more tokens, but it is generally more reliable when a skill is incomplete or out of date.

One idea I raised to Jan Wielemaker was a built-in predicate similar to SWI-Prolog [apropos/1](https://www.swi-prolog.org/pldoc/man?predicate=apropos/1) predicate, but designed to produce structured, LLM-friendly output. That would keep results aligned with the exact SWI-Prolog version in use.

Drift is a real issue with external skills—especially as syntax and libraries evolve (e.g., SDL3 integration, dict changes). Maintaining skills started to feel like a side project, and in some cases became a distraction. Some skills are still useful, but the maintenance cost is non-trivial.

A related issue is that LLM capability tends to improve in discontinuous jumps. Skills that were previously necessary can become redundant or even counterproductive unless they are continuously updated. There is a kind of impedance mismatch here: both the LLM and SWI-Prolog evolve, so alignment becomes an ongoing effort rather than a one-time solution.

Conceptually, I do not frame Prolog as a chain-of-thought mechanism for LLMs. I start from the problem domain and choose tools accordingly:

- SWI-Prolog where logic programming fits
- DCGs for parsing
- constraint solvers such as Z3 where appropriate
- graph or ontology approaches when structure matters
- meta-interpreters when control over reasoning is required

LLMs are one component in that toolbox, not the organizing principle.

* * *

> [@thetyster](#):
>
> Have you created any Agent skills which might help LLMs with using Prolog KBs in CoT reasoning or problem analysis?

Not specifically at that level. I tend to use plans realizing that they are one time usage.

> [@thetyster](#):
>
> Are there any particular strategies which have worked well for you in helping LLMs approach Prolog KBs?

Covered in my earlier responses.

> [@thetyster](#):
>
> Are there any particular strategies which have worked well for you in helping LLMs approach proofs?

I am not currently working on proofs in Lean 4. However, I do occasionally follow developments on the [Lean forum](https://leanprover.zulipchat.com/) to stay informed.

* * *

If you have more questions or want feedback on an idea, feel free to post here.

---

<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:** [April 24, 2026, 10:28am UTC](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420/21 "2026-04-24T10:28:01Z")

</div>

[An update on recent Claude Code quality reports](https://www.anthropic.com/engineering/april-23-postmortem)

[Next page](https://swi-prolog.discourse.group/t/using-claude-code-to-create-skills-commands-plans-for-swi-prolog/9420.md?page=2)
