Build React SPAs where components are declarative UI consuming external state (Zustand/XState/TanStack Query). Logic lives in stores, not components.
Builds React SPAs where components are declarative UI that consume external state (Zustand/XState/TanStack Query). Logic lives in stores, not components.
/plugin marketplace add codethread/claude-code-plugins/plugin install langs@codethread-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
CLAUDE.mdComponents consume external state, contain no logic:
| State Type | Solution |
|---|---|
| Remote (REST) | TanStack Query |
| Remote (GraphQL) | Apollo Client |
| Application state | Zustand |
| Complex machines | XState |
| Local UI state | useState (rare, last resort) |
// ✅ External hooks → Early returns → JSX
function UserProfile({ userId }: { userId: string }) {
const { user, isLoading } = useUser(userId);
const { updateProfile } = useUserActions();
if (isLoading) return <Spinner />;
return (
<div>
<h1>{user.name}</h1>
<button onClick={() => updateProfile({ email: 'new@example.com' })}>
Update
</button>
</div>
);
}
| What | Tool | Why |
|---|---|---|
| Zustand stores | Vitest | Test without React |
| XState machines | Vitest | Deterministic transitions |
| Critical flows | Playwright | Real browser |
| Components | Never | Logic should be in stores |
// Test store directly
const { login } = useAuthStore.getState();
await login({ email: "test@example.com", password: "pass" });
expect(useAuthStore.getState().user).toBeDefined();
<Table
data={items}
loading={isLoading}
sortable
onSort={handleSort}
renderRow={(item) => <Row>{item.name}</Row>}
/>
// ✅ Inline - TypeScript infers types
<SearchableList
items={budgets}
renderItem={(budget) => <Card name={budget.name} />}
/>;
// ❌ Extract only if repeated 2+ times
const renderItem = (budget: Budget) => <Card name={budget.name} />;
import { match } from "ts-pattern";
{
match(state)
.with({ _tag: "loading" }, () => <Spinner />)
.with({ _tag: "success" }, (s) => <Data value={s.data} />)
.exhaustive();
}
| Technique | When |
|---|---|
| useMemo | Profiled as slow |
| useCallback | Repeated 2+ times |
| React.memo | Props rarely change |
| Code splitting | Route-level |
// ✅ Single component with CSS selectors
const Table = styled.table`
thead {
background: ${(p) => p.theme.colors.header};
}
tbody tr:hover {
background: ${(p) => p.theme.colors.hover};
}
td {
padding: ${(p) => p.theme.space.md};
}
`;
// ❌ Separate components for each element
const TableHeader = styled.thead`...`;
const TableRow = styled.tr`...`;
const TableCell = styled.td`...`;
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.