---
name: "redux-toolkit-rtk-query-slices"
description: "Standardize enterprise state management with Redux Toolkit slices and RTK Query auto-caching."
metadata:
  author: "Redux"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create rtk query api"
  - "configure redux toolkit store"
  - "invalidate tags rtk query"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Redux Toolkit (RTK) & RTK Query API Caching

Implements Redux Toolkit: creating slices with createSlice and Immer mutations, defining API services with createApi and fetchBaseQuery, automatic tag invalidation (providesTags, invalidatesTags), and typed hooks.

## When to Invoke
Invoke this skill whenever you need to:
- create rtk query api
- configure redux toolkit store
- invalidate tags rtk query

## Execution SOP & Rules
1. Define API with createApi: baseQuery: fetchBaseQuery({ baseUrl: '/api' }), tagTypes: ['Post'].
2. Declare queries: getPosts: builder.query({ query: () => '/posts', providesTags: ['Post'] }).
3. Declare mutations: addPost: builder.mutation({ query: body => ({ url: '/posts', method: 'POST', body }), invalidatesTags: ['Post'] }).
4. Attach API middleware to store configuration: middleware: getDefault => getDefault().concat(api.middleware).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
