一键导入
lang-react
Build React SPAs where components are declarative UI consuming external state (Zustand/XState/TanStack Query). Logic lives in stores, not components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build React SPAs where components are declarative UI consuming external state (Zustand/XState/TanStack Query). Logic lives in stores, not components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Bootstrap a new project with the BDFL architecture
Incrementally migrate an existing project toward the BDFL architecture
Mandatory when configuring any Claude Code specifics - hooks, skills, plugins, MCP servers, slash commands, settings, agents, or any Claude Code feature. Provides opinionated best practices
Write clear, effective technical documentation following industry-proven patterns from exemplary projects and authoritative style guides, with built-in countermeasures for common LLM documentation issues
Write clean, type-safe TypeScript code using modern patterns, strict configuration, and best practices. Use when writing TypeScript code, configuring projects, or solving type-related challenges.
基于 SOC 职业分类
| name | lang-react |
| description | Build React SPAs where components are declarative UI consuming external state (Zustand/XState/TanStack Query). Logic lives in stores, not components. |
REACT_TASK: $ARGUMENTS (if provided) or current React implementation taskApply these patterns to $REACT_TASK.
Components 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`...`;