Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

state-management

verified

Patterns for managing application state - local, global, server, and URL state

View on GitHub

Marketplace

alphaagent-team

the-answerai/alphaagent-team

Plugin

aai-dev-frontend

dev

Repository

the-answerai/alphaagent-team

plugins/aai-dev-frontend/skills/state-management/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-dev-frontend/skills/state-management/SKILL.md -a claude-code --skill state-management

Installation paths:

Claude
.claude/skills/state-management/
Powered by add-skill CLI

Instructions

# State Management Skill

Patterns for choosing and implementing state management strategies in frontend applications.

## State Categories

### 1. Local UI State
State that only affects a single component.

```typescript
// Form input values
const [value, setValue] = useState('');

// Toggle states
const [isOpen, setIsOpen] = useState(false);

// Loading/error states
const [status, setStatus] = useState<'idle' | 'loading' | 'error'>('idle');
```

### 2. Shared UI State
State shared between components (lift state up or use context).

```typescript
// Theme context
const ThemeContext = createContext<Theme>('light');

function ThemeProvider({ children }) {
  const [theme, setTheme] = useState<Theme>('light');

  return (
    <ThemeContext.Provider value={{ theme, setTheme }}>
      {children}
    </ThemeContext.Provider>
  );
}
```

### 3. Server State
Data from external sources (use TanStack Query, SWR, or similar).

```typescript
// TanStack Query
const { data, isLoading, error } = useQuery({
  queryKey: ['users'],
  queryFn: fetchUsers,
  staleTime: 5 * 60 * 1000, // 5 minutes
});

// Mutations
const mutation = useMutation({
  mutationFn: createUser,
  onSuccess: () => {
    queryClient.invalidateQueries({ queryKey: ['users'] });
  },
});
```

### 4. URL State
State that should be shareable/bookmarkable.

```typescript
// Next.js App Router
import { useSearchParams, useRouter } from 'next/navigation';

function FilteredList() {
  const searchParams = useSearchParams();
  const router = useRouter();

  const filter = searchParams.get('filter') || 'all';

  const setFilter = (value: string) => {
    const params = new URLSearchParams(searchParams);
    params.set('filter', value);
    router.push(`?${params.toString()}`);
  };

  return <Filters value={filter} onChange={setFilter} />;
}
```

## State Management Libraries

### When to Use What

| Use Case | Solution |
|----------|----------|
| Simple local state | `useState` |
| Complex local state | `useReducer` |
| 

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5778 chars