Skip to main content
skill CX Codex

redux-toolkit — Claude Code skill: what it does, how to install

Redux Toolkit best practices for React and Next.js applications using TypeScript. Helps structure feature slices, typed hooks, and RTK Query endpoints.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Mindrally/skills --skill redux-toolkit -a claude-code
Open on GitHub

What redux-toolkit does

The skill instructs the coding agent on Redux Toolkit state management conventions. It enforces feature-based slices with createSlice and encapsulated state access via createSelector. For remote data fetching and cache invalidation, it guides the model toward RTK Query and createAsyncThunk.

It establishes clear TypeScript conventions. Strict mode is expected, interfaces take precedence over types for object models, and components must rely on typed useAppDispatch and useAppSelector hooks. Error handling pairs with Zod validation, while unit testing relies on Jest and React Testing Library following the Arrange-Act-Assert pattern.

The skill enforces strict separation by feature. Generating state for a monolithic single-file store will conflict directly with its rules.

What it helps with

  • generate feature slices using createSlice
  • implement data fetching and caching with RTK Query
  • configure typed useAppDispatch and useAppSelector hooks
  • write tests for reducers and selectors using React Testing Library

Example prompts for the agent

  • Create a shopping cart slice using Redux Toolkit and TypeScript interfaces
  • Set up an RTK Query API slice for user profile fetching with cache invalidation
  • Write unit tests for my auth thunk using Jest and Arrange-Act-Assert

How to install redux-toolkit

1Skills CLI (Vercel)

npx skills add Mindrally/skills --skill redux-toolkit -a claude-code

2Manually: put the files in place

~/.claude/skills/redux-toolkit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/redux-toolkit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about redux-toolkit

How to install redux-toolkit in Claude Code?

Run npx skills add Mindrally/skills --skill redux-toolkit -a claude-code in your terminal.

What does the redux-toolkit skill do?

It guides the AI assistant to follow Redux Toolkit patterns in React and Next.js, including typed hooks, normalized slices, and RTK Query caching.

Which libraries does this skill prescribe for validation and tests?

It specifies Zod for input validation and Jest with React Testing Library for testing reducers and selectors independently.

Source text

SKILL.md · Apache-2.0
---
name: redux-toolkit
description: Comprehensive Redux Toolkit best practices for React and Next.js applications with TypeScript.
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Redux Toolkit

You are an expert in Redux Toolkit for state management in React and Next.js applications.

## Development Philosophy

- Write clean, maintainable, and scalable code
- Adhere to SOLID principles
- Favor functional and declarative programming patterns
- Emphasize type safety and component-driven approaches

## Redux State Management

### Core Principles
- Implement Redux Toolkit for global state management
- Use createSlice to define state, reducers, and actions together
- Normalize state structure to prevent deeply nested data
- Employ selectors to encapsulate state access
- Separate concerns by feature; avoid monolithic slices

### Slice Structure
```typescript
import { createSlice, PayloadAction } from '@reduxjs/toolkit'

interface CounterState {
  value: number
  isLoading: boolean
}

const initialState: CounterState = {
  value: 0,
  isLoading: false,
}

const counterSlice = createSlice({
  name: 'counter',
  initialState,
  reducers: {
    increment: (state) => {
      state.value += 1
    },
    setLoading: (state, action: PayloadAction<boolean>) => {
      state.isLoading = action.payload
    },
  },
})

export const { increment, setLoading } = counterSlice.actions
export default counterSlice.reducer
```

## Naming Conventions

- **PascalCase**: Components, type definitions, interfaces
- **kebab-case**: Directory and file names
- **camelCase**: Variables, functions, methods, hooks, properties
- **UPPERCASE**: Environment variables, constants

### Prefixes
- Event handlers: `handle` (e.g., `handleClick`)
- Boolean variables: verbs (e.g., `isLoading`, `hasError`)
- Custom hooks: `use` (e.g., `useAuth`)

## TypeScript Integration

- Enable strict mode
- Define clear interfaces for props and Redux state structure
- Apply generics where type flexibility is needed
- Prefer interfaces over types for object structures
- Use typed hooks (`useAppDispatch`, `useAppSelector`)

## Async Operations

### RTK Query
- Use RTK Query for data fetching and caching
- Define API slices with endpoints
- Leverage automatic cache invalidation
- Implement optimistic updates when appropriate

### createAsyncThunk
```typescript
export const fetchUser = createAsyncThunk(
  'user/fetch',
  async (userId: string, { rejectWithValue }) => {
    try {
      const response = await api.getUser(userId)
      return response.data
    } catch (error) {
      return rejectWithValue(error.message)
    }
  }
)
```

## Performance Optimization

- Use React.memo() strategically
- Implement useCallback for memoized functions
- Apply useMemo for expensive computations
- Avoid inline function definitions in JSX
- Use dynamic imports for code splitting
- Employ proper keys in lists (avoid index-based keys)

## Selectors

- Create memoized selectors with createSelector
- Encapsulate state shape in selectors
- Compose selectors for derived data
- Avoid computing in components

## Error Handling

- Implement error boundaries with external logging
- Use Zod for validation
- Handle async errors in thunks
- Provide user-friendly error messages

## Testing

- Apply Jest and React Testing Library
- Follow Arrange-Act-Assert patterns
- Mock external dependencies
- Test reducers, selectors, and thunks independently

© Mindrally · Apache-2.0 · Mindrally/skills

Similar skills

Everything for Frontend and UI →

From the same set236

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor