← ClaudeAtlas

async-patterns-safetylisted

Baseline best practice - prevent invalid hook-style async usage and enforce safe async data flow patterns in migrated code. Always loaded in Transform and Repair stages.
devjpedro/portlet-migrator · ★ 0 · Data & Documents · score 45
Install: claude install-skill devjpedro/portlet-migrator
# Async Patterns Safety ## Core rules - Never call a hook-shaped function (`use*`) inside callbacks, loops, conditions, or async helpers. - If a function is imperative, rename from `useSomething` to `somethingWorker` or `fetchSomething`. - Prefer TanStack Query hooks for server state instead of manual `useEffect` + `fetch` orchestration. - Async functions without `await` must not be declared `async`. ## Safe migrations 1. `useEffect(() => { useApiWorker(...) })` -> `useEffect(() => { apiWorker(...) })`. 2. `async function foo() { return x; }` -> `function foo() { return x; }`. 3. Callback-style API wrappers -> typed Promise-based service functions. ## Checklist before final output - No `react-hooks/rules-of-hooks` risk in generated code. - No `@typescript-eslint/require-await` warnings. - Hook names are reserved for real React hooks.