IID.systems
ProfileServicesFormal MethodsAI AlignmentEssaysBookSchoolGitHub日本語
日本語
Reference

Skills Reference

Complete reference for all 15 skills in the Formal Agent Contracts plugin. Includes both the forward pipeline (define → verify → prove → generate → test + import/export) and the reverse pipeline (extract true specs from existing code).

Overview

SkillPurposeVersionRequires
define-contractNatural language → VDM-SL specv2.0.0
verify-specSyntax/type check + PO generationv2.0.0VDMJ
smt-verifyPO → SMT-LIB → Z3 provingv0.2.0Z3
generate-codeVDM-SL → TypeScript/Pythonv0.4.0
generate-testsVDM-SL + design docs → contract testsv2.1.0Node.js + Vitest/Jest
generate-db-schemaVDM-SL types/invariants → DB schema (DDL)v2.1.0sqlite3 / PostgreSQL (optional)
route-modelsContract complexity → per-module model tierv1.0.0
integrated-workflowFull pipeline orchestrationv2.1.0VDMJ (Z3 optional)
formal-methods-guideVDM-SL reference knowledgev0.1.0
import-natural-specMarkdown spec → VDM-SL (interactive)v1.0.0
export-human-specVDM-SL → human-readable Markdownv1.0.0

define

define-contract

v2.0.0

Interactively converts natural language requirements into VDM-SL formal specifications and Phase 2 design documents (PROTOCOL.md, API-SIGNATURES.md) through a guided dialogue.

Trigger phrases:

"Define an agent contract""Formalize the interface between agents""Write a contract for...""I need a spec for..."

Workflow steps:

  1. Gather agent information — name, role, inputs, outputs, relationships
  2. Generate type definitions — map natural language to VDM-SL types
  3. Define operations and contracts — capture pre/post/inv through questions
  4. Generate the VDM-SL specification — complete module with all definitions
  5. Review and iterate — present spec for user validation

Output:

.vdmsl specification file + design documents (PROTOCOL.md, API-SIGNATURES.md)

Built-in templates:

  • Transform Agent — stateless input/output conversion
  • CRUD Agent — create, read, update, delete with state
  • Pipeline Agent — sequential data processing stages
  • Mediator Agent — orchestrates multiple sub-agents
  • Validation Agent — input validation and sanitization
  • Design Document Template (v2.0.0) — Phase 2 protocol/API design documents
  • Hybrid Decision Agent (v2.0.0) — score-based compound decisions

verify

verify-spec

v2.0.0

Runs VDMJ syntax checking, type checking, and proof obligation generation on VDM-SL files, then explains results in plain language. Also checks design documents (PROTOCOL.md, API-SIGNATURES.md) for completeness and consistency with the spec.

Trigger phrases:

"Verify this specification""Check the spec for errors""Generate proof obligations""Type check this .vdmsl file"

Workflow steps:

  1. Locate VDM-SL files — find .vdmsl files in workspace
  2. Syntax and type checking — run VDMJ with error reporting
  3. Generate proof obligations — run VDMJ with -p flag
  4. Interpret and explain — translate each PO to plain language
  5. Categorize POs — rank by urgency (critical / standard / info)
  6. Suggest next steps — offer to proceed to SMT verification

Output:

PO list with natural language explanations, categorized by urgency

prove

smt-verify

v0.2.0

Converts proof obligations to SMT-LIB format and proves them with the Z3 solver. Reports results as proved, counterexample found, or unknown.

Trigger phrases:

"Prove the POs with Z3""Verify POs with SMT""Find counterexamples""Are these obligations provable?"

Workflow steps:

  1. Accept POs — from verify-spec output or direct input
  2. Generate type declarations — map VDM-SL types to SMT-LIB sorts
  3. Generate auxiliary definitions — invariants, pre/post as define-fun
  4. Convert PO expressions — transform VDM-SL logic to SMT-LIB formulas
  5. Negate and check-sat — reflexive verification: assert(not PO)
  6. Execute Z3 — run solver on each .smt2 file
  7. Interpret results — unsat=proved, sat=counterexample, unknown=timeout

Output:

.smt2 files and per-PO verification report

generate

generate-code

v0.4.0

