api

Implement validated Next.js Server Actions and REST API Routes with Zod and standardized error handling.

Updated May 19, 2026
One-click install
npx skills add https://github.com/TimeKast/AgendaInteligente --skill api-timekast
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api
Source: https://github.com/TimeKast/AgendaInteligente/tree/main/.agent/skills/domains/api
Command: npx skills add https://github.com/TimeKast/AgendaInteligente --skill api-timekast

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design and implement Next.js API endpoints and Server Actions that reliably validate inputs, enforce auth, and return consistent responses instead of leaking internal errors.

Core Features & Use Cases

  • Server Actions for UI mutations: Use 'use server' functions to perform authenticated write operations from React forms and components, with cache revalidation after mutations.
  • API Routes for external consumers: Expose REST endpoints for webhooks, integrations, and mobile clients while keeping route handlers thin.
  • Zod validation at the boundary: Parse and validate params, query, and request bodies using Zod schemas to prevent trusting untrusted input.
  • Standardized error handling: Implement ERROR_CODES and a central handleApiError to map Zod and domain errors to correct HTTP status codes.
  • Deletion safety with dependency checks: Verify related records (e.g., “hasMovements”) before deleting/soft-deleting entities to preserve business integrity.

Quick Start

Implement a new endpoint by creating an API Route under app/api/.../route.ts that uses a Zod schema to validate params/body, delegates business logic to Server Actions, and returns results via NextResponse.json with standardized errors handled by handleApiError.

Frequently Asked Questions about api

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

FAQPage Schema
How do I validate inputs in Next.js Server Actions and API routes?

Use Zod schemas at the boundary to parse and validate params, query strings, and request bodies in Next.js Server Actions and API routes. This ensures untrusted input never reaches your core business logic.

What is the best way to handle API errors in Next.js without leaking internal details?

The best way to handle API errors in Next.js is by implementing centralized error mapping with ERROR_CODES and a handleApiError function to map Zod and domain errors to correct HTTP status codes.

How do I process incoming webhooks with signature verification in Next.js?

Process incoming webhooks with signature verification in Next.js by exposing thin REST API route handlers that validate the incoming payload signature before delegating the business logic to authenticated Server Actions.

When do I need to use revalidatePath or revalidateTag after Next.js Server Action mutations?

You need to use revalidatePath or revalidateTag after Next.js Server Action mutations to clear cached data and ensure the UI reflects the latest updated records immediately following authenticated write operations.

How do I prevent deleting records that have existing dependencies in a Next.js API?

Prevent deleting records with existing dependencies in a Next.js API by implementing deletion safety checks that verify related records, such as hasMovements flags, before performing hard or soft delete operations.

Can I use Drizzle ORM with Next.js Server Actions for authenticated CRUD workflows?

Yes, you can use Drizzle ORM with Next.js Server Actions for authenticated CRUD workflows by delegating database operations to 'use server' functions while keeping REST API route handlers thin.