Principle Type System Discipline
Design type systems to make illegal states unrepresentable by enforcing strict type validation at creation, parsing external data, and deriving types from authoritative schemas.
Editor's Note
Before applying this discipline, ensure that all external data sources (e.g., JSON, RPC, CLI args) are parsed through a dedicated function that returns a typed model. This step is mandatory to enforce type safety at the system boundary.
When to Use It
- Validating user input in a web application by enforcing strict type definitions.
- Parsing JSON API responses into typed models to avoid runtime errors.
- Creating domain-specific types to prevent misuse of shared primitive types.
SKILL.md
SkillsHunter provides this listing for informational purposes only. Review the skill’s source, license, and required permissions before use. You are responsible for deciding whether to install or run it. Terms of Use
---
name: principle-type-system-discipline
description: When designing types or signatures, make illegal states unrepresentable.
disable-model-invocation: true
---
# Type System Discipline
Other empstack skills live at `../<name>/SKILL.md`. Read one to run it.
Make the compiler reject impossible states, mismatched primitives, and unhandled variants.
- **Brand semantic primitives.** If two arguments share a primitive type but mean different things, give each its own type. Validate once at creation.
- **External data is untyped until parsed.** JSON, RPC payloads, CLI args, config, environment variables, and database rows go through a parse function at the boundary that returns the typed model.
- **Derive types from authoritative schemas.** When a schema file owns a shape, derive the type from it instead of hand-rolling a parallel one.
For TypeScript syntax, see the **typescript-best-practices** skill.
Community Reviews & Field Notes
Tried this skill on your own project? Share the model you used and the results you got.