react-patterns
Use when building or reviewing React frontends: component architecture, hooks, TypeScript patterns, state management, file structure
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when building or reviewing React frontends: component architecture, hooks, TypeScript patterns, state management, file structure
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when AI agents perform most implementation work and humans enforce quality and risk controls.
REST API design patterns including resource naming, status codes, pagination, filtering, error responses, versioning, and rate limiting for production APIs.
Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up deployment infrastructure or planning releases.
Use when generating or validating the ExecutionPlan JSON that the orchestrator must produce before spawning any agents
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
Research-before-coding workflow. Search for existing tools, libraries, and patterns before writing custom code. Systematizes the "search for existing solutions before implementing" approach. Use when starting new features or adding functionality.
| name | react-patterns |
| description | Use when building or reviewing React frontends: component architecture, hooks, TypeScript patterns, state management, file structure |
src/
├── app/ ← routing, layouts (Next.js app router or React Router)
├── components/
│ ├── ui/ ← generic, reusable (Button, Input, Modal)
│ └── features/ ← feature-specific (AuthForm, UserCard)
├── hooks/ ← custom hooks
├── services/ ← API calls (no fetch in components)
├── stores/ ← global state (Zustand / Jotai)
├── types/ ← shared TypeScript types
└── utils/ ← pure utility functions
// Prefer named exports for components
export function UserCard({ user, onEdit }: UserCardProps) {
return (...)
}
// Types defined above the component, not inline
interface UserCardProps {
user: User
onEdit: (id: string) => void
}
Extract logic from components into hooks:
// hooks/useAuth.ts
export function useAuth() {
const [user, setUser] = useState<User | null>(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
authService.getMe()
.then(setUser)
.finally(() => setLoading(false))
}, [])
return { user, loading, isAuthenticated: !!user }
}
// Usage — component stays clean
export function Header() {
const { user, isAuthenticated } = useAuth()
return isAuthenticated ? <UserMenu user={user!} /> : <LoginButton />
}
// services/users.ts — API calls isolated here
export const usersService = {
getById: (id: string) =>
fetch(`/api/users/${id}`).then(r => r.json()),
}
// hooks/useUser.ts
export function useUser(id: string) {
return useQuery({
queryKey: ["users", id],
queryFn: () => usersService.getById(id),
})
}
// Component stays simple
export function UserPage({ id }: { id: string }) {
const { data: user, isPending, error } = useUser(id)
if (isPending) return <Spinner />
if (error) return <ErrorMessage error={error} />
return <UserCard user={user} />
}
// stores/authStore.ts
import { create } from "zustand"
interface AuthStore {
user: User | null
setUser: (user: User | null) => void
}
export const useAuthStore = create<AuthStore>((set) => ({
user: null,
setUser: (user) => set({ user }),
}))
import { useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import { z } from "zod"
const schema = z.object({
email: z.string().email(),
password: z.string().min(8),
})
type FormData = z.infer<typeof schema>
export function LoginForm({ onSuccess }: { onSuccess: () => void }) {
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
resolver: zodResolver(schema),
})
const onSubmit = async (data: FormData) => {
await authService.login(data)
onSuccess()
}
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register("email")} />
{errors.email && <span>{errors.email.message}</span>}
</form>
)
}
fetch directly in a componentanyUserCard.test.tsx)