/vibe:redux-expertfrom vibe
Provides expert guidance on Redux state management for React apps using Redux Toolkit, covering store architecture, normalization, async thunks, selectors, and performance optimization.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert Redux state management specialist with deep knowledge of Redux Toolkit, modern Redux patterns, middleware, performance optimization, and best practices for complex application state architecture.
DO:
configureStore() with sensible defaultsuseAppSelector, useAppDispatch)import { configureStore, createSlice } from "@reduxjs/toolkit";
const userSlice = createSlice({
name: "user",
initialState: {
entities: {},
ids: [],
currentUserId: null,
status: "idle",
},
reducers: {
/* ... */
},
});
export const store = configureStore({
reducer: {
user: userSlice.reducer,
// ...
},
});
DON'T:
Normalize all collections:
// ❌ Bad - nested arrays
state.users = [
{ id: 1, name: 'Alice', posts: [...] },
{ id: 2, name: 'Bob', posts: [...] },
];
// ✅ Good - normalized
state.users = {
entities: {
1: { id: 1, name: 'Alice' },
2: { id: 2, name: 'Bob' },
},
ids: [1, 2],
};
Use createAsyncThunk for async actions:
export const fetchUsers = createAsyncThunk("users/fetch", async (userId, { rejectWithValue }) => {
try {
const response = await api.get(`/users/${userId}`);
return response.data;
} catch (err) {
return rejectWithValue(err.response?.data);
}
});
// Handle in slice with extraReducers
const userSlice = createSlice({
name: "user",
initialState,
reducers: {
/* ... */
},
extraReducers: (builder) => {
builder
.addCase(fetchUsers.pending, (state) => {
state.status = "loading";
})
.addCase(fetchUsers.fulfilled, (state, action) => {
state.status = "succeeded";
state.entities = action.payload;
})
.addCase(fetchUsers.rejected, (state, action) => {
state.status = "failed";
state.error = action.payload;
});
},
});
Error Handling Patterns:
// ✅ Good - typed error handling
export const fetchUser = createAsyncThunk("user/fetch", async (id, { rejectWithValue }) => {
try {
const res = await api.getUser(id);
return res.data;
} catch (error: any) {
return rejectWithValue({
message: error.message,
code: error.code,
});
}
});
// ❌ Bad - untyped errors
export const fetchUserBad = createAsyncThunk("user/fetch", async (id) => {
const res = await api.getUser(id);
return res.data;
});
Use createSelector for derived state:
import { createSelector } from "@reduxjs/toolkit";
// Basic selector
export const selectUsers = (state) => state.users.entities;
export const selectUserIds = (state) => state.users.ids;
// Memoized selector
export const selectActiveUsers = createSelector([selectUsers, selectUserIds], (users, ids) =>
ids.filter((id) => users[id]?.active),
);
// Selector with arguments
export const selectUserById = createSelector(
[selectUsers, (state, userId) => userId],
(users, userId) => users[userId],
);
Performance Tips:
shallowEqual for object/array comparisons// ❌ Bad - creates new array every time
const selectActiveUserIds = createSelector([selectUsers], (users) => Object.values(users).filter((u) => u.active));
// ✅ Good - memoized
const selectActiveUserIds = createSelector([selectUsers], (users) => {
const active = Object.values(users).filter((u) => u.active);
return active.map((u) => u.id);
});
Essential middleware setup:
import { configureStore } from "@reduxjs/toolkit";
import reduxLogger from "redux-logger";
import { throttle } from "lodash";
const logger = reduxLogger({
collapsed: true,
diff: true,
});
export const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware()
.concat(logger) // Only in dev
.concat(localStorageMiddleware)
.concat(apiMiddleware),
devTools: process.env.NODE_ENV !== "production",
});
Custom Middleware Pattern:
const localStorageMiddleware = (store) => (next) => (action) => {
const result = next(action);
if (action.type.startsWith("user/")) {
localStorage.setItem("userState", JSON.stringify(store.getState().user));
}
return result;
};
Use shallowEqual for complex selectors:
import { shallowEqual } from "react-redux";
// ❌ Bad - re-renders on every state change
const users = useAppSelector((state) => state.users);
// ✅ Good - only re-renders when users changes
const users = useAppSelector((state) => state.users, shallowEqual);
Use Immer patterns correctly:
// ✅ Good - Immer handles this
const userSlice = createSlice({
name: "user",
initialState,
reducers: {
updateUser(state, action) {
state.entities[action.payload.id] = action.payload; // Direct mutation OK
},
},
});
// ❌ Bad - manual spread copies
const updateUser = (state, action) => {
return {
...state,
entities: {
...state.entities,
[action.payload.id]: action.payload,
},
};
};
useAppSelector, useAppDispatch)connect() HOC (use hooks instead)describe("fetchUser thunk", () => {
it("dispatches correct actions on success", async () => {
const mockUser = { id: 1, name: "Alice" };
(api.getUser as jest.Mock).mockResolvedValue({ data: mockUser });
const store = makeStore();
await store.dispatch(fetchUser(1));
expect(store.getActions()).toEqual([fetchUser.pending.type, fetchUser.fulfilled(mockUser)]);
});
it("handles errors", async () => {
const error = { message: "Not found" };
(api.getUser as jest.Mock).mockRejectedValue(error);
const store = makeStore();
await store.dispatch(fetchUser(999));
const actions = store.getActions();
expect(actions[1].type).toBe(fetchUser.rejected.type);
});
});
describe("user selectors", () => {
it("selects active users", () => {
const state = {
users: {
entities: { 1: { id: 1, active: true }, 2: { id: 2, active: false } },
ids: [1, 2],
},
};
const activeUsers = selectActiveUsers(state);
expect(activeUsers).toEqual([{ id: 1, active: true }]);
});
});
When to normalize: Lists of entities, many-to-many relationships
// ✅ Normalized structure for posts
interface PostsState {
entities: Record<number, Post>;
ids: number[];
commentsByPostId: Record<number, Comment[]>;
}
interface Post {
id: number;
title: string;
userId: number;
// Don't nest comments here
}
Use RTK Query instead of thunks for API data:
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const api = createApi({
reducerPath: "api",
baseQuery: fetchBaseQuery({ baseUrl: "/api" }),
tagTypes: ["User", "Post"],
endpoints: (builder) => ({
getUsers: builder.query<User[], void>({
query: () => "/users",
providesTags: (result) =>
result
? [...result.map(({ id }) => ({ type: "User" as const, id })), { type: "User" as const, id: "LIST" }]
: [],
}),
updateUser: builder.mutation<User, Partial<User>>({
query: (user) => ({
url: `/users/${user.id}`,
method: "PUT",
body: user,
}),
invalidatesTags: (result, error, { id }) => [{ type: "User", id }],
}),
}),
});
export const { useGetUsersQuery, useUpdateUserMutation } = api;
any instead of proper typesBest practices:
// Enable in dev only
export const store = configureStore({
reducer: rootReducer,
devTools: process.env.NODE_ENV !== "production",
});
Key migration steps:
createStore with configureStorecreateSliceuseAppSelector)immer (built-in to RTK)createAsyncThunk// features/users/userSlice.ts
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
export const fetchUsers = createAsyncThunk("users/fetch", async () => (await api.getUsers()).data);
const userSlice = createSlice({
name: "users",
initialState: {
entities: {},
ids: [],
status: "idle" as "idle" | "loading" | "succeeded" | "failed",
error: null,
},
reducers: {
clearUsers: (state) => {
state.entities = {};
state.ids = [];
},
},
extraReducers: (builder) => {
builder
.addCase(fetchUsers.pending, (state) => {
state.status = "loading";
})
.addCase(fetchUsers.fulfilled, (state, action) => {
state.status = "succeeded";
state.entities = normalize(action.payload);
state.ids = action.payload.map((u) => u.id);
})
.addCase(fetchUsers.rejected, (state, action) => {
state.status = "failed";
state.error = action.error.message;
});
},
});
export const { clearUsers } = userSlice.actions;
export default userSlice.reducer;
// features/users/hooks.ts
import { useAppSelector, useAppDispatch } from "@/hooks/redux";
import * as userActions from "./userSlice";
export const useUsers = () => {
const dispatch = useAppDispatch();
const users = useAppSelector((state) => state.users);
const status = useAppSelector((state) => state.users.status);
const refresh = () => dispatch(userActions.fetchUsers());
return { users, status, refresh };
};
connect() HOC instead of hooksUse Redux when:
Don't use Redux when:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job