trycompai/comp / .agents/skills/audit-hooks
audit-hooks
VerifiedAudit & fix hooks and API usage patterns — eliminate server actions, raw fetch, and stale patterns
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.8 KB |
SKILL.md
View on GitHub---
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`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |