Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Principle Type System Discipline?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/erickb336-principle-type-system-discipline)
---
name: principle-type-system-discipline
description: "Type system discipline. Apply when you design types, review a function signature or write code in a statically typed language."
license: MIT
metadata:
source: "pstack principle-type-system-discipline, MIT, Copyright (c) 2026 Lauren Tan, github.com/cursor/plugins, adapted; checked against pstack 0.15.36 at commit 0bb6f37"
---
<!-- Generated by scripts/build.mjs from the sources; edit the source, then run npm run build. -->
# Type system discipline
Make the compiler reject impossible states, mixed-up primitives and unhandled variants. Define errors and special cases out of existence instead of adding more handlers.
- **Make illegal states unrepresentable.** Model variants as a tagged union, not as optional fields whose contradictory combinations compile.
- **Build shapes that cannot hold the illegal value:** a non-empty list is a head plus a rest.
- **Strengthen a type only where partiality appears:** where the loose type forces a cast, a null check or a "should never happen" throw.
- **Brand semantic primitives** that share a type but mean different things, such as a `UserId` and an `OrderId` string. Give each its own type (a brand or a newtype), validate it once at creation, and trust it downstream.
- **Parse external data at each boundary** into the typed model: JSON, messages, arguments, configuration, environment variables, database rows (see "boundary discipline").
- **Do not lie to the compiler.** A cast is a latent crash: cast only after validation.
- **Make every match exhaustive:** a new variant without a case must fail to compile.
- **Derive types from the schema that owns the shape,** such as an OpenAPI spec, not a parallel type by hand.