Skip to content
Back to skills

Swi Prolog Standards

ASecurity

Coding standards and guidelines for SWI-Prolog applications and scripts. Use when targeting SWI-Prolog specifically.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 1, 2026
ai-agentsgotesting

Works with

  • terminal

Security analysis

A100/100

Scanned October 1, 2026

npx -y skills add dougransom/prolog-agent-toolkit --skill swi-prolog-standards --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swi Prolog Standards?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swi Prolog Standards
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dougransom-swi-prolog-standards/badge)](https://www.skillsdirectory.com/skills/dougransom-swi-prolog-standards)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swi-prolog-standards
description: Coding standards and guidelines for SWI-Prolog applications and scripts. Use when targeting SWI-Prolog specifically.
---

# SWI-Prolog Standards

Guidelines for writing idiomatic SWI-Prolog code:

## Core Rules

1. **Modules**: Define clear module headers with `:- module(name, [exports...]).`.
2. **Data Structures**: Utilize SWI dicts (`_{key: Value}`) and SWI strings where appropriate for modern SWI applications.
3. **Packs & Libraries**: Manage external packages using SWI-Prolog `pack_install/1`.
4. **Library Cheat-Sheet Usage**: Use the Standard Library Cheat Sheet below for module imports; do NOT read raw system library files unless working with un-documented custom packages.
5. **Safety**: Always execute code using `swi-safe` or `prolog-safe` with `PROLOG_ENGINE=swi`.

## SWI-Prolog Standard Library Cheat Sheet

> **Universal Coding Standards Note**: The cheat sheet table below specifies SWI-specific module import headers (`:- use_module(library(...)).`) and built-ins. While SWI has system-specific module names (e.g. `library(clpfd)`, `library(yall)`), all underlying coding guidelines, purity rules, reification patterns (`=(X,Y,Truth)`, `cond_t`, `if_`), DCG syntax, safe type testing, and formatted output follow the **universal Prolog coding standards** defined in [`prolog-conventions`](../prolog-conventions/SKILL.md) and [`prolog_guidelines.md`](../../references/prolog_guidelines.md).

| Feature / Topic | Import Header | Primary Exported Predicates | Notes / System Rules |
| :--- | :--- | :--- | :--- |
| **CLP(FD) Constraints**| `:- use_module(library(clpfd)).` | `(#=)/2`, `in/2`, `label/1`, `labeling/2` | Integer constraints in SWI (SWI uses `clpfd`). |
| **Higher-Order Lambdas**| `:- use_module(library(yall)).` | `[X]>>...`, `[X,Y]>>Goal` | SWI built-in lambda syntax (`yall`). |
| **Higher-Order Apply**| `:- use_module(library(apply)).` | `maplist/2..5`, `include/3`, `exclude/3`, `foldl/4` | List mapping and filtering. |
| **DCG Basics** | `:- use_module(library(dcg/basics)).` | `string//1`, `integer//1`, `whites//0` | Common parsing non-terminals. |
| **Ordered Sets** | `:- use_module(library(ordsets)).` | `list_to_ord_set/2`, `ord_union/3` | Set operations on sorted lists. |
| **Unit Testing** | `:- use_module(library(plunit)).` | `:- begin_tests(name).`, `:- end_tests(name).` | Native SWI test harness. |
| **Dict Manipulation** | *Built-in* | `get_dict/3`, `put_dict/4`, `is_dict/1` | Native SWI dict support (`Dict.Key`). |

## Universal Guidelines & References

- [Covington Prolog Style Guide](../../references/covington_style.md)
- [Prolog Purity Guidelines](../../references/prolog_guidelines.md)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.