← ClaudeAtlas

no-invalid-stateslisted

Use when code or a design guards invariants with repeated runtime checks, lifecycle flags, or the same guard at every consumer, or when asked to make invalid states unrepresentable or parse-don't-validate.
Vivswan/skills · ★ 1 · AI & Automation · score 60
Install: claude install-skill Vivswan/skills
# No Invalid States Review and refactor a codebase so that correctness constraints are carried by the strongest mechanism the language provides, not by scattered defensive checks. The core principle: > Validate at boundaries, convert into stronger representations, and make invalid internal states difficult or impossible to construct. This is the "parse, don't validate" discipline: - Each fact is checked **once**, at the edge. - The result is encoded in a representation the rest of the program can trust. - Runtime validation is not deleted: checks on external, dynamic, or untrusted data stay. ## When to Apply Use this skill when the code shows any of these signals: - repeated runtime checks of the same condition (`if !initialized`, `if value is None`, `assert ready`) - booleans that encode lifecycle or mutually exclusive states - several optional fields that must always appear or be absent together - methods that are only valid after another method has been called - comments such as "must call X before Y" or "only valid when connected" - functions re-validating data that a caller already validated - structs, classes, or interfaces that permit contradictory field combinations - incorrect operation ordering that could be rejected statically - casts, non-null assertions, or type ignores used to quiet the checker Do not use this skill to add abstraction to code that is already simple, or in place of a bug hunt. It improves representation, not behavior. ## Workflow ### 1