Skip to main content

audit-hooks

Audit & fix hooks and API usage patterns — eliminate server actions, raw fetch, and stale patterns

来源信息

仓库
trycompai/comp
最近来源活动
2026年4月27日 13:56
检测到的 SKILL.md 语言
英语
星标
2,074
Forks
441

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
audit-hooks
description
Audit & fix hooks and API usage patterns — eliminate server actions, raw fetch, and stale patterns
Audit the specified files for hook and API usage compliance. **Fix every issue found immediately.** ## Forbidden Patterns (fix immediately) 1. **`useAction` from `next-safe-action`** → replace with SWR hook or custom mutation hook 2. **Server actions mutating via `@db`** → delete and use API hook instead 3. **Direct `@db` in client components** → replace with `apiClient` via hook 4. **Direct `@db` in Next.js pages for mutations** → replace with `serverApi` 5. **Raw `fetch()` without `credentials: 'include'`** → use `apiClient` 6. **`window.location.reload()` after mutations** → use SWR `mutate()` 7. **`router.refresh()` after mutations** → use SWR `mutate()` 8. **`useEffect` + `apiClient.get` for data fetching** → replace with `useSWR` 9. **Callback props for data refresh** (`onXxxAdded`, `onSuccess`) → remove, rely on SWR cache sharing ## Required Patterns - **Client data fetching**: `useSWR` with `apiClient` or custom hook - **Client mutations**: custom hooks wrapping `apiClient` with `mutate()` for cache invalidation - **Server components**: `serverApi` from `apps/app/src/lib/api-server.ts` - **SWR**: `fallbackData` for SSR data, `revalidateOnMount: !initialData` - **API response**: lists = `response.data.data`, single = `response.data` - **`mutate()` safety**: guard against `undefined` in optimistic update functions - **`Array.isArray()` checks**: when consuming SWR data that could be stale ## Process 1. Read files specified in `$ARGUMENTS` 2. Find forbidden patterns and fix them 3. Ensure all data fetching uses SWR hooks 4. Run typecheck to verify: `bunx turbo run typecheck --filter=@trycompai/app`
在 GitHub 查看