frontend-state-management

frontend-state-management is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 109 tokens per session (1,334 once invoked), scanned A, original, Apache-2.0.

A workflow for deciding where data belongs in a web interface and how it changes. It distinguishes server data, temporary interface choices, URL values, and truly shared application data.

In plain words
What is it for?
It helps design stores, context, cached server data, URL filters, optimistic updates, and component-level state.
Why use it?
It prevents multiple copies of the same fact from disagreeing, outdated displays, excessive data passed between components, and unnecessarily large shared stores.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps design stores, context, cached server data, URL filters, optimistic updates, and component-level state.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/frontend-state-management
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tmj-90/gaffer --skill frontend-state-management
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for frontend-state-management

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/frontend-state-management/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/frontend-state-management)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/frontend-state-management"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/frontend-state-management/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for frontend-state-management

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/frontend-state-management"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/frontend-state-management.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 109 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,334 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00109 $0.01334
Opus 5.5 $0.00044 $0.00534
Sonnet 5.5 $0.00022 $0.00267
Haiku 4.5 $0.00011 $0.00133

Measured 16d ago against content hash 3c072a634deb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

frontend-state-management scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/frontend-state-management/SKILL.md · 90 lines

How it starts

The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Manage frontend state deliberately

"It shows the old value" and "these two parts disagree" are ownership bugs: a fact was copied, and the copies drifted. For each fact decide one owner and one way it changes. Server data belongs to the server-cache layer, UI state stays as local as possible, shareable state lives in the URL, and a global store holds only client-owned global facts.

Steps

  1. Inventory the state the ticket touches and classify each fact:

    Kind Examples Owner
    Server data lists, records, the current user's profile query/cache layer
    URL state filters, sort, page, selected id, open tab router search params / path
    Local UI state open/closed, hover, an input's draft the component, or nearest common parent
    Global client state theme, auth session handle, cross-page draft the repo's store
    Derived counts, filtered lists, "is valid" computed in render, never stored

    Call search_lore for the chosen libraries and conventions.

  2. Server data stays in the cache layer (TanStack Query, SWR, RTK Query, Apollo, loaders — the frontend-data-fetching skill). Read it where needed with the same query key; do not copy it into useState or a store. To edit a record, keep only the draft fields in form state, initialised from the query once, and submit a mutation.

  3. Local first; lift only as far as needed. Two siblings that must agree share the nearest common parent. Passing props through two or three levels is fine; deeper usually wants composition (pass the rendered child) before context. Context carries rarely changing values; split fast-changing values into their own context so a keystroke does not re-render the tree.

  4. URL for anything a user would share, bookmark or expect back. Parse search params on read with a schema (unknown or invalid values fall back to defaults, never crash); write with the router's API, replace for typing-driven changes and push for navigations the Back button should undo. The URL is then the only copy — do not mirror it into state.

  5. A global store only for truly global client state, using the repo's library (Zustand, Redux Toolkit, Pinia, signals). Small slices, actions named for intent (selectTicket), selectors that return the minimum so subscribers re-render only when their slice changes. External stores in React are read through the library's hooks or useSyncExternalStore, never by subscribing in an effect.

  6. Transitions are explicit and safe under concurrency.

    • One named function per transition; reducers are pure (no fetches, no Date.now(), no mutation of the previous state).
    • Updates that depend on the previous value use the functional form (setCount(c => c + 1)) so rapid events are not lost.
    • Optimistic updates snapshot and roll back on failure, and a slower earlier response must not overwrite a newer optimistic value (cancel or ignore superseded requests).
  7. Persisted state (localStorage, IndexedDB) is versioned. Store a schema version, migrate or discard old shapes on read, never persist server data or secrets, and read it after hydration (or with the library's hydration helper) to avoid server/client mismatches. If two tabs can edit the same persisted state, sync through the storage event or BroadcastChannel, or declare last-write-wins in the ticket — do not leave it undefined.

  8. Reset deliberately. To reset a subtree's state when an entity changes, key it by the entity id (<Editor key={ticketId} />) instead of an effect that clears fields.

  9. Test where the state lives (the frontend-testing skill): pure reducer/store transition tests; a component test per AC that drives the UI and asserts what is shown; a URL test (load with params → correct view; change filter → URL updated; Back restores); the rollback path; and rapid repeated events (click ×5 → count is 5). Record per-AC evidence with the record-evidence skill, then stop.

Read the full file on GitHub · 90 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +25 lines · +6 tokens per session 3c072a634deb
  2. 19d ago First seen · 65 lines · 103 tokens per session scan A da37f443e8e4

Subscribe to this mod's changes

frontend-state-management is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 109 tokens to every session and 1,334 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.

Related

Other skills, from other repositories

bulwark-brainstorm

Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.

QBall-Inc/the-bulwark · 50 tokens

plan-creation

Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.

QBall-Inc/the-bulwark · 38 tokens

anthropic-validator

Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.

QBall-Inc/the-bulwark · 40 tokens

create-subagent

Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.

QBall-Inc/the-bulwark · 42 tokens

test-audit

Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.

QBall-Inc/the-bulwark · 0 tokens

code-review

Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.

QBall-Inc/the-bulwark · 61 tokens