一键导入
react-feature
Use when implementing a new React feature, page, component, or hook in a Vite/Bun frontend with testing-library
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when implementing a new React feature, page, component, or hook in a Vite/Bun frontend with testing-library
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the user wants to free disk space, investigate disk usage, clean caches, remove unused artifacts, or when disk capacity is high. Also use when asked to "clean up", "free space", "disk full", or "what's using disk space". Always uses AskUserQuestion for every deletion decision.
Use at the start of every conversation and for every user message — orchestrates the full engineering skills suite by understanding intent, clarifying requirements interactively, and invoking the right skills
Use when refactoring Go code, cleaning up legacy codebases, optimizing performance, or enforcing clean architecture boundaries in a Go/Fiber backend
Use when refactoring Python code, cleaning up legacy codebases, optimizing performance, enforcing type safety, or improving clean architecture in a FastAPI backend
Use when refactoring React components, cleaning up legacy frontends, optimizing performance, improving component architecture, or reducing bundle size
Use when reviewing changed code before committing or after completing a feature — checks performance, architecture, type safety, and code quality against project standards
| name | react-feature |
| description | Use when implementing a new React feature, page, component, or hook in a Vite/Bun frontend with testing-library |
TDD workflow for React features using Vitest + testing-library. User-centric testing with MSW for API mocking.
Core principle: Test what users see and do, not implementation details.
src/features/users/
components/
UserList.tsx
UserList.test.tsx
UserForm.tsx
UserForm.test.tsx
hooks/
useUsers.ts
useUsers.test.ts
api/
users.ts
types/
index.ts
index.ts # public API barrel export
Test first:
// UserList.test.tsx
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { UserList } from './UserList'
describe('UserList', () => {
it('renders users', () => {
render(<UserList users={[{ id: '1', name: 'Alice', email: 'a@b.com' }]} />)
expect(screen.getByText('Alice')).toBeInTheDocument()
})
it('calls onDelete when delete button clicked', async () => {
const onDelete = vi.fn()
const user = userEvent.setup()
render(<UserList users={[{ id: '1', name: 'Alice', email: 'a@b.com' }]} onDelete={onDelete} />)
await user.click(screen.getByRole('button', { name: /delete/i }))
expect(onDelete).toHaveBeenCalledWith('1')
})
})
import { renderHook, waitFor } from '@testing-library/react'
import { useUsers } from './useUsers'
import { QueryClientProvider, QueryClient } from '@tanstack/react-query'
function wrapper({ children }: { children: React.ReactNode }) {
return <QueryClientProvider client={new QueryClient()}>{children}</QueryClientProvider>
}
it('fetches users', async () => {
const { result } = renderHook(() => useUsers(), { wrapper })
await waitFor(() => expect(result.current.isSuccess).toBe(true))
expect(result.current.data).toHaveLength(2)
})
// src/mocks/handlers.ts
import { http, HttpResponse } from 'msw'
export const handlers = [
http.get('/api/v1/users', () => {
return HttpResponse.json({
data: [{ id: '1', name: 'Alice', email: 'a@b.com' }],
})
}),
]
// src/mocks/server.ts
import { setupServer } from 'msw/node'
import { handlers } from './handlers'
export const server = setupServer(...handlers)
// vitest.setup.ts
beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
| Pattern | When |
|---|---|
useState | Local component state |
useReducer | Complex state transitions |
| React Query | Server state (fetching, caching) |
| Context | Shared UI state (theme, auth) |
| URL params | Filters, pagination, selected tab |
Always handle all three:
if (isLoading) return <Skeleton />
if (error) return <ErrorMessage error={error} onRetry={refetch} />
if (data.length === 0) return <EmptyState message="No users found" />
return <UserList users={data} />
superpowers:test-driven-developmentcode-quality standards — virtualize long lists, debounce inputs, paginate API calls, code-split routesclaude-md)go-feature or py-feature