flowmvi
Skill956 starsChanged 24 months agoApache-2.0View on GitHub
FlowMVI usage guidance. Use when working with FlowMVI stores/containers, plugin pipelines, composing stores, decorators, or authoring plugins.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 5 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this to learn the API of FlowMVI.
- Very specific: line 16
Use rg over references/*signatures*.md for discovery and open URLs from references/docs-index.md when you need full docs.
- Distinctive: line 31
Use sealed interfaces for LCE or multi-branch screens.
- Very specific: line 32
Use EmptyState if no state is needed.
- Very specific: line 48
If no actions, use Nothing or the no-action store overload.
- Distinctive: line 65
Prefer a container per screen/feature and expose the store as a property.
- Very specific: line 81
Use lazyStore when construction is heavy or should be deferred.
- Very specific: line 97
Prefer ImmutableStore/ImmutableContainer at the edges to avoid leaking context.
- Very specific: line 146
Use reduce early if you want later plugins to observe processed intents.
- Very specific: line 148
All plugin signatures are in references/plugin-signatures.md.
- Very specific: line 149
All callback signatures and behavior are in references/plugin-callbacks.md.
- Very specific: line 170
Use the plugin DSL to intercept store events.
- Very specific: line 178
Do not call updateState inside onState to avoid loops.
- Very specific: line 179
Never throw from onUndeliveredIntent/onUndeliveredAction.
- Very specific: line 181
Use references/plugin-callbacks.md for full behavior rules.
- Very specific: line 188
If you do not invoke child.onX(...) in a decorator, the chain stops there.
- Distinctive: line 191
Use decorators only when:
- Very specific: line 215
Use DelegationMode.Immediate when you need always-hot projections.
- Very specific: line 216
Default WhileSubscribed mode yields stale projections when no subscribers.
- Distinctive: line 218
Prefer building tree-like store hierarchies using children and delegates for complex business logic.
- Distinctive: line 221
Use savedstate module for persistence, metrics module to set up metrics, and essenty for decompose integration.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
Use this to learn the API of FlowMVI. Prefer the bundled references for exact APIs and the live official docs for plugins/integrations/state.
Key references in this skill:
references/api-signatures.mdfor core API signatures.references/plugin-signatures.mdfor all plugin/decorator signatures.references/plugin-callbacks.mdfor callback behavior and decorator semantics.references/docs-index.mdfor live docs URLs (plugins, integrations, state).
Use rg over references/*signatures*.md for discovery and open URLs from references/docs-index.md when you need full docs.
Core loop
- Define a Contract:
MVIState,MVIIntent,MVIAction. - Build a Store: uses a plugin pipeline, handles intents, updates state, emits actions (side effects).
- Install Plugins: ordered chain of responsibility. Order changes behavior.
- Install Decorators: wrap the entire plugin chain and can short-circuit it.
- Subscribers render state and handle actions.
Contract and state design
State
- Make state immutable and comparable. Use
data class/data object. - Use sealed interfaces for LCE or multi-branch screens. Avoid placeholder fields.
- Use
EmptyStateif no state is needed.
Example (state family):
sealed interface CounterState : MVIState {
data object Loading : CounterState
data class Content(val count: Int) : CounterState
data class Error(val cause: Exception) : CounterState
}Intent and action
MVIIntent: inputs/events. Use sealed interfaces for MVI style.MVIAction: one-off effects, never rely on them for critical logic.- If no actions, use
Nothingor the no-action store overload.
sealed interface CounterIntent : MVIIntent {
data object Tap : CounterIntent
data class Set(val value: Int) : CounterIntent
}
sealed interface CounterAction : MVIAction {
data class ShowToast(val text: String) : CounterAction
}Store creation patterns
Container pattern
Prefer a container per screen/feature and expose the store as a property.
class CounterContainer : Container<CounterState, CounterIntent, CounterAction> {
override val store = store(initial = CounterState.Loading) {
configure { debuggable = BuildFlags.debuggable; name = "CounterStore" }
reduce { intent ->
when (intent) {
is CounterIntent.Set -> updateState<_, CounterState.Content> { copy(count = intent.value) }
is CounterIntent.Tap -> action(CounterAction.ShowToast("tap"))
}
}
}
}Use lazyStore when construction is heavy or should be deferred.
MVVM+ Intents
Intents can be lambdas (Orbit MVI-style):
// contract
typealias CounterIntent = LambdaIntent<CounterState, CounterAction>
// sending
fun onTap() = store.intent { updateState<State.Content, _> { copy(count = count + 1) } }When using LambdaIntent:
- Mandatory: Install
reduceLambdasplugin to invoke intent blocks. - Prefer
ImmutableStore/ImmutableContainerat the edges to avoid leaking context. - Plugins lose observability into intent contents, prefer regular intents unless codebase already uses lambdas.
State management (SST)
FlowMVI serializes state transactions by default.
Use:
updateState { }for atomic updates.withState { }for safe reads.- Typed overloads for state families:
updateState<T, R> { }andwithState<T, R> { }(note always two parameters, of which first is target state, and second is always underscore_). Also these need an import. updateStateImmediateonly for performance-critical hot paths; it bypasses plugins and safety.
PipelineContext API
You get PipelineContext receiver inside most of the store DSLs and plugin callbacks. Key operations:
updateState { },withState { },updateStateImmediate { }action(action)andintent(intent)configfor store config and loggingFlow.consume(context)for safe collection in store context
Exact signatures in references/api-signatures.md.
Store configuration
Configure inside store { configure { ... } }. Defaults are defined in StoreConfigurationBuilder.
Key flags:
debuggable: enable validations + verbose logging.name: used for logging/debugging and store identity.parallelIntents: process intents concurrently (state safety becomes critical).coroutineContext: merged with start scope.actionShareBehavior:Distribute,Share,Restrict,Disabled.intentCapacity+onOverflow: buffer sizing and backpressure.stateStrategy:Atomic(reentrant = true/false)orImmediate.allowIdleSubscriptions,allowTransientSubscriptions.logger,verifyPlugins.
See exact defaults in references/api-signatures.md and use references/docs-index.md for the latest state docs.
Exact signatures: references/api-signatures.md.
Plugins (system)
Plugins are the core of FlowMVI. Order matters.
- Install plugins in the order you want them to intercept events.
- Plugins can consume, modify, or veto intents/actions/states.
- Use
reduceearly if you want later plugins to observe processed intents.
All plugin signatures are in references/plugin-signatures.md.
All callback signatures and behavior are in references/plugin-callbacks.md.
Prebuilt plugin catalog
Open references/docs-index.md and references/plugin-signatures.md for the full list. Core plugins include:
- reduce, init, asyncInit, recover, whileSubscribed
- enableLogging
- cache / asyncCache
- manageJobs
- awaitSubscribers
- undoRedo
- disallowRestart
- timeTravel
- consumeIntents
- deinit, resetStateOnStop
- saved state plugins (savedstate module)
- remote debugger plugins (debugger modules)
Creating custom plugins
Use the plugin DSL to intercept store events. Use lazyPlugin when you need config at creation time.
val analytics = plugin<State, Intent, Action> {
onIntent { intent -> log { "intent = $intent" }; intent }
}Rules:
- Do not call
updateStateinsideonStateto avoid loops. - Never throw from
onUndeliveredIntent/onUndeliveredAction.
Use references/plugin-callbacks.md for full behavior rules.
Decorators (plugins for plugins)
Decorators wrap plugins and can short-circuit the entire chain.
- decorators run after plugins; they wrap all previously installed plugins.
- If you do not invoke
child.onX(...)in a decorator, the chain stops there. - Decorators return final values, not intermediate chain values.
Use decorators only when:
- You need to instrument, retry, debounce, or batch the whole chain.
- You want cross-cutting behavior that is hard to express as a plugin without chain control.
Child stores
Tie lifecycle of child stores to a parent store:
val child = store(ChildState.Loading) { /* ... */ }
val parent = store(ParentState.Loading) {
this hasChild child
}Delegation
Delegate state/actions from another store and project them:
val feedState by delegate(feedStore) { action -> /* handle */ }
whileSubscribed { feedState.collect { state -> /* render */ } }Use DelegationMode.Immediate when you need always-hot projections.
Default WhileSubscribed mode yields stale projections when no subscribers.
Prefer building tree-like store hierarchies using children and delegates for complex business logic.
Other
Use savedstate module for persistence, metrics module to set up metrics, and essenty for decompose integration.
More info in references/docs-index.md
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
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.

