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.mdCopy 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
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
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.
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.
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
Comments
- …
More skills from this repository
advisor
15kLets your agent consult a stronger second model at key checkpoints, such as before a big decision or when stuck on an error, if you turn it on.
check-agent-compatibility
15kRuns a full check of whether AI coding agents can start, verify and document a repository, and returns one compatibility score with the main issues.
cli-for-agents
15kTeaches your agent to design or review command-line tools so AI agents can run them without prompts, with clear help text and examples.
continual-learning
15kKeeps your AGENTS.md notes up to date by handing the work of reviewing past chats to a dedicated memory updater.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.