State Management
Provides architectural guidance for complex state management in frontend applications like React and Vue.
Install
mkdir -p .claude/skills/state-management-tuyenht && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13861" && unzip -o skill.zip -d .claude/skills/state-management-tuyenht && rm skill.zipInstalls to .claude/skills/state-management-tuyenht
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Mô hình quản lý trạng thái luồng dữ liệu (Redux, Zustand, Pinia) hiệu quả bền.Key capabilities
- →Manage complex frontend state
- →Implement Redux Toolkit patterns
- →Implement Zustand for state management
- →Implement Pinia for state management
- →Optimize state performance
- →Normalize state for relational data
How it works
The skill provides patterns for managing application state across frameworks, including React and Vue, and offers guidance on performance optimization techniques.
Inputs & outputs
When to use State Management
- →Select a state management library
- →Optimize state performance
- →Implement Redux Toolkit in React
- →Sync global and local state
About this skill
State Management Patterns
Comprehensive patterns for managing application state across frameworks.
When to Use This Skill
- Complex frontend state
- Choosing state management solution
- Redux/Zustand implementation (React)
- Pinia implementation (Vue)
- State synchronization
- Performance optimization
Content Map
React State Management
- react-state.md - useState, useReducer, Context
- Redux Toolkit patterns
- Zustand (lightweight alternative)
- Jotai (atomic state)
- When to use each
Vue State Management
- vue-state.md - Reactive state, Composition API
- Pinia patterns
- Vuex (legacy)
State Patterns
- patterns.md - Common patterns
- Global vs local state
- Derived state
- Async state
- State normalization
Performance
- performance.md - Optimization techniques
- Selector memoization
- Preventing re-renders
- State slicing
Quick Reference
React - useState (Local State)
const [count, setCount] = useState(0);
const [user, setUser] = useState<User | null>(null);
// Update object state
setUser(prev => ({ ...prev, name: 'John' }));
React - Context (Medium Complexity)
const UserContext = createContext<User | null>(null);
function UserProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<User | null>(null);
return (
<UserContext.Provider value={{ user, setUser }}>
{children}
</UserContext.Provider>
);
}
// Usage
const { user } = useContext(UserContext);
React - Redux Toolkit (Complex Apps)
// Slice
const counterSlice = createSlice({
name: 'counter',
initialState: { value: 0 },
reducers: {
increment: (state) => {
state.value += 1; // Immer makes this safe
},
decrement: (state) => {
state.value -= 1;
},
},
});
// Store
const store = configureStore({
reducer: {
counter: counterSlice.reducer,
},
});
// Usage
const count = useSelector((state: RootState) => state.counter.value);
const dispatch = useDispatch();
dispatch(increment());
React - Zustand (Simple & Fast)
import create from 'zustand';
const useStore = create<State>((set) => ({
count: 0,
increment: () => set((state) => ({ count: state.count + 1 })),
decrement: () => set((state) => ({ count: state.count - 1 })),
}));
// Usage
const { count, increment } = useStore();
Vue - Pinia
import { defineStore } from 'pinia';
export const useCounterStore = defineStore('counter', {
state: () => ({
count: 0,
}),
getters: {
doubleCount: (state) => state.count * 2,
},
actions: {
increment() {
this.count++;
},
},
});
// Usage
const store = useCounterStore();
store.increment();
Decision Tree
Choose State Management:
Local Component State?
→ useState/reactive (Vue)
Shared Across Few Components?
→ Context API/Provide-Inject
Complex Global State?
→ Redux Toolkit/Pinia
Simple Global State?
→ Zustand/Pinia
Atomic Updates?
→ Jotai/Recoil
Anti-Patterns
❌ Everything in global state → Keep local when possible
❌ Prop drilling > 3 levels → Use context/state management
❌ No state normalization → Duplicate data
❌ Mutating state directly → Use immutable updates
❌ Over-engineering → useState often sufficient
Best Practices
✅ Start simple - useState/reactive first
✅ Normalize state for relational data
✅ Memoize selectors (useSelector, computed)
✅ Separate UI vs server state (React Query for server)
✅ DevTools for debugging
✅ TypeScript for type safety
Performance Tips
// ✅ Good - Memoized selector
const selectUser = createSelector(
(state: RootState) => state.users,
(users) => users.find(u => u.active)
);
// ✅ Good - Prevent re-renders
const Component = memo(({ data }) => {
return <div>{data}</div>;
});
// ✅ Good - State slicing (Zustand)
const count = useStore(state => state.count); // Only re-renders when count changes
Related Skills
react-patterns- React component patternsperformance-profiling- Performance optimization
Official Resources
When not to use it
- →When state is simple and local to a component
- →When state is shared across few components
Limitations
- →The skill does not cover server state management, suggesting external tools like React Query for that purpose.
- →The skill advises against putting everything in global state.
- →The skill advises against prop drilling beyond three levels.
How it compares
This skill offers structured patterns and decision trees for various state management libraries, unlike manually choosing a library without considering specific application needs.
Compared to similar skills
State Management side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| State Management (this skill) | 0 | 5mo | No flags | Intermediate |
| moai-domain-frontend | 1 | 3mo | No flags | Advanced |
| perf-web-optimization | 1 | 5mo | Review | Intermediate |
| astro | 0 | 3mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by tuyenht
View all by tuyenht →You might also like
moai-domain-frontend
modu-ai
Frontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implementing components, optimizing frontend performance, or integrating state management.
perf-web-optimization
tech-leads-club
Optimize web performance: Core Web Vitals (LCP, CLS, INP), bundle size, images, caching. Use when site is slow, optimizing for Lighthouse scores, reducing bundle size, fixing layout shifts, or improving Time to Interactive. Triggers on: web performance, Core Web Vitals, LCP, CLS, INP, FID, bundle size, page speed, slow site.
astro
Anhvu1107
ALWAYS use this when the request matches Astro: Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.
frontend-developer
bonnguyenitc
Use when building web UI, designing component architecture, or reviewing frontend code — regardless of framework (React, Vue, Svelte, etc.)
optimize
aladicf
Diagnose and fix UI performance across loading speed, rendering, animations, images, and bundle size. Use when the user mentions slow, laggy, janky, performance, bundle size, load time, or wants a faster, smoother experience.
screenshot-to-code
OneWave-AI
Convert UI screenshots into working HTML/CSS/React/Vue code. Detects design patterns, components, and generates responsive layouts. Use this when users provide screenshots of websites, apps, or UI designs and want code implementation.