api-design-security

Enforce RBAC, CSRF, tenant isolation, and audit logging in Next.js 16 admin APIs.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/ArtisanClarinets/crispy-fishstick --skill api-design-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-security
Source: https://github.com/ArtisanClarinets/crispy-fishstick/tree/main/.agent/skills/api-design-security
Command: npx skills add https://github.com/ArtisanClarinets/crispy-fishstick --skill api-design-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the challenge of building and maintaining secure admin APIs in Next.js 16 apps. It provides a proven pattern to enforce authentication, authorization, CSRF protection, multi-tenant data isolation, rate limiting, and comprehensive audit logging across critical admin routes.

Core Features & Use Cases

  • Admin route wrappers: Use adminRead for reads and adminMutation for mutations to consistently apply security controls.
  • RBAC & CSRF: Integrate role-based access control and cross-site request forgery protections across endpoints.
  • Tenant isolation: Ensure all queries are scoped by tenantId to prevent cross-tenant data access.
  • Audit & safety: Automatically audit privileged operations and enforce safe data selection to redact sensitive fields.

Quick Start

  1. Choose the appropriate wrapper (adminRead for GET, adminMutation for writes).
  2. Define input validation with Zod schemas.
  3. Apply tenant scoping and use safe selects.
  4. Implement security tests (CSRF, RBAC, audit logging). Example: export async function POST(req: NextRequest) { return adminMutation(req, { permissions: ["users.write"], audit: { action: "create_user", resource: "user" } }, async (user, body) => { const validatedData = createUserSchema.parse(body); // Implementation with tenant scoping and security }); }

Frequently Asked Questions about api-design-security

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

FAQPage Schema
How do I implement RBAC and CSRF protection in Next.js 16 admin APIs?

You can implement RBAC and CSRF protection in Next.js 16 admin APIs by applying adminRead and adminMutation route wrappers to consistently enforce security controls across your endpoints.

What's the best way to enforce tenant isolation in Next.js admin routes?

The best way to enforce tenant isolation in Next.js admin routes is scoping all database queries by tenantId, which prevents cross-tenant data access when handling multi-tenant operations.

How do I automatically audit privileged admin operations in Next.js?

You automatically audit privileged admin operations in Next.js by configuring the audit property within the adminMutation wrapper to log specific actions and resources during secure API mutations.

Does this admin API security approach work with Zod schemas for input validation?

Yes, this admin API security approach works with Zod schemas, allowing you to parse and validate incoming request bodies before executing core logic inside the secure route wrappers.

How do I prevent sensitive data exposure in Next.js admin API responses?

You prevent sensitive data exposure in Next.js admin API responses by enforcing safe data selection within your database queries, which redacts sensitive fields from the output.

Can I use adminRead and adminMutation wrappers for rate limiting in Next.js?

Yes, you can use adminRead and adminMutation wrappers for rate limiting in Next.js, as they consistently apply security controls including rate limiting across critical admin routes.