Skip to content
Agentmart
Submit a tool

illegal-states-unrepresentable

Make illegal states unrepresentable with precise types, discriminated variants, and boundary parsing.

Skill by kasofsk

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/kasofsk-illegal-states-unrepresentable

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Make illegal states unrepresentable with precise types, discriminated variants, and boundary parsing. Use when a record has state-dependent optional fields, code repeatedly checks that fields agree, constructors can produce invalid values, or persistence-shaped nullability leaks into domain logic.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/illegal-states-unrepresentable

What's inside

Skill name
illegal-states-unrepresentable
Description
Make illegal states unrepresentable with precise types, discriminated variants, and boundary parsing. Use when a record has state-dependent optional fields, code repeatedly checks that fields agree, constructors can produce invalid values, or persistence-shaped nullability leaks into domain logic.
License
MIT
Instructions
50 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Illegal States Unrepresentable

## Core principle

Represent domain rules in types so callers cannot construct invalid combinations.
Use runtime validation at untyped boundaries, then pass only valid domain values
inward.

## Model states as variants

Give each meaningful state its own discriminated variant containing exactly the
fields that state requires. Do not combine a status with optional fields whose
presence depends on that status, or encode mutually exclusive states as
independent booleans.

Use an optional only when a value may be independently absent. Do not copy
persistence nullability into the domain model when absence has a state-specific
meaning.

## Parse at boundaries

Parse external data into precise internal types once, at the boundary. Return a
valid domain value or an explicit failure; do not pass partially validated data
inward for each consumer to check again.

Keep database rows, wire schemas, and vendor types at the edge. Map their nullable
or stringly typed fields into domain variants and values. Preserve useful database
constraints as an additional defense for stored data.

## Enforce invariants during construction

Use constructors and parsers for values with rules. Reject invalid input during
construction and make recoverable failure visible in the return type. Once
constructed, a value should not require repeated validation.

Use distinct value types for distinct concepts such as identifiers, units, and
bounded values. In structurally typed languages, use branding or the idiomatic
equivalent when aliases do not create a real distinction.

## Make branching exhaustive

Switch over discriminated variants exhaustively so adding a state exposes every
decision that must handle it. Avoid fallback branches that silently treat a new
state as an existing one.

Use assertions for contradictions at trusted boundaries and invariants the type
system cannot express. Repeated assertions in ordinary domain logic indicate
that the representation is too broad.

From kasofsk/blessed-practices, MIT.

More from kasofsk/blessed-practices

Signals

Stars
0
Forks
1
Open issues
0
Last commit (this folder)
Aug 30, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from kasofsk

Cite this page

illegal-states-unrepresentable skill. Agent Mart. https://agentmart.dev/skills/kasofsk-illegal-states-unrepresentable (last updated 2026-10-24)