Agent skill
riverpod-overrides
Override Riverpod providers for tests, debugging, or environment-specific behavior; ProviderScope and ProviderContainer overrides, overrideWith, overrideWithValue. Use when mocking providers in tests, injecting different implementations, or scoping provider behavior. Use this skill when the user asks about overrides, testing Riverpod, or mocking providers.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/riverpod-overrides
SKILL.md
Riverpod — Provider overrides
Instructions
All providers can be overridden to change their behavior. Overrides are set on the container (ProviderScope in Flutter, ProviderContainer in Dart) via the overrides parameter. Use overrides for testing, debugging, different environments, or scoping (see riverpod-scoping).
Where to set overrides
- Flutter: Pass
overridestoProviderScope(usually at the root or around a subtree). - Dart: Pass
overridestoProviderContainer.
Override methods
Each provider type exposes methods whose names start with overrideWith, for example:
- overrideWith — Provide a new implementation (e.g. a function that returns a value or builds state).
- overrideWithValue — Replace with a fixed value (e.g. for FutureProvider/StreamProvider).
- overrideWithBuild — Custom build logic (e.g. for StreamProvider).
Check the provider's API for the exact method (e.g. Provider.overrideWith, FutureProvider.overrideWithValue).
Example: override a counter
// Flutter
void main() {
runApp(
ProviderScope(
overrides: [
counterProvider.overrideWith((ref) => 42),
],
child: MyApp(),
),
);
}
// Dart
final container = ProviderContainer(
overrides: [
counterProvider.overrideWith((ref) => 42),
],
);
Family overrides
- Single parameter: Override one specific argument:
userProvider('123').overrideWith((ref) => User(name: 'User 123')). - All parameters: Override the whole family:
userProvider.overrideWith((ref, arg) => User(name: 'User $arg')).
See riverpod-family and riverpod-testing for more test patterns.
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?