Skip to content
Log in

Type Modelling Review

Reshapes types so invalid states cannot be represented, rather than validating them at runtime and hoping.

0

Share this prompt

Free — no card needed

Create a free account

to open Type Modelling Review — and the other 364 prompts across 21 categories.

We store your email address to send these. We never sell it or pass it to advertisers. Withdraw at any time. Privacy Policy.

Already have an account?

CategoryCodingForDevelopersTested onClaudeChatGPT

Running it, start to finish

  1. List every invalid state the current types allow.
  2. Replace optional-plus-flag shapes with discriminated unions.
  3. Move validation to the boundary and parse into a guaranteed type.

What you get back

The output this produces, every time.

  • Lists the invalid states your current types permit, which is usually more than expected.
  • Moves validation to the boundary so downstream code is guaranteed by construction.
  • Checks each proposed change against bugs you actually had, rather than theoretical ones.

Getting better results

Where this usually goes wrong, and how to avoid it.

  • Look hardest at optional pairs. Two optionals where exactly one should be set is the most common representable-invalid-state, and a union fixes it outright.
  • Split the meanings of null. Absent, not-applicable and empty collapsed into one value produces bugs nobody can reproduce.
  • Brand your identifiers. An order id and a user id are both strings, and swapping them type-checks perfectly today.

More Coding prompts

All Coding

Written for The AI University. Every prompt in this library is original work — authored, tested and revised here, not collected from elsewhere. 365 of them, free with an account.