← LeaderboardThe Skill Leaderboard

principle-type-system-discipline

Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, exhaust variants, derive from authoritative schemas.

Published by backnotprop ↗backnotprop/pstack

Try your first task

Use types to disallow contradictory toy reservation states

Start a fresh conversation.

Replace the supplied flags in a fictional reservation record with a typed state that cannot be both cancelled and active. Show how to parse external data into the type and one example the compiler or validation should reject.

    User-approved starter prompt based on a pinned source version; check current skill requirements before running. Task evidence ↗

    SKILL.md

    name: principle-type-system-disciplinedescription: "Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, exhaust variants, derive from authoritative schemas."disable-model-invocation: true

    Type System Discipline

    Make the compiler reject impossible states, mismatched primitives, and unhandled variants.

    • Brand semantic primitives. If two arguments share a primitive type but mean different things, give each its own type. Validate once at creation.
    • External data is untyped until parsed. JSON, RPC payloads, CLI args, config, environment variables, and database rows go through a parse function at the boundary that returns the typed model.
    • Derive types from authoritative schemas. When a schema file owns a shape, derive the type from it instead of hand-rolling a parallel one.

    For TypeScript syntax, see the typescript-best-practices skill.