mcpField
P
principle-type-system-discipline

principle-type-system-discipline

github.com/backnotpropDevelopment3.1k5.9k installsUpdated today
Repository

About principle-type-system-discipline

Type System Discipline is a development principle skill for designing types that rule out invalid states and mismatched values. It covers semantic primitives, parsing external data, and deriving types from authoritative schemas.

Key features

  1. 01Brand semantically distinct primitives
  2. 02Parse data at system boundaries
  3. 03Derive types from authoritative schemas

Use cases

  1. 01Distinguishing IDs that share a base type
  2. 02Typing RPC, JSON, or configuration input
  3. 03Generating types from protocol or database schemas

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/backnotprop/pstack --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