// Enforces Head Shakers server actions coding conventions when creating or modifying server actions using next-safe-action, and ensures consistent client-side consumption patterns using the project's useServerAction hook. This skill covers both server-side action implementation and frontend integration patterns.
| name | server-actions |
| description | Enforces Head Shakers server actions coding conventions when creating or modifying server actions using next-safe-action, and ensures consistent client-side consumption patterns using the project's useServerAction hook. This skill covers both server-side action implementation and frontend integration patterns. |
This skill enforces the Head Shakers server actions coding conventions automatically during server action development. It ensures consistent patterns for authentication, validation, error handling, Sentry integration, cache invalidation, and client-side consumption via the useServerAction hook.
This skill activates when:
src/lib/actions/.actions.ts)useServerActionactions/ or imports from next-safe-action or use-server-action)references/Server-Actions-Conventions.mdauthActionClient, adminActionClient, or publicActionClient based on auth requirementsctx.sanitizedInput parsed through Zod schema (never use parsedInput directly)actionName and isTransactionRequiredwithActionErrorHandling() wrapper for automatic Sentry context, breadcrumbs, and error handling (recommended)withActionBreadcrumbs() for breadcrumbs without error handlingtrackCacheInvalidation() to log cache failures as warnings without throwinghandleActionError utility (automatic with withActionErrorHandling)CacheRevalidationService{ success, message, data }useServerAction hook from @/hooks/use-server-action (never useAction directly)executeAsync with toastMessages for user-initiated mutationsexecute with isDisableToast: true for silent background operationsbreadcrumbContext for Sentry tracking on user-initiated actions (provides action and component names)data.data in callbacks or result?.data?.data from result objectisExecuting for loading states and button disabled statesuseAppForm for form submissions with focus managementwithFocusManagement HOC and useFocusContext for form error focusing| Use Case | Hook Setup | Execution |
|---|---|---|
| Form submission | toastMessages + onSuccess | await executeAsync(value) |
| Delete with navigation | toastMessages | await executeAsync(id).then(redirect) |
| Search/autocomplete | isDisableToast: true | execute(query) in useEffect |
| Silent background ops | isDisableToast: true | execute(data) in callback |
| Availability check | isDisableToast: true | execute(value) in useEffect |
references/Server-Actions-Conventions.md - Complete server actions conventions (server & client)