mcpField
P
principle-type-system-discipline

principle-type-system-discipline

github.com/cursorDevelopment14.6k4.7k installsUpdated 1d ago
Repository

About principle-type-system-discipline

Type System Discipline is a development skill for using types to prevent invalid states, primitive mix-ups, and unhandled variants. It guides developers to validate external data at boundaries and derive types from authoritative schemas.

Key features

  1. 01Use branded types for semantic primitives
  2. 02Parse untyped data at system boundaries
  3. 03Derive types from authoritative schemas
  4. 04Prefer removing impossible states over adding handlers

Use cases

  1. 01Separating identifiers that share a primitive type
  2. 02Typing data received through RPC or JSON
  3. 03Keeping application types aligned with protocol or database schemas

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/cursor/plugins --skill principle-type-system-discipline

After installing, type/principle-type-system-disciplinein Claude Code to confirm it loaded.

Details

From the project README

Type System Discipline

Make the compiler reject impossible states, mismatched primitives, and unhandled variants. Prefer defining errors and special cases out of existence over proliferating handlers. For TypeScript syntax, see the typescript-best-practices skill.

  • Brand semantic primitives. UserId and OrderId are strings underneath but should not be interchangeable. Give each its own type, such as a branded intersection in TypeScript or a newtype elsewhere. Validate once at creation, trust the type downstream. If two arguments share a primitive type but mean different things, brand them.
  • External data is untyped until parsed. RPC payloads, JSON, IPC messages, CLI args, config files, environment variables, database rows. Have a parse function at every boundary that turns unstructured input into the typed model. The boundary-discipline principle skill says where to put validation.
  • Derive types from authoritative schemas. When a protocol buffer, OpenAPI spec, GraphQL schema, database migration, design-token file, or another file owns a shape, derive from it instead of hand-rolling a parallel type. See the encode-lessons-in-structure principle skill.

Comments

Markdown supported