{"data":{"slug":"discovered-7edc69c595e202c6105408ac69750f028b7901a46001ba2b","title":"Principle Type System Discipline","summary":"Design type systems to make illegal states unrepresentable by enforcing strict type validation at creation, parsing external data, and deriving types from authoritative schemas.","url":"https:\/\/skillshunter.net\/skills\/discovered-7edc69c595e202c6105408ac69750f028b7901a46001ba2b","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-7edc69c595e202c6105408ac69750f028b7901a46001ba2b","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-7edc69c595e202c6105408ac69750f028b7901a46001ba2b.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-7edc69c595e202c6105408ac69750f028b7901a46001ba2b\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_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.","instructions":"---\nname: principle-type-system-discipline\ndescription: When designing types or signatures, make illegal states unrepresentable.\ndisable-model-invocation: true\n---\n\n# Type System Discipline\n\nOther empstack skills live at `..\/<name>\/SKILL.md`. Read one to run it.\n\nMake the compiler reject impossible states, mismatched primitives, and unhandled variants.\n\n- **Brand semantic primitives.** If two arguments share a primitive type but mean different things, give each its own type. Validate once at creation.\n- **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.\n- **Derive types from authoritative schemas.** When a schema file owns a shape, derive the type from it instead of hand-rolling a parallel one.\n\nFor TypeScript syntax, see the **typescript-best-practices** skill.\n","use_cases":["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."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/jueyi6\/empstack\/blob\/74181e31d2f00313f8683ba157966efcabbe109e\/skills\/principle-type-system-discipline\/SKILL.md","source_commit":"74181e31d2f00313f8683ba157966efcabbe109e","license":null,"version":null,"listing_approved_at":"2026-12-02","created_at":"2026-11-30T08:56:36.000000Z","updated_at":"2026-12-02T09:15:14.000000Z","seo_title":"Type System Discipline: Enforce Illegal States Unrepresentable","seo_description":"Learn how to design type systems that prevent impossible states by using strict type validation, parsing external data, and deriving types from authoritative schemas.","seo_keywords":["type system discipline","illegal states unrepresentable","type validation","external data parsing","schema-derived types"]}}