P
principle-type-system-discipline
About principle-type-system-discipline
A coding skill that guides developers and coding agents to use types to rule out invalid states, distinguish semantic values, and validate data at boundaries. It also recommends deriving types from authoritative schemas instead of maintaining parallel definitions.
Key features
- 01Brand semantically distinct primitives
- 02Parse untyped data at boundaries
- 03Derive types from authoritative schemas
- 04Prefer types over extra handlers
Use cases
- 01Prevent accidental interchange of IDs
- 02Validate RPC, JSON, or CLI input
- 03Keep types aligned with API or database schemas
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ mariusflorescu/ pstack-t3 --skill principle-type-system-disciplineAfter installing, type/principle-type-system-disciplinein Claude Code to confirm it loaded.
Bundled filesagents/openai.yaml
Details
From the project READMEType 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.
UserIdandOrderIdare 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