react-tanstack-senior
54
总安装量
53
周安装量
#3986
全站排名
安装命令
npx skills add https://github.com/modra40/claude-codex-skills-directory --skill react-tanstack-senior
Agent 安装分布
claude-code
38
gemini-cli
33
antigravity
30
codex
29
github-copilot
28
Skill 文档
React + TanStack Senior Developer Skill
Core Philosophy
KISS > Clever Code
Readability > Brevity
Explicit > Implicit
Composition > Inheritance
Colocation > Separation
Type Safety > Any
Quick Decision Tree
State Management:
- Server state â TanStack Query (WAJIB)
- URL state â TanStack Router search params
- Form state â TanStack Form atau React Hook Form
- Global UI state â Zustand (bukan Redux)
- Local UI state â useState/useReducer
Routing:
- SPA â TanStack Router
- Full-stack SSR â TanStack Start
- Existing Next.js â tetap Next.js
Project Setup Workflow
-
Determine project type:
- SPA/Client-only? â Vite + TanStack Router + Query
- Full-stack SSR? â TanStack Start (Vinxi-based)
- Existing project? â Incremental adoption
-
Initialize project â See folder-structure.md
-
Setup core dependencies â See recommended-libraries.md
TanStack Ecosystem References
| Library | When to Read |
|---|---|
| tanstack-query.md | Data fetching, caching, mutations |
| tanstack-router.md | Type-safe routing, loaders, search params |
| tanstack-table.md | Complex tables, sorting, filtering, pagination |
| tanstack-form.md | Form validation, field arrays, async validation |
| tanstack-start.md | Full-stack SSR framework |
Code Quality Standards
Naming Conventions
// Components: PascalCase dengan suffix deskriptif
UserProfileCard.tsx // â
UserCard.tsx // â terlalu generic
user-profile.tsx // â wrong case
// Hooks: camelCase dengan prefix 'use'
useUserProfile() // â
useGetUserProfile() // â redundant 'Get'
getUserProfile() // â missing 'use'
// Query keys: array dengan hierarchy
['users', 'list', { status }] // â
['usersList'] // â tidak granular
`users-${status}` // â string interpolation
// Files: kebab-case untuk non-components
api-client.ts // â
apiClient.ts // â
Component Structure Pattern
// 1. Imports (grouped: external â internal â types)
import { useSuspenseQuery } from '@tanstack/react-query'
import { userQueries } from '@/features/users/api'
import type { User } from '@/features/users/types'
// 2. Types (colocated, tidak di file terpisah kecuali shared)
interface UserCardProps {
userId: string
onSelect?: (user: User) => void
}
// 3. Component (single responsibility)
export function UserCard({ userId, onSelect }: UserCardProps) {
// 3a. Queries/mutations first
const { data: user } = useSuspenseQuery(userQueries.detail(userId))
// 3b. Derived state (useMemo hanya jika expensive)
const fullName = `${user.firstName} ${user.lastName}`
// 3c. Handlers (useCallback hanya jika passed to memoized children)
const handleClick = () => onSelect?.(user)
// 3d. Early returns untuk edge cases
if (!user.isActive) return null
// 3e. JSX (clean, minimal nesting)
return (
<article onClick={handleClick} className="user-card">
<h3>{fullName}</h3>
<p>{user.email}</p>
</article>
)
}
Anti-Patterns to AVOID
// â NEVER: useEffect untuk data fetching
useEffect(() => {
fetch('/api/users').then(setUsers)
}, [])
// â
ALWAYS: TanStack Query
const { data: users } = useQuery(userQueries.list())
// â NEVER: Prop drilling lebih dari 2 level
<Parent userData={user}>
<Child userData={user}>
<GrandChild userData={user} />
// â
ALWAYS: Context atau query di level yang butuh
function GrandChild() {
const { data: user } = useQuery(userQueries.current())
}
// â NEVER: Premature optimization
const value = useMemo(() => a + b, [a, b]) // simple math
// â
ALWAYS: Optimize only when measured
const value = a + b // just calculate
// â NEVER: Index as key untuk dynamic lists
{items.map((item, i) => <Item key={i} />)}
// â
ALWAYS: Stable unique identifier
{items.map(item => <Item key={item.id} />)}
Debugging Guide
See debugging-guide.md for:
- React DevTools profiling
- TanStack Query DevTools
- Memory leak detection
- Performance bottleneck identification
- Common error patterns
Common Pitfalls & Bugs
See common-pitfalls.md for:
- Stale closure bugs
- Race conditions
- Memory leaks patterns
- Hydration mismatches
- Query invalidation mistakes
Performance Checklist
â¡ Bundle size < 200KB gzipped (initial)
â¡ Largest Contentful Paint < 2.5s
â¡ No unnecessary re-renders (React DevTools)
â¡ Images lazy loaded
â¡ Code splitting per route
â¡ Query deduplication working
â¡ No memory leaks (heap snapshot stable)
Code Review Checklist
â¡ No `any` types (use `unknown` if needed)
â¡ No `// @ts-ignore` tanpa penjelasan
â¡ Error boundaries di route level
â¡ Loading states handled
â¡ Empty states handled
â¡ Error states handled
â¡ Accessibility (aria labels, keyboard nav)
â¡ No hardcoded strings (i18n ready)
â¡ No console.log in production code
â¡ Tests untuk business logic