nextbase-safe-actions-data
Skill827 starsChanged 3 months agoMITView on GitHub
Use for NextBase server actions, next-safe-action clients or hooks, forms, Zod validation, authenticated mutations, RLS ownership, data-layer placement, invalidation, redirects, or the optional Effect bridge.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- nextbase-architectureSkill
- nextbase-auth-ssrSkill
- nextbase-cache-componentsSkill
- nextbase-database-testingSkill
- nextbase-testingSkill
- nextbase-ui-patternsSkill
- next-cache-components-optimizerSkill
- safe-action-advancedSkill
- safe-action-clientSkill
- safe-action-hooksSkill
- safe-action-middlewareSkill
- safe-action-testingSkill
- shadcnSkill
- supabase-postgres-best-practicesSkill
- supabase-schema-migrationsSkill
- supabaseSkill
- turborepoSkill
- vercel-composition-patternsSkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use actionClient from src/lib/safe-action.ts for unauthenticated flows such as sign-in and password recovery.
- Very specific: line 13
Use authActionClient for authenticated work.
- Very specific: line 14
Keep action modules server-only and place auth actions in src/data/auth, user-scoped actions in src/data/user, and reusable server reads in …
- Distinctive: line 22
Check and surface database errors without leaking secrets or internal policy details.
- Distinctive: line 30
Keep the form as the smallest possible Client Component.
- Very specific: line 31
Use the maintainer hook appropriate to the UX (useAction, optimistic action, or state action) and its status/callback API instead of …
- Distinctive: line 32
Use shadcn form controls and accessible labels.
- Distinctive: line 41
Test valid input, invalid input, anonymous calls, authenticated ownership, RLS denial, database failure, invalidation, and redirect …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NextBase Safe Actions and Data
Load the relevant vendored safe-action-* skill for API details and the supabase skill for database behavior.
Action Boundary
- Use
actionClientfromsrc/lib/safe-action.tsfor unauthenticated flows such as sign-in and password recovery. - Use
authActionClientfor authenticated work. It suppliesctx.userId; do not accept the owner ID from input. - Keep action modules server-only and place auth actions in
src/data/auth, user-scoped actions insrc/data/user, and reusable server reads in the closest existing data layer. - Define a Zod schema at the action boundary. Client form validation improves feedback but does not replace server validation.
Mutation Workflow
- Parse and validate with the action schema.
- Derive identity and ownership from
ctx, never from untrusted input. - Execute through the server Supabase client so cookies and RLS apply.
- Check and surface database errors without leaking secrets or internal policy details.
- Invalidate the narrow path or cache tag affected by the successful mutation.
- Redirect only after the mutation and invalidation succeed.
RLS is the final authorization boundary. An action-level owner filter is defense in depth, not a replacement for an RLS policy.
Client Forms
- Keep the form as the smallest possible Client Component.
- Use the maintainer hook appropriate to the UX (
useAction, optimistic action, or state action) and its status/callback API instead of duplicating loading and error state. - Use shadcn form controls and accessible labels. Preserve progressive enhancement where the flow requires it.
- Stable field errors come from validation results; unexpected server failures belong in a form-level error.
Effect Bridge
src/utils/effect-bridge.ts and the Effect query helpers are optional adapters for typed effectful code. Reuse them where an adjacent action already uses Effect or where typed error composition materially helps. Do not introduce Effect for a simple one-call mutation.
Verification
Test valid input, invalid input, anonymous calls, authenticated ownership, RLS denial, database failure, invalidation, and redirect behavior at the narrowest suitable layer.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

