illegal-states-unrepresentable
Make illegal states unrepresentable with precise types, discriminated variants, and boundary parsing.
Skill by kasofsk
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.
About
Reviews
Write a reviewNo 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
- 0.524score
comments-describe-the-code
kasofsk
Write comments about the code itself, never about the prompt, conversation, or moment that produced it — and treat a long justifying comment as a signal the…
SkillBFreshness: BClaude Code +9 - 0.524score
design-with-known-limits
kasofsk
Design systems with explicit correctness limits, failure modes, and operational assumptions instead of automatically engineering every weakness away.
SkillBFreshness: BClaude Code +9 - 0.524score
diminishing-returns
kasofsk
Pursue the highest-value work first and stop when the expected value of the next improvement no longer justifies its full cost.
SkillBFreshness: BClaude Code +9 - 0.524score
domain-modelling
kasofsk
Shape the contents of the domain core — ubiquitous language, aggregates as consistency boundaries, entities versus value objects, making illegal states…
SkillBFreshness: BClaude Code +9 - 0.524score
fix-the-assumption-not-the-hack
kasofsk
When a new feature invalidates an assumption the current design rests on, rethink the pattern rather than land a tweak that technically satisfies the request.
SkillBFreshness: BClaude Code +9 - 0.524score
idiomatic-by-default
kasofsk
Take the community-standard path for the language, framework, or ecosystem unless there is an articulable reason not to, and don't escalate a decision the…
SkillBFreshness: BClaude Code +9 - 0.524score
layering
kasofsk
Decide where code goes and which way its dependencies point — inward-pointing source dependencies, what the domain, application, adapter and infrastructure…
SkillBFreshness: BClaude Code +9 - 0.524score
modular-and-layered-code
kasofsk
Architect so a future agent can act at a single layer — strict tested contracts between layers, testing concentrated at domain boundaries, pure logic kept…
SkillBFreshness: BClaude Code +9 - 0.524score
push-back-and-verify-assumptions
kasofsk
Treat the operator as a fellow engineer — challenge naive or wrong premises, state assumptions explicitly, keep asking until they are right, and stop rather…
SkillBFreshness: BClaude Code +9 - 0.524score
write-the-present-not-the-diff
kasofsk
Write prose that states what is true now, without narrating the correction, the superseded claim, or the path that got there.
SkillBFreshness: BClaude Code +9 - 0.494score
dependencies
kasofsk
Add, remove, upgrade, or pin a dependency with the ecosystem's package manager instead of hand-editing the manifest.
SkillBFreshness: BClaude Code +9
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
- Repository
- github.com/kasofsk/blessed-practices
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from kasofsk
- 0.524score
comments-describe-the-code
kasofsk
Write comments about the code itself, never about the prompt, conversation, or moment that produced it — and treat a long justifying comment as a signal the…
SkillBFreshness: BClaude Code +9 - 0.524score
design-with-known-limits
kasofsk
Design systems with explicit correctness limits, failure modes, and operational assumptions instead of automatically engineering every weakness away.
SkillBFreshness: BClaude Code +9 - 0.524score
diminishing-returns
kasofsk
Pursue the highest-value work first and stop when the expected value of the next improvement no longer justifies its full cost.
SkillBFreshness: BClaude Code +9 - 0.524score
domain-modelling
kasofsk
Shape the contents of the domain core — ubiquitous language, aggregates as consistency boundaries, entities versus value objects, making illegal states…
SkillBFreshness: BClaude Code +9 - 0.524score
fix-the-assumption-not-the-hack
kasofsk
When a new feature invalidates an assumption the current design rests on, rethink the pattern rather than land a tweak that technically satisfies the request.
SkillBFreshness: BClaude Code +9 - 0.524score
idiomatic-by-default
kasofsk
Take the community-standard path for the language, framework, or ecosystem unless there is an articulable reason not to, and don't escalate a decision the…
SkillBFreshness: BClaude Code +9
Cite this page
illegal-states-unrepresentable skill. Agent Mart. https://agentmart.dev/skills/kasofsk-illegal-states-unrepresentable (last updated 2026-10-24)