smithery/dafum

state-safety-action-creator-guard

enforce state immutability and valid transitions. Trigger when modifying the reducer, creating actions, or debugging state bugs.

Installation

$ npx skills add smithery/dafum --skill state-safety-action-creator-guard

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/dafum.

npx skills add smithery/dafum

Browse all from smithery/dafum

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,748 B
  • docs SUMMARY.md 230 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

State Safety & Action Creator Guard

Ensure global state remains consistent, immutable, and valid.

Workflow

  1. Use Action Creators

- Rule: Never dispatch raw objects (dispatch({ type: 'FOO' })). - Fix: Import from src/context/actionCreators.ts. - Cross-check: Verify reducer handling in src/context/gameReducer.ts. - Why: Centralizes logic and ensures payload shape.

  1. Enforce Invariants

- Money: Must be >= 0. - Harmony: Must be > 0 (or triggers Game Over). - Inventory: Items must be unique IDs.

  1. Check Reducer Logic

- Immutability: Use spread syntax ...state or immer (if available). - Clamping: Math.max(0, newState.money).

Example

Input: "Deduct 50 money for the venue fee."

Bad:

dispatch({ type: 'DEDUCT_MONEY', amount: 50 })

Good:

import { createUpdatePlayerAction } from 'src/context/actionCreators'

if (player.money >= 50) {
  // Use createUpdatePlayerAction with object payload
  dispatch(createUpdatePlayerAction({ money: Math.max(0, player.money - 50) }))
} else {
  console.error('Insufficient funds')
}

Reducer Check:

case 'UPDATE_PLAYER':
  return {
    ...state,
    player: {
      ...state.player,
      ...action.payload
    }
  };

Output: "Updated dispatch to use createUpdatePlayerAction with validation check player.money >= 50."

Skill sync: compatible with React 19.2.8 / Vite 8.2.2 / Tailwind 4.3.3 baseline as of 2026-05-20.