用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill frontend-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | frontend-patterns |
| description | Frontend patterns — debounce, double-submit prevention, error boundaries. |
Apply debounce whenever user input triggers expensive side effects (API calls, heavy computation). Without it, every keystroke fires a request — degrading both UX and server load.
When to use: search/autocomplete inputs, address or tag lookup, form field validation against an API, resize/scroll event handlers.
Framework-agnostic pattern (adapt to the project's stack):
// Reusable debounce utility — use lodash.debounce, use-debounce, or VueUse's useDebounceFn
function debounce<T extends (...args: unknown[]) => void>(fn: T, delay: number): T {
let timer: ReturnType<typeof setTimeout>
return ((...args) => { clearTimeout(timer); timer = setTimeout(() => fn(...args), delay) }) as T
}
// Autocomplete example
const searchUsers = debounce(async (query: string) => {
if (query.length < 2) return
results.value = await api.users.search(query)
}, 300)
Rules:
AbortController)Every form submit or action button must be guarded against duplicate submissions. Two clicks = two POST requests = corrupted data, duplicate payments, or duplicate records.
Rules:
isSubmitting state; set it true on submission start, false on completion (success or error)isSubmitting is true — never just rely on UX// Framework-agnostic guard
async function handleSubmit() {
if (isSubmitting) return // ← guard: bail on double-click
isSubmitting = true
try {
await api.createOrder(payload)
} finally {
isSubmitting = false // ← always release, even on error
}
}
finally (or equivalent) — releasing the lock only on success is a common bug that permanently disables the form after an errorA runtime error in one component must not crash the entire UI. Wrap every route/page-level component in an error boundary that shows a user-facing fallback.
componentDidCatch, or react-error-boundary (<ErrorBoundary FallbackComponent={...}>)onErrorCaptured in a wrapper component, or app.config.errorHandler for global handlingErrorHandler and provide it at the root level ({ provide: ErrorHandler, useClass: AppErrorHandler })<svelte:boundary> (Svelte 5) or a wrapper component with onerrorRules:
window.addEventListener('unhandledrejection', ...) to catch uncaught promise rejections and forward them to the project's error tracking service (Sentry, Datadog, etc.)