---
name: vuex-redux-saga-integration-to-pinia-effects
description: Use when a Vuex codebase uses redux-saga (or saga-like orchestration) and you need to migrate side effects safely while moving state to Pinia.
enabled: false
source: github:JuanJoseGonGi/skills
imported-from: github:JuanJoseGonGi/skills
---

# Vuex Redux-Saga Integration to Pinia Effects

## Overview

Use this skill when your store migration is blocked by saga orchestration.

In large legacy codebases, sagas are often wired from the store entry and depend on action streams. Migrating state without a side-effect plan causes regressions.

## Migration Strategies

1. **Bridge First (recommended for large codebases)**
   - Keep sagas temporarily.
   - Emit Pinia action lifecycle events into a saga-compatible bus.

2. **Domain Rewrite**
   - Replace sagas with store actions + service layer + composables.
   - Better long-term maintainability, higher up-front cost.

3. **Hybrid**
   - Bridge critical flows first.
   - Rewrite low-risk sagas incrementally.

## Bridge Pattern

```ts
// pinia plugin sketch
pinia.use(({ store }) => {
  store.$onAction(({ name, args, after, onError }) => {
    actionBus.next({ type: `${store.$id}/${name}`, payload: args })
    after((result) => actionBus.next({ type: `${store.$id}/${name}/success`, payload: result }))
    onError((error) => actionBus.next({ type: `${store.$id}/${name}/error`, error }))
  })
})
```

## Workflow

1. Inventory sagas by domain and criticality.
2. Define target per saga: bridge, rewrite now, or rewrite later.
3. Build one action bus adapter for Pinia.
4. Migrate one domain end-to-end and verify behavior.
5. Remove Vuex `subscribeAction` and saga wiring only after all dependent flows are moved.

## Done Criteria

- Every active saga has a mapped Pinia trigger path.
- No production flow depends on removed Vuex action streams.
- Side-effect tests pass for success, error, and cancellation paths.

## Common Pitfalls

- Rewriting all sagas at once without domain slicing.
- Losing cancellation semantics (`takeLatest`, race) during action rewrites.
- Duplicating side effects by running both old and new listeners at the same time.
