Back to Skills

nextjs

KubrickCode
Updated Today
91 views
1
1
View on GitHub
Metaapidesigndata

About

This skill provides Next.js architecture expertise focused on App Router patterns and implementation guidance. It enforces BFF architecture, Server/Client Component strategies, and optimal data fetching with caching. Use it when implementing Server Actions, streaming SSR, route handlers, or performance optimization in Next.js 15.5+ applications.

Documentation

Next.js Project Architecture Rules

Scope: Project-specific policies and architecture decisions only.

Version: Next.js 15.5+ with App Router


1. BFF Architecture (Mandatory)

Absolute Rules

Next.js serves ONLY as a thin Backend for Frontend (BFF) layer:

Browser ↔ Next.js Server ↔ Backend API ↔ Database

NEVER:

  • ❌ Direct database access from Next.js (no Prisma, no ORMs)
  • ❌ Business logic implementation in Next.js
  • ❌ Data validation beyond input sanitization

ALWAYS:

  • ✅ All business logic in separate backend service
  • ✅ All database operations via backend API
  • ✅ Next.js for: SSR/SSG, API aggregation, session management, caching

2. Component Strategy (Enforced)

Server Components First

Rule: Default to Server Components. 'use client' only at leaf nodes.

Client Component allowed for:

  • Event handlers (onClick, onChange)
  • Browser APIs (localStorage, window)
  • React hooks (useState, useEffect)

Violation: Client Component wrapping Server Components


3. Rendering Strategy (Explicit Declaration Required)

Mandatory Export

Every page MUST explicitly declare rendering intent:

// Required - choose one:
export const dynamic = "force-static"; // SSG
export const dynamic = "force-dynamic"; // SSR
export const revalidate = 3600; // ISR

No implicit rendering. Always be explicit about caching behavior.


4. Data Fetching (Server Actions vs API Routes)

Server Actions (Default for Internal Operations)

Use for:

  • Form submissions
  • Data mutations
  • Internal Next.js operations

Location: app/actions/*.ts or inline with 'use server'

API Routes (External Integration ONLY)

Use for:

  • Webhooks (Stripe, GitHub, etc.)
  • OAuth callbacks
  • Mobile app endpoints
  • Third-party service integrations

Location: app/api/*/route.ts

NEVER: API routes for internal Next.js-to-Next.js communication


5. Caching Policy (Explicit Intent Required)

Mandatory Cache Declaration

All fetch calls MUST explicitly specify caching:

// Required - choose one:
fetch(url, { next: { revalidate: 3600 } }); // Time-based
fetch(url, { cache: "no-store" }); // Dynamic

Use React cache() to prevent duplicate requests within render cycle.

No implicit caching. Always declare intent.


Critical Violations

  1. Direct DB access from Next.js → Architecture violation
  2. API Routes for internal mutations → Use Server Actions
  3. Missing rendering strategy declaration → Add explicit export
  4. Client Component not at leaf → Move 'use client' down
  5. Implicit caching → Add explicit cache declaration
  6. Backend not separated → Mandatory separate service

Quick Install

/plugin add https://github.com/KubrickCode/ai-config-toolkit/tree/main/nextjs

Copy and paste this command in Claude Code to install this skill

GitHub 仓库

KubrickCode/ai-config-toolkit
Path: .claude/skills/nextjs

Related Skills

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

webapp-testing

Testing

This Claude Skill provides a Playwright-based toolkit for testing local web applications through Python scripts. It enables frontend verification, UI debugging, screenshot capture, and log viewing while managing server lifecycles. Use it for browser automation tasks but run scripts directly rather than reading their source code to avoid context pollution.

View skill

business-rule-documentation

Meta

This skill provides standardized templates for systematically documenting business logic and domain knowledge following Domain-Driven Design principles. It helps developers capture business rules, process flows, decision trees, and terminology glossaries to maintain consistency between requirements and implementation. Use it when documenting domain models, creating business rule repositories, or bridging communication between business and technical teams.

View skill