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

no-library.mdreferences/

No Library

Use this reference when the user wants plain JavaScript or TypeScript patterns without committing to a state library.

Strong default

Model state as:

  • a state shape
  • a list of events
  • a pure transition function
  • selectors for derived reads
  • an imperative shell for effects

Minimal pattern

type State = {
  status: 'idle' | 'editing' | 'submitting' | 'failure';
  draft: Draft;
  error: string | null;
};

type Event =
  | { type: 'draft.changed'; value: Draft }
  | { type: 'submit.requested' }
  | { type: 'submit.succeeded' }
  | { type: 'submit.failed'; error: string };

function transition(state: State, event: Event): State {
  switch (event.type) {
    case 'draft.changed':
      return { ...state, draft: event.value };
    case 'submit.requested':
      return { ...state, status: 'submitting', error: null };
    case 'submit.succeeded':
      return { ...state, status: 'idle' };
    case 'submit.failed':
      return { ...state, status: 'failure', error: event.error };
  }
}

This is often enough for modeling and review, even if the final implementation later moves to React, Redux, Zustand, or Vue.

Guidance

  • Keep transitions pure.
  • Keep effects outside the transition function.
  • Use selectors for derived state.
  • Use discriminated unions when fields only make sense in certain modes.
  • Reach for a fuller state machine only when the workflow truly needs it.

LICENSE

README.md

SKILL.md

tile.json