Generates TypeScript or Python implementation scaffolds from VDM-SL specifications, with runtime contract enforcement for pre-conditions, post-conditions, and invariants.

Trigger phrases:

"Generate code from this spec""Convert to TypeScript""Generate Python code""Create an implementation"

Workflow steps:

  1. Read VDM-SL file — parse specification
  2. Confirm target language — TypeScript, Python, or both
  3. Transform types — map VDM-SL to target language types
  4. Generate type definitions — interfaces/dataclasses with invariants
  5. Generate contract code — validation functions for pre/post/inv
  6. Generate operation stubs — function scaffolds with contract wrappers
  7. Output files — save to generated/ directory

Output:

TypeScript (.ts) or Python (.py) files with runtime contracts

test

generate-tests

v2.1.0

Generates Jest/Vitest-compatible contract tests from VDM-SL specifications and design documents (PROTOCOL.md, API-SIGNATURES.md). Covers type invariants, pre/post-conditions, state transitions, and boundary values.

Trigger phrases:

"Generate tests from the spec""Create contract tests""Auto-generate tests""Generate boundary tests from the VDM spec"

Workflow steps:

  1. Read the VDM-SL spec and design documents — catalog invariants, contracts, protocol rules
  2. Generate type invariant tests
  3. Generate pre/post-condition tests
  4. Generate protocol tests from the design documents: message-type/payload consistency and state transitions (PROTOCOL.md), API signatures (API-SIGNATURES.md)
  5. Generate boundary value tests
  6. Output test files — Jest/Vitest compatible

Output:

Jest/Vitest contract test files

schema

generate-db-schema

v2.1.0

Derives a database schema (DDL) from VDM-SL types and invariants by numbered mapping rules (R1–R18) rather than free-writing. Records infidelities as a DEVIATIONS retrenchment table (e.g. nat→BIGINT, transition rules) and maps every invariant to its enforcement point in a TRACEABILITY matrix.

Trigger phrases:

"Generate a database schema from the spec""Derive tables from the VDM spec""Turn invariants into DB constraints""Design the data model"

Workflow steps:

  1. Parse the spec — identify persistent state: record types, quote unions, state components, invariants, atomic operations
  2. Confirm target DBMS (PostgreSQL/MySQL/SQLite) and naming conventions
  3. Apply mapping rules R1–R18: record→table, map state→keyed table, quote union→ENUM/CHECK, invariant→CHECK/UNIQUE/FK/trigger, atomic→transaction boundary
  4. Generate DEVIATIONS.md (retrenchment table) — record each infidelity with a concrete compensation (trigger / app-layer contract check / contract test)
  5. Generate TRACEABILITY.md — map every invariant and operation contract to its enforcement point; no unaccounted invariant allowed
  6. Validate the DDL (executable check for SQLite / psql / Docker) and completeness

Output:

schema.sql (DDL) + DEVIATIONS.md + TRACEABILITY.md

routing

route-models

v1.0.0

Scores each module from objective complexity signals in the VDM-SL contract (implicit definitions, invariants, quantifiers, recursion, cross-module dependencies, PO counts) and assigns the lightest capable model tier (light / standard / heavy). Produces a machine-readable model-routing.json and a rationale-backed MODEL-ROUTING.md, consumed by generate-code / generate-tests via per-module subagent execution. A module that fails verification twice escalates one tier automatically — quality is guaranteed by the verification gates.

Trigger phrases:

"Route models""Assign models per module""Reduce token cost"「モデルを割り振って」

Workflow steps:

  1. Read the spec and split it into modules
  2. Collect complexity signals per module (reusing a verify-spec PO report if available)
  3. Assign tiers via the scoring rubric (fast paths: types-only → light; any implicit definition → never light)
  4. Present the routing table for user confirmation with per-row overrides
  5. Write model-routing.json (next to the spec) and MODEL-ROUTING.md

Output:

model-routing.json (machine-readable, with the tier → model mapping) + MODEL-ROUTING.md (rationale and expected savings)

workflow

integrated-workflow

v2.1.0

Orchestrates the full pipeline — Define → Verify → Prove → Generate → Test — in a single guided session, with error recovery and session reporting.

Trigger phrases:

"Run the full workflow""End-to-end development""Define and generate code for an agent""Full pipeline for..."

Workflow steps:

  1. Session setup — gather agent name, starting point, target language, SMT toggle
  2. Phase 1: Define — invoke define-contract for VDM-SL generation
  3. Phase 2: Verify — invoke verify-spec for syntax/type/PO checks
  4. Phase 3: Prove (optional) — invoke smt-verify for Z3 proving
  5. Phase 4: Generate — invoke generate-code for TS/Python scaffolds
  6. Phase 5: Test — invoke generate-tests for contract tests, then run them
  7. Session report — comprehensive summary of all phases

Output:

Complete agent: .vdmsl + generated code + tests + session report

guide

formal-methods-guide

v0.1.0

Provides reference knowledge on VDM-SL syntax, type system, and all 38 proof obligation types. Acts as background knowledge for other skills.

Trigger phrases:

"Explain VDM-SL syntax""What is a pre-condition?""What does this PO mean?""Help me understand the types"

Workflow steps:

  1. Identify the concept — match user question to reference material
  2. Provide explanation — plain language with VDM-SL examples
  3. Link to context — connect to the user's current specification

Output:

Plain language explanations with code examples

import

import-natural-spec

v1.0.0

Reads a Markdown requirements document and interactively converts it to VDM-SL. Identifies ambiguities (vague quantifiers, missing error cases, implicit constraints, boundary conditions) and resolves them through structured dialogue.

Trigger phrases:

"Import a spec from Markdown""Convert requirements to VDM-SL""Formalize this requirements document""Turn this spec into VDM-SL"

Workflow steps:

  1. Read and parse the MD document — identify structure, headings, lists, tables
  2. Classify requirements — map each to types, constraints, operations, or rules
  3. Detect ambiguities — vague quantifiers, undefined terms, missing error cases, boundary conditions
  4. Interactive resolution — present ambiguities in priority order, resolve through dialogue
  5. Generate VDM-SL — produce tagged specification with [REQ-nnn] traceability
  6. Gap analysis — forward/backward/completeness checks
  7. Connect to pipeline — recommend verify-spec or refine-spec as next step

Output:

.vdmsl specification file with requirement traceability

export

export-human-spec

v1.0.0

Generates a structured natural language specification document (Markdown) from VDM-SL. Types become "what things exist", pre-conditions become "prerequisites", post-conditions become "guarantees". Designed for domain experts and non-technical stakeholders.

Trigger phrases:

"Generate documentation from VDM-SL""Create a readable specification""Export spec for stakeholder review""Convert VDM-SL to natural language"

Workflow steps:

  1. Read VDM-SL specification — catalog types, state, operations, invariants
  2. Ask about output preferences — audience, language, format, detail level
  3. Translate each construct — types→definitions, pre→prerequisites, post→guarantees
  4. Structure the document — overview, glossary, data model, operations, business rules
  5. Quality checks — completeness, faithfulness, readability, consistency
  6. Save and present — output as Markdown, suggest next steps

Output:

Structured Markdown specification document

Reverse Pipeline

NEW

A reverse pipeline for extracting specifications from existing codebases. The reverse-workflow skill orchestrates this:

Existing Code → Extract Provisional Spec → Dialogue Refinement → Code Reconciliation → (Can connect to forward pipeline)
SkillVersionPurpose
extract-specv1.1.0Extract a provisional VDM-SL spec from existing code. Tagged [PROVISIONAL] and presented as dialogue scaffolding
refine-specv1.2.0Use the provisional spec as a scaffold for dialogue with the user, uncovering the true specification. Differences recorded as Findings
reconcile-codev1.3.0Compare confirmed spec vs existing code item-by-item. Generate diff report, code fixes, and auto-tests
reverse-workflowv1.4.0Orchestrate the full reverse pipeline: Extract → Refine → Reconcile. Can connect to forward pipeline

Skill Pipeline

Skills can be used independently, but are designed to chain together. The integrated-workflow skill automates this pipeline: New in v2.0.0: Phase 2 design documents (PROTOCOL.md / API-SIGNATURES.md) and automatic contract test generation with generate-tests.

import-natural-specMD → VDM-SLdefine-contract.vdmslverify-specPOssmt-verifyproofsgenerate-codeTS / Pythongenerate-testscontract testsexport-human-specVDM-SL → readable MD