new-action

Scaffold TypeScript/Next.js server actions with auth, Zod validation, and repositories.

13|5|Updated May 18, 2024
One-click install
npx skills add https://github.com/techdiary-dev/techdiary.dev --skill new-action
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: new-action
Source: https://github.com/techdiary-dev/techdiary.dev/tree/main/.claude/skills/new-action
Command: npx skills add https://github.com/techdiary-dev/techdiary.dev --skill new-action

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Scaffold a secure, boilerplate backend server action with built-in auth checks, input validation, repository interaction, and standardized error handling, dramatically reducing boilerplate and risk when adding new domain actions.

Core Features & Use Cases

  • Enforces a consistent action skeleton with "use server" at the top and Zod-based input validation.
  • Integrates with your persistence layer to perform domain operations and return typed results.
  • Provides a safe, reusable template for protected actions used in admin panels, internal APIs, and service workflows.

Quick Start

Use the template to generate a new action by specifying the domain name, action name, and domain model, then adapt the scaffold to your repository.

Frequently Asked Questions about new-action

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I scaffold a secure server action in Next.js with TypeScript and Zod validation?▼

To scaffold a secure server action, the template enforces the 'use server' directive, validates input via Zod's parseAsync, checks user authorization, and wraps repository calls in a try/catch block to return a typed ActionResponse<T>.

What is the best way to add authorization checks to backend server actions?▼

Adding authorization checks to backend server actions is handled by the scaffold's built-in auth enforcement, ensuring a user is authorized before executing domain logic and returning a standardized error response if validation fails.

How do I standardize error handling across internal microservices and admin workflows?▼

Standardizing error handling across internal microservices involves wrapping server action logic in a try/catch block and returning a typed ActionResponse<T>, which ensures consistent error reporting for protected domain actions.

Does this server action template work with an existing TypeScript persistence repository?▼

Yes, the server action template works with an existing TypeScript persistence repository by injecting configured repository calls directly into the scaffold to perform domain operations and return typed results.

Can I use this scaffold to generate protected actions for internal APIs?▼

Yes, you can use this scaffold to generate protected actions for internal APIs, as it provides a safe, reusable template specifically suitable for building protected domain actions across admin panels and service workflows.

Why does my Next.js server action require Zod input validation?▼

Next.js server actions require Zod input validation to securely parse asynchronous data from a domain input schema, ensuring that backend repository calls only process verified and correctly typed payloads.