prolog-linter-static-analysislisted
Install: claude install-skill dougransom/prolog-agent-toolkit
# Prolog Static Analysis & Code Quality Guidelines
Use this skill to audit, lint, and analyze Prolog code for common errors, singleton variables, discontiguous clauses, non-deterministic performance issues, and non-logical constructs.
## 1. Common Linter Warnings & Remedies
| Issue / Warning | Cause | Recommended Solution |
| :--- | :--- | :--- |
| **Singleton variables** | Variable appears only once in a clause (often a typo or unreferenced value). | Prefix with `_` (e.g. `_Var`) or use anonymous variable `_`. |
| **Discontiguous predicate** | Clauses of the same predicate are separated by other predicates. | Group clauses together or add `:- discontiguous Name/Arity.` directive. |
| **Unknown predicate** | Calling a predicate that has not been defined or imported. | Add `:- use_module(...)` or correct predicate name/arity. |
| **Non-logical cut (`!`)** | Impure control flow masking logic bugs or disabling backtracking. | Replace with `if_/3` from `library(reif)` or pure `dif/2`. |
| **Negation-as-failure (`\+/1`) for inequality** | Using `\+ (X = Y)` or `\+ Goal` to express inequality on potentially uninstantiated terms (unsound). | Replace with pure `dif(X, Y)` constraint. |
| **Defaulty Representation** | Data element kinds cannot be distinguished by principal functor (forcing `var/1` or catch-all default clauses). | Wrap elements in distinct principal functors (e.g. `leaf(X)`, `node(L, R)`). Convert external defaulty data early at boundaries. |
| **Mis-typed Neck Oper