CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

statelyai/state-management

Model, review, and refactor application state so source state stays minimal, derived state is computed instead of synchronized, impossible states are not representable, and each piece of state lives in the right place. Use this whenever the user mentions state management, reducers, stores, Redux, Zustand, React state, Vue state, Pinia, selectors, derived state, duplicated state, boolean flags, invalid states, async status, useEffect soup, forms, wizards, filters, URL state, server state, or confusing UI logic, even if they do not explicitly ask for a "state model."

Quality

87%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

typescript-modeling.mdreferences/

TypeScript Modeling

Use this reference when TypeScript is available. It is one of the highest-leverage ways to make invalid states harder to represent.

Strong defaults

  • Prefer string literal unions over free-form strings.
  • Prefer discriminated unions over nullable field soup.
  • Narrow on status or another discriminant.
  • Use exhaustiveness checking in switch statements.

Example

Prefer this:

type SaveState =
  | { status: 'idle'; draft: Draft }
  | { status: 'saving'; draft: Draft }
  | { status: 'success'; draft: Draft; savedAt: string }
  | { status: 'failure'; draft: Draft; error: string };

Over this:

type SaveState = {
  isSaving: boolean;
  isSuccess: boolean;
  error: string | null;
  savedAt: string | null;
  draft: Draft;
};

The second shape permits many impossible combinations.

When to use discriminated unions

Use them when:

  • some fields only exist in certain modes
  • status determines which actions are valid
  • nullability is spreading because the model lacks explicit states

Exhaustiveness

Prefer exhaustive switch statements so missing transitions fail loudly during development.

Caution

Do not overcomplicate simple independent state with unions just because TypeScript can express them. Use the smallest type shape that protects the real invariants.

LICENSE

README.md

SKILL.md

tile.json