一键导入
patterns-reference
Golden implementation patterns for each effect type
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Golden implementation patterns for each effect type
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate or validate UI with design physics
Slot external knowledge into Rune constructs
Validate data correctness in web3 components
Capture taste preferences for design physics
Hypothesis validation and closed-loop learning
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
| name | patterns-reference |
| description | Golden implementation patterns for each effect type |
| user-invocable | false |
Complete golden patterns for the crafting skill. Loaded on-demand.
Two-phase confirmation. No optimistic updates. Cancel always visible.
function ClaimButton({ amount, onSuccess }) {
const [showConfirm, setShowConfirm] = useState(false)
const { mutate, isPending, isError, error } = useMutation({
mutationFn: () => claimRewards(amount),
onSuccess: () => { setShowConfirm(false); onSuccess?.() },
// NO onMutate - pessimistic
})
if (!showConfirm) {
return <button onClick={() => setShowConfirm(true)}>Claim {amount}</button>
}
return (
<div>
<p>Confirm claiming {amount}?</p>
<button onClick={() => setShowConfirm(false)}>Cancel</button>
<button onClick={() => mutate()} disabled={isPending}>
{isPending ? 'Claiming...' : 'Confirm'}
</button>
{isError && <p>{error.message}</p>}
</div>
)
}
Optimistic update with rollback. No confirmation needed.
function LikeButton({ postId, isLiked }) {
const queryClient = useQueryClient()
const { mutate } = useMutation({
mutationFn: () => toggleLike(postId),
onMutate: async () => {
await queryClient.cancelQueries(['post', postId])
const previous = queryClient.getQueryData(['post', postId])
queryClient.setQueryData(['post', postId], old => ({
...old, isLiked: !old.isLiked
}))
return { previous }
},
onError: (_, __, ctx) => {
queryClient.setQueryData(['post', postId], ctx?.previous)
},
})
return <button onClick={() => mutate()}>{isLiked ? '❤️' : '🤍'}</button>
}
No server. Immediate response. Accessible.
function ThemeToggle() {
const { theme, setTheme } = useTheme()
const isDark = theme === 'dark'
return (
<button
onClick={() => setTheme(isDark ? 'light' : 'dark')}
aria-label={`Switch to ${isDark ? 'light' : 'dark'} mode`}
>
{isDark ? '🌙' : '☀️'}
</button>
)
}
Optimistic with toast and undo.
function ArchiveButton({ itemId }) {
const { mutate } = useMutation({
mutationFn: () => archiveItem(itemId),
onMutate: async () => {
// Optimistically remove from list
},
onSuccess: () => {
toast('Archived', {
action: { label: 'Undo', onClick: () => restoreItem(itemId) },
duration: 5000
})
},
onError: () => {
// Rollback
toast.error('Failed to archive')
},
})
return <button onClick={() => mutate()}>Archive</button>
}