# Riverpod Scoping

> Scope Riverpod providers to a subtree using overrides and dependencies; page-specific behavior, ListView optimization, avoiding passing family parameters. Use when changing provider behavior for one page or widget, or when optimizing rebuilds. Use this skill when the user asks about scoping providers or provider scope.

- **Type:** Skill
- **Install:** `agentstack add skill-serverpod-skills-registry-riverpod-scoping`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [serverpod](https://agentstack.voostack.com/s/serverpod)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** BSD-3-Clause
- **Upstream author:** [serverpod](https://github.com/serverpod)
- **Source:** https://github.com/serverpod/skills-registry/tree/main/skills/riverpod/riverpod-scoping

## Install

```sh
agentstack add skill-serverpod-skills-registry-riverpod-scoping
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Riverpod — Scoping providers

## Instructions

**Scoping** means changing a provider's behavior for only part of the app by overriding it in a **non-root** ProviderScope. Use cases: page-specific customization (e.g. theme for one page), performance (e.g. rebuild only the item that changed in a ListView), or avoiding passing family parameters through the tree.

**Note:** Scoping is complex and may be reworked in future Riverpod versions. Use with care.

### Opt-in: dependencies

By default you cannot scope a provider. Opt in by setting **dependencies** on the provider. The first scoped provider usually has `dependencies: const []`.

```dart
final currentItemIdProvider = Provider(
  dependencies: const [],
  (ref) => null,
);
```

### Listening to a scoped provider

Use ref.watch/ref.read as usual. If another **provider** listens to a scoped provider, that listening provider must list the scoped provider in its **dependencies**:

```dart
final currentItemProvider = FutureProvider(
  dependencies: [currentItemIdProvider],
  (ref) async {
    final currentItemId = ref.watch(currentItemIdProvider);
    if (currentItemId == null) return null;
    return fetchItem(id: currentItemId);
  },
);
```

Only scoped providers need to be listed in dependencies; non-scoped providers do not.

### Setting the scoped value: overrides

Use **overrides** on a ProviderScope that wraps the subtree where the scoped value should apply:

```dart
ProviderScope(
  overrides: [
    currentItemIdProvider.overrideWithValue('123'),
  ],
  child: const DetailPageView(),
)
```

That way the detail page sees `'123'` as the current item ID without it being passed down manually. See riverpod-overrides for override syntax.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [serverpod](https://github.com/serverpod)
- **Source:** [serverpod/skills-registry](https://github.com/serverpod/skills-registry)
- **License:** BSD-3-Clause

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-serverpod-skills-registry-riverpod-scoping
- Seller: https://agentstack.voostack.com/s/serverpod
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
