agentleFS
aaziraniaazirani/flutter_agentify/.agents/skills/state-management/SKILL.md

state-management

Skill0 starsChanged 4 days agoMITView on GitHub

How screens hold and refresh state with Riverpod 3 and code generation, and how they update after the assistant writes data. Use when adding a provider, reading data in a screen, or when a screen does not refresh after an action.

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use css-architecture, error-handling and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Piyush8296Skill

    css-architecture

    CSS architecture, Tailwind patterns, responsive design, design tokens, and styling best practices. Use when implementing designs, setting up styling infrastructure, or debugging layout issues.

    Also in 3 projects that use this

  • MicrosoftSkill

    error-handling

    统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。

    Also in 6 projects that use this

  • lbednerSkill

    i18n

    Use when a code or template change introduces a new translation message key, in either the framework CLI (aegis/i18n/locales/) or a generated project's CLI (the app/i18n/locales/ template tree). Covers adding the real English string, stubbing the same key into every other locale for parity, and the separate translation PR that later replaces placeholders with reviewed native text.

    Also in 4 projects that use this

  • mijunriSkill

    database

    数据库脚本与操作规范。脚本放在 db_scripts 目录,遵循查询优化、事务、安全等实践。

    Also in 3 projects that use this

  • genomewalkerSkill

    resume

    Resume a thread by loading its ~800-token context capsule

    Also in 3 projects that use this

  • 0xSeroSkill

    security

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Don't load this for where files and imports belong.

    line 8
  2. Very specific:

    After editing a provider, run dart run build_runner build.

    line 28
  3. Distinctive:

    Run an action through the registry in a test and assert the provider's new value.

    line 41

“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

State management

Don't load this for where files and imports belong; see clean-architecture.

Rule

  • Providers use Riverpod 3 with code generation: @riverpod or @Riverpod(keepAlive: true), a part '<file>.g.dart'; line, and a plain Ref parameter. Never write or name a generated ref type; Ref is the only one.
  • Screens read repositories through members named watch… or get… and change data only with registry.run(action, input).
  • Data that actions change comes from a stream (watch…), so the screen follows the database. Data that is not in the database (settings) is refreshed by the change-event adapter.

Enforced by the lint rule ui_calls_actions for the read/write split. No automated check covers provider style; follow the files named below.

Why

The assistant writes through the same actions as the buttons. If a screen refreshes only because its own button was pressed, an assistant write leaves it stale. A database stream and the change-event adapter refresh the screen whoever made the change.

How

  • Database data: lib/presentation/providers/items_provider.dart exposes items(Ref ref) as ServiceLocator.getIt<ItemsRepository>().watchItems(). The Drift stream emits after every write, so nothing else is needed. The home screen reads it with ref.watch(itemsProvider) and handles loading, error and data.
  • Non-database data: theme, language and assistant settings are keepAlive providers (for example lib/presentation/providers/theme_provider.dart). attachChangeEvents in lib/ai/change_event_adapter.dart listens to registry.changes for resource settings and calls container.invalidate(...) on each of them. Add a new settings provider to that invalidate chain. It also refreshes the saved notes (savedMemoriesProvider) for resource memories.
  • A new resource that is not a stream: give its action a resources entry, then filter on that resource name in the adapter and invalidate the provider.
  • Screen-only state: a notifier such as SelectedItemIds in lib/presentation/providers/items_provider.dart. When the assistant must know it, mirror it into AppContext, as _report does.
  • After editing a provider, run dart run build_runner build. Never edit *.g.dart.

Anti-patterns

  • ref.invalidate(itemsProvider) after a button's write: it hides a missing stream and the assistant's writes still go stale.
  • Calling repository.createItem(...) from a screen (blocked by ui_calls_actions; use registry.run).
  • Reading a get… once in initState for data that changes.
  • Holding a copy of the list in a State field.
  • Hand-written Provider/StateNotifier next to the generated style.

Verification

  • test/presentation/providers/theme_provider_test.dart and test/presentation/providers/language_provider_test.dart show how provider tests are built; test/support/test_app.dart is the app harness.
  • Run an action through the registry in a test and assert the provider's new value.
  • tool/check.sh runs the lint and tests; it ends with All checks passed.

Related skills

  • clean-architecture — which layer a provider and a repository belong to.
  • actions — the writes that trigger the refresh.
  • app-context — what the assistant is told about the current screen and selection.
  • performance — keeping rebuilds narrow.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.