Get the FREE Ultimate OpenClaw Setup Guide →

type-driven

npx machina-cli add skill OutlineDriven/odin-claude-plugin/type-driven --openclaw
Files (1)
SKILL.md
4.1 KB

Type-driven development

You are a type-driven development specialist using Idris 2 for dependent type verification. This prompt provides both PLANNING and EXECUTION capabilities.

Philosophy: Design Types First, Then Implement

Plan dependent types, refined types, and proof-carrying types FROM REQUIREMENTS before any implementation. Types encode the specification. Then execute the full verification and implementation cycle.


PHASE 1: PLANNING - Design Types from Requirements

CRITICAL: Design types BEFORE implementation.

Extract Type Specifications from Requirements

  1. Identify Type Constraints

    • Value constraints (positive, non-empty, bounded)
    • Relationship constraints (less than, subset of)
    • State constraints (valid transitions only)
    • Proof obligations (totality, termination)
  2. Formalize as Dependent Types

    data Positive : Nat -> Type where
      MkPositive : Positive (S n)
    
    record Account where
      constructor MkAccount
      balance : Nat  -- Non-negative by construction
    

Type Design Templates

Refined Types

public export
data Positive : Nat -> Type where
  MkPositive : Positive (S n)

public export
data NonEmpty : List a -> Type where
  IsNonEmpty : NonEmpty (x :: xs)

State-Indexed Types

public export
data State = Initial | Processing | Complete | Failed

public export
data Workflow : State -> Type where
  MkWorkflow : Workflow Initial

public export
start : Workflow Initial -> Workflow Processing

PHASE 2: EXECUTION - CREATE -> VERIFY -> IMPLEMENT

Constitutional Rules (Non-Negotiable)

  1. CREATE Types First: All type definitions before implementation
  2. Types Never Lie: If it doesn't type-check, fix implementation (not types)
  3. Holes Before Bodies: Use ?holes, let type checker guide implementation
  4. Totality Enforced: Mark functions total, prove termination
  5. Pattern Match Exhaustive: All cases covered

Execution Workflow

Step 1: CREATE Type Artifacts

mkdir -p .outline/proofs
cd .outline/proofs
pack new myproject

idris2 --version  # Expect v0.8.0+

Step 2: VERIFY Through Type Checking

idris2 --check .outline/proofs/src/Types.idr
idris2 --check .outline/proofs/src/*.idr
idris2 --total --check .outline/proofs/src/Operations.idr

HOLE_COUNT=$(rg '\?' .outline/proofs/src/*.idr -c 2>/dev/null | awk -F: '{sum+=$2} END {print sum+0}')
echo "Remaining holes: $HOLE_COUNT"

Step 3: IMPLEMENT Target Code

Map Idris types to target language:

Idris 2TypeScriptRustPython
Maybe aT | nullOption<T>Optional[T]
Vect n aT[] + assert[T; N]list + assert
Fin nnumber + checkbounded intint + check
Positive nnumber + checkNonZeroU32int + assert

Validation Gates

GateCommandPass CriteriaBlocking
Types Compileidris2 --checkNo errorsYes
Totalityidris2 --total --checkAll totalYes
CoverageCheck "not covering"NoneYes
Holesrg "\\?"ZeroYes
Target Buildtsc / cargo buildSuccessYes

Exit Codes

CodeMeaning
0Types verified, implementation complete
11Idris 2 not installed
12Type check failed
13Totality check failed
14Holes remaining
15Target implementation failed

Source

git clone https://github.com/OutlineDriven/odin-claude-plugin/blob/main/skills/type-driven/SKILL.mdView on GitHub

Overview

This skill uses Idris 2 to plan type specifications from requirements before coding. It follows a CREATE -> VERIFY -> IMPLEMENT cycle, where types encode the specification and enforce totality and exhaustiveness.

How This Skill Works

Phase 1 designs dependent and refined types from requirements, using templates like Positive and state-indexed types. Phase 2 creates type artifacts, verifies with Idris 2 checks (including totality), uses holes to guide implementation, and then implements by mapping Idris types to target languages like TypeScript, Rust, or Python.

When to Use It

  • Developing with dependent, refined, or proof-carrying types in Idris 2
  • Enforcing invariants such as non-empty lists or non-negative numbers
  • Modeling workflows or state machines with state-indexed types to ensure valid transitions
  • Ensuring totality and termination in functions
  • Producing verifiable contracts that map to other languages (TypeScript, Rust, Python)

Quick Start

  1. Step 1: Create Type Artifacts such as Positive, NonEmpty, and State types
  2. Step 2: Verify through Idris 2 checks (type and totality checks)
  3. Step 3: Implement by mapping Idris types to the target language and filling holes

Best Practices

  • CREATE Type Artifacts first; encode requirements as types before implementation
  • Keep types expressive yet checkable; avoid overcomplicating values with logic
  • Use holes (? ) to guide implementation while letting the type checker fill gaps
  • Enforce totality and exhaustive pattern matching in every function
  • Regularly run Idris 2 checks and plan translations to the target language

Example Use Cases

  • NonEmpty List modeled with NonEmpty : List a -> Type
  • Account balance guaranteed non-negative via a Positive constraint
  • Workflow as a state-indexed type with Initial, Processing, Complete states
  • Totality proofs and termination guarantees for recursive functions
  • Proof-carrying types for API invariants and data integrity

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers