m05-type-driven

Encode invariants and workflow constraints in the type system at compile time.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill m05-type-driven-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m05-type-driven
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/rust-dev/skills/m05-type-driven
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill m05-type-driven-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Without strong type design, software can accidentally allow invalid states that slip through at runtime. By encoding invariants and workflow constraints in the type system, developers gain compile-time safety and clearer APIs.

Core Features & Use Cases

  • Type state patterns and phantom types enforce valid transitions and capabilities at compile time.
  • Newtype wrappers, marker traits, and builders encode constraints and invariants without runtime costs.
  • Use cases include domain modeling, API safety, and zero-cost abstractions that catch errors before they execute.

Quick Start

Create a validated newtype to wrap a primitive and enforce invariants at construction.

Frequently Asked Questions about m05-type-driven

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

FAQPage Schema
How do I use Rust type safety to prevent invalid states at compile time?

Use Rust type safety to prevent invalid states by encoding invariants directly in the type system. This approach leverages type-state patterns and phantom types to enforce valid transitions and capabilities during compilation, eliminating runtime checks.

What is the type-state pattern and how does it enforce compile-time guarantees?

The type-state pattern enforces compile-time guarantees by using phantom types and marker traits to represent an object's state. This ensures only valid state transitions compile, preventing invalid states from existing without runtime overhead.

How do I create a newtype wrapper in Rust to enforce domain invariants?

Create a newtype wrapper in Rust to enforce domain invariants by wrapping a primitive type in a struct and validating constraints at construction. This pattern encodes constraints without runtime costs, ensuring safe abstractions.

When should I use phantom types for API design in Rust?

Use phantom types for API design in Rust when you need to enforce workflow constraints and capabilities at compile time. They are ideal for domain modeling and creating safe abstractions that catch errors before execution.

Does encoding invariants with types have runtime costs in Rust?

Encoding invariants with types in Rust has no runtime costs. It leverages zero-cost abstractions like newtype wrappers and marker traits to express constraints at compile time, ensuring safe abstractions without performance penalties.