M05 Type Driven

🌐Community
by actionbook Β· vlatest Β· Repository

M05 Type Driven executes actions based on specified types, streamlining workflows and automating targeted tasks efficiently.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add actionbook-m05-type-driven npx -- -y @trustedskills/actionbook-m05-type-driven
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "actionbook-m05-type-driven": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/actionbook-m05-type-driven"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill, M05 Type Driven, helps AI agents design software by leveraging type systems to prevent errors and enforce invariants at compile time rather than runtime. It focuses on using techniques like newtypes, type states, and phantom data to encode constraints directly into the code's types, leading to more robust and reliable applications. The skill guides the agent through a process of questioning whether an error can be caught by the compiler before resorting to runtime checks.

When to use it

  • When designing systems where preventing invalid states is critical.
  • When refactoring existing code that relies heavily on runtime validation.
  • To create more type-safe wrappers around primitive data types (e.g., ensuring a string represents a valid email address).
  • For implementing state machines with well-defined and validated transitions.
  • When needing to track phantom type parameters for variance or lifetime management.

Key capabilities

  • Newtype Pattern: Creating custom types based on primitive types to enforce constraints (e.g., struct UserId(u64)).
  • Type State Pattern: Representing state machines using tagged unions encoded as types (e.g., Connection<Connected>).
  • PhantomData: Managing variance and lifetimes through phantom type parameters.
  • Marker Traits: Implementing capability flags to track whether an object meets certain criteria.
  • Builder Pattern: Enabling gradual construction of complex objects with validation at each step.

Example prompts

  • "I need a way to represent user IDs safely; they should always be positive integers."
  • "How can I model a connection state machine with states like 'disconnected', 'connected', and 'authenticated'?"
  • "Can you help me create a type-safe wrapper for an email address, ensuring it’s valid before use?"

Tips & gotchas

  • This skill is best used when designing new systems or refactoring existing ones. It requires understanding of Rust type system concepts.
  • The skill focuses on compile-time validation; runtime checks may still be necessary in some cases where invariants cannot be encoded in types.
  • Consider using the "Trace Up" feature to connect this skill with m09-domain for domain model guidance and m04-zero-cost for marker trait usage.

Tags

πŸ›‘οΈ

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates β€” what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
actionbook
Installs
34

🌐 Community

Passed automated security scans.