state-discipline

state-discipline is a skill for Claude Code, Codex from lukedj78/dev-flow. It costs 217 tokens per session (5,840 once invoked), scanned A, original, MIT.

Rules for deciding where data and user-interface state should live in React 19 and Next.js 16 apps. State means information the interface remembers, such as a selected option or form value.

In plain words
What is it for?
Use it to review or design code involving useState, useEffect, fetched data, URL parameters, forms, derived values, or one-time synchronization.
Why use it?
It reduces bugs caused by copying props, URLs, or server data into separate state that later becomes out of sync with the original source.

Skill for Claude CodeCodex

Part of the dev-flow plugin — 45 skills shipped together

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.

agentmods
npx agentmods add skills/lukedj78/dev-flow/state-discipline
Any agent
npx skills add lukedj78/dev-flow --skill state-discipline
Clone the repo
git clone --depth 1 https://github.com/lukedj78/dev-flow

Made for: Claude Code, Codex.

Or install dev-flow, the plugin that ships this one along with the rest of its 45 skills.

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 state-discipline

README.md
[![agentmods](https://agentmods.dev/badge/skills/lukedj78/dev-flow/state-discipline.svg)](https://agentmods.dev/skills/lukedj78/dev-flow/state-discipline)
Your own site
<a href="https://agentmods.dev/skills/lukedj78/dev-flow/state-discipline"><img src="https://agentmods.dev/badge/skills/lukedj78/dev-flow/state-discipline.svg" alt="Measured on agentmods" height="20"></a>
Per session 217 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,840 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00217 $0.05840
Opus 5 $0.00109 $0.02920
Sonnet 5 $0.00043 $0.01168
Haiku 4.5 $0.00022 $0.00584

Measured 4d ago against content hash 1e37354ce4ec, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

state-discipline 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 4d 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.

state-discipline/SKILL.md · 465 lines

How it starts

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

state-discipline — useState is the last resort

This skill governs where state lives in a Next.js 16 App Router / React 19 codebase. The framework's primitives (Server Components, URL searchParams, props, query libraries, controlled inputs, useOptimistic, useTransition) cover ~90% of "I need some state" cases. useState and useEffect are escape hatches for the last 10%.

The bug is silent: code that uses useState + useEffect to mirror a prop, derive a value, or sync with the URL works — until the source of truth changes and the mirror desyncs. No error, no warning, just wrong UI.

When this skill applies

  • The user pastes useState + useEffect and asks for review.
  • The user is about to add useEffect (at all).
  • The user is about to add useState to mirror a prop.
  • The user asks "should I add useState here?".
  • The user is about to add useState to hold form field values (route them to the forms skill).
  • The user is about to add useState to hold server-fetched data (route them to the data-fetching skill).
  • The user asks to audit a codebase against the React state rules.

Contract

Follows the dev-flow contract — see references/contracts.md. Key facts:

  • Reads meta.json#stack.framework and stack.nextjs_version. For monorepo, reads stack.monorepo.web.*.
  • Refuses if stack.framework ∉ {"next", "monorepo"} or stack.nextjs_version != "16". The principles transfer to other React 19 setups (Remix v3, plain React 19 + Vite, etc.) but the URL/Server-Component rungs do not — refuse rather than mis-apply.
  • Appends history per refactor.
  • Does not bump phase.

Companion skills

  • data-fetching — owns the "read data in Server Components, not in useEffect" rule. Every useEffect that fetches is a data-fetching problem first.
  • forms — owns field state for forms. Every useState bound to <input>/<Checkbox>/<Switch> whose value persists is a forms problem first.

This skill owns everything left over: derived values, prop mirrors, UI toggles, optimistic UI, reset semantics, one-time external sync.

Read the full file on GitHub · 465 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 465 lines · 217 tokens per session scan A 1e37354ce4ec

Subscribe to this mod's changes

state-discipline is a skill published in the GitHub repository lukedj78/dev-flow (6 stars, last pushed today), licensed MIT. It adds 217 tokens to every session and 5,840 once invoked, about $0.0011 per session on Opus 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-08-31.

Related

Other skills, from other repositories

agent-code-analyzer

Agent skill for code-analyzer - invoke with $agent-code-analyzer.

ruvnet/ruflo · 19 tokens

agui-dotnet-streaming-chat

Get started with the AG-UI .NET SDK: bootstrap and run your first streaming-chat app (client + server) with the AG-UI .NET NuGet packages (AGUI.Client, AGUI.Server, AGUI.Formatting, AGUI.Abstractions). USE FOR: which packages to install and how to wire them; constructing an AGUIChatClient against an endpoint and…

ag-ui-protocol/ag-ui · 223 tokens

agui-dotnet-sample-step

Add a GettingStarted sample Step (a Server/Client pair) to the AG-UI .NET SDK that demonstrates one protocol feature the way we want users to write it. USE FOR: adding a new samples/GettingStarted/StepNN Server+Client pair, wiring it into AGUI.slnx and the integration-test project, giving it a deterministic…

ag-ui-protocol/ag-ui · 168 tokens

agui-dotnet-protobuf

Use the protobuf wire transport (instead of the default Server-Sent Events) for an AG-UI connection with the AG-UI .NET SDK — a compact binary event stream negotiated via the Accept header. USE FOR: making an AGUIChatClient prefer protobuf by wiring an AGUIEventStreamHandler with ProtobufEventStreamFormatter (then…

ag-ui-protocol/ag-ui · 162 tokens

evaluating-code-models

Evaluates code generation models across HumanEval, MBPP, MultiPL-E, and 15+ benchmarks with pass@k metrics. Use when benchmarking code models, comparing coding abilities, testing multi-language support, or measuring code generation quality. Industry standard from BigCode Project used by HuggingFace leaderboards.

Orchestra-Research/AI-Research-SKILLs · 68 tokens

taiyi-ui-design

TaiyiForge 第 4 阶段 — UI/UX 契约,产出 UI-DESIGN.md。四端通用。.

Dong90/oh-my-taiyiforge · 35 tokens