Agent skill
riverpod-observers
Use ProviderObserver to log or debug Riverpod provider lifecycle; didUpdateProvider, ProviderScope observers, naming providers. Use when adding logging, analytics, or debugging for provider state changes. Use this skill when the user asks about ProviderObserver, logging Riverpod, or debugging provider updates.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/riverpod-observers
SKILL.md
Riverpod — ProviderObservers
Instructions
A ProviderObserver receives lifecycle events for providers (e.g. when a provider's value changes). Use it for logging, analytics, or debugging.
Implementing an observer
Extend ProviderObserver and override the methods you need (e.g. didUpdateProvider). Pass instances to ProviderScope or ProviderContainer via the observers parameter.
Example: logger
final class Logger extends ProviderObserver {
@override
void didUpdateProvider(
ProviderObserverContext context,
Object? previousValue,
Object? newValue,
) {
print('{"provider": "${context.provider}", "newValue": "$newValue"}');
}
}
void main() {
runApp(
ProviderScope(
observers: [Logger()],
child: const MyApp(),
),
);
}
Naming providers
For clearer logs, give providers a name:
final myProvider = Provider<int>((ref) => 0, name: 'MyProvider');
With code generation, a name is usually assigned automatically.
Note on mutations
If state is mutated in place (e.g. a List with ref.notifyListeners), previousValue and newValue in didUpdateProvider may be the same reference. For distinct values, clone before mutating.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?