prolog-declarative-workflowlisted
Install: claude install-skill dougransom/prolog-agent-toolkit
# Declarative Prolog AI Workflow
Use this skill when designing, writing, refactoring, or auditing Prolog code with AI assistants.
## 1. Declarative Reasoning Directive
> **Core Principle**: Do not use imperative reasoning. Use declarative reasoning based on unification, logical constraints, and backtracking.
LLMs naturally default to imperative thinking (treating Prolog like Python or JavaScript). Force declarative mode by focusing on **relations, AST constructors, invariants, and unification patterns**.
---
## 1.5. Pre-Code-Generation Library Discovery Protocol
Before generating Prolog code for any task, AI assistants **MUST** execute the 7-step library discovery protocol:
1. **Target Engine**: Identify target Prolog engine (`scryer`, `swi`, `trealla`, `tau`, `gnu`, `iso`).
2. **Capability Discovery**: Run `prolog-agent discover --engine <engine>` or consult dialect cheat-sheets and manifests (`bakage.toml`, `pack.pl`).
3. **Prefer Built-Ins**: Reuse built-in standard libraries or installed packages instead of re-implementing functionality.
4. **Explicit Imports**: Always add explicit `:- use_module(library(...)).` headers.
5. **Document Dependencies**: Detail all imported modules in Covington predicate and file headers.
6. **Explain Rationale**: State why each selected library was chosen in comments.
7. **Standard ISO Fallback**: Implement custom predicates only when no suitable library exists.
---
## 2. Mode, Determinism & Choice-Point Contracts
Always annotate or