From pstack
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, refuse to lie to the compiler, exhaust variants, derive from authoritative schemas.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pstack:principle-type-system-disciplineThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
The type checker is a proof assistant. Use it to eliminate impossible states, mismatched primitives, and unhandled variants at compile time. Anything you let through as runtime data becomes a runtime failure the compiler could have stopped.
The type checker is a proof assistant. Use it to eliminate impossible states, mismatched primitives, and unhandled variants at compile time. Anything you let through as runtime data becomes a runtime failure the compiler could have stopped.
Applies to any typed language. Skills like typescript-best-practices ground it in specific syntax.
The patterns:
{ completed: boolean; completedAt?: Date } admits completed: true; completedAt: undefined, which is meaningless. Derive the boolean from a single source like completedAt !== null, or model the variants explicitly as { kind: 'open' } | { kind: 'done'; at: Date }. If a bug forces the question "wait, can this combination actually happen?", the type is too loose.UserId and OrderId are strings underneath but should not be interchangeable. Newtypes in Rust, opaque types in Swift, value classes in Kotlin, phantom types in Haskell, branded intersections in TypeScript. Validate once at creation, trust the type downstream.never-typed binding in TypeScript, unannotated match in Rust, -Wincomplete-patterns in Haskell, sealed-class match exhaustiveness in Kotlin.instanceof is admitting the type system isn't carrying its weight. Push the check up to the type.The tests:
any, this as, this assertNotNull come from?" Trace it to the boundary and validate there instead.npx claudepluginhub kdoroszewicz/cursor-plugins-claude --plugin pstack2plugins reuse this skill
First indexed Jun 9, 2026
Develop with refined types: model domains, encode state machines, and harden API boundaries against malformed input using techniques like 'make illegal states unrepresentable' and 'parse don't validate'.
Use when a backpressured code-review subagent is judging whether a diff uses the type system to make illegal states unrepresentable — i.e. the diff touches data models, function signatures, or domain types. TypeScript-centric, with mappings to Rust, Swift, Kotlin, and Haskell/OCaml.
TypeScript best practices. Use when reading or editing any .ts or .tsx file.