prolog-modules

Explain Prolog module declarations, imports, exports, and visibility for ISO/SWI projects.

1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/hafley66/claude-research --skill prolog-modules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prolog-modules
Source: https://github.com/hafley66/claude-research/tree/main/skills/prolog-modules
Command: npx skills add https://github.com/hafley66/claude-research --skill prolog-modules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Traditional Prolog environments use a global namespace which leads to predicate name collisions when multiple modules or libraries are loaded. This Skill explains how to design and use module declarations, import/export lists, and module visibility rules to keep code isolated and maintainable.

Core Features & Use Cases

  • Understand ISO vs SWI module semantics and common pitfalls.
  • Learn how to declare modules, export predicates, and selectively import from local files and libraries.
  • Apply best practices to avoid collisions in larger Prolog codebases, such as using qualified calls and explicit exports.
  • Use in educational contexts to teach module concepts and in production code to structure libraries.

Quick Start

Explain how to declare a module and export a predicate in SWI-Prolog.

Frequently Asked Questions about prolog-modules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid predicate name collisions in Prolog?

To avoid predicate name collisions in Prolog, use module systems to isolate code. Declare modules with explicit export lists and use qualified calls to maintain isolation in larger codebases.

How do I declare a module and export a predicate in SWI-Prolog?

In SWI-Prolog, declare a module using the module/2 directive, specify your export list within the brackets, and use use_module to import those predicates into other files or libraries selectively.

What is the difference between ISO and SWI Prolog module semantics?

ISO and SWI Prolog module semantics differ in visibility rules and import behavior. Understanding these distinctions helps prevent common pitfalls when structuring libraries across different Prolog environments.

How does use_module work for importing predicates in Prolog?

The use_module directive imports predicates from local files or libraries into your current Prolog module. It respects export lists, ensuring only declared predicates are visible to the importing module.

Can I use SWI-Prolog module declarations in SICStus Prolog?

SWI-Prolog module declarations can apply to SICStus Prolog contexts, but you must verify module visibility rules and meta-predicate requirements to ensure compatibility across both ISO and SWI environments.

What are the best practices for structuring large Prolog codebases with modules?

Best practices for structuring large Prolog codebases include using explicit exports, qualified calls, and strict module visibility. This prevents predicate collisions and keeps your libraries maintainable.