Skip to content
Back to skills

Principle Type System Discipline

ASecurity

Type system discipline. Apply when you design types, review a function signature or write code in a statically typed language.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentsrustgitapidatabase

Works with

  • cursor
  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add erickb336/sage-stack --skill principle-type-system-discipline --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Principle Type System Discipline?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Principle Type System Discipline
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/erickb336-principle-type-system-discipline/badge)](https://www.skillsdirectory.com/skills/erickb336-principle-type-system-discipline)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.