Skip to content
Skillpedia
General coding15k · #10991

principle-type-system-discipline

What it does

Gives the assistant a rule for designing types that catch mistakes early. It is for developers working in statically typed languages.

When to use it

  • ✓When you design types or review a function signature.
  • ✓When two values share a type but mean different things.
  • ✓When data from outside the program enters the code.

Skill link

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Our user IDs and order IDs are both plain strings and keep getting mixed up. Tighten the types so the compiler stops this.”

5 new skills a week. 1 minute to read.

How it works

The assistant gives each semantic value its own type, parses external data into typed models at the boundary, makes unhandled variants fail the build, and derives types from authoritative schemas rather than hand-written copies.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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.
FAQ

What is a branded type?

A type that looks like a string underneath but cannot be mixed with other IDs, so the compiler catches the mistake.

Where does parsing happen?

At every boundary, such as network payloads, config files, command-line arguments and database rows.

Why derive types from schemas?

So a shape owned by a protocol file or migration is not duplicated by hand and left to drift.

Details

Original description by the author

Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, exhaust variants, derive from authoritative schemas.

repo: cursor/plugins

Popularity

GitHub stars
15k
Ranking position
#10991
License
—
Updated
10/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills