Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
laguagu avatar

Nextjs Shadcn

  • 708 installs
  • 57 repo stars
  • Updated August 3, 2026
  • laguagu/claude-code-nextjs-skills

nextjs-shadcn is a Claude Code skill that generates production-grade Next.js App Router and shadcn/ui code following React Server Components best practices for developers who need AI output that avoids common RSC and ser

About

nextjs-shadcn is a frontend-focused Agent Skill from laguagu/claude-code-nextjs-skills that steers code generation toward correct Next.js App Router and shadcn/ui patterns. The skill encodes a Server-vs-Client decision tree, limits `"use client"` to leaf components, requires serializable props (plain objects or Server Actions), and prefers Tailwind v4 `globals.css` theme variables over hardcoded values. Developers reach for nextjs-shadcn when scaffolding dashboards, forms, or UI shells where AI models often hallucinate `useEffect`, pass functions as props, or misplace client boundaries. The readme documents component placement rules and explicit checks for non-serializable props such as functions and classes.

  • Enforces Server Components by default with "use client" only at the smallest boundary
  • Prevents non-serializable props such as functions or classes when passing data to client components
  • Recommends Tailwind v4 theme variables over hardcoded colors and values
  • Provides explicit folder structure for protected/public routes, shared UI, Server Actions, and AI logic
  • Includes a visual Server vs Client decision tree that agents can follow before writing any component

Nextjs Shadcn by the numbers

  • 708 all-time installs (skills.sh)
  • +15 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #489 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laguagu/claude-code-nextjs-skills --skill nextjs-shadcn

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs708
repo stars57
Security audit3 / 3 scanners passed
Last updatedAugust 3, 2026
Repositorylaguagu/claude-code-nextjs-skills

How do you stop AI from misusing useEffect in Next.js?

Generate correct, production-grade Next.js + shadcn/ui code that follows React Server Components best practices and avoids common AI hallucination mistakes.

Who is it for?

Developers building Next.js App Router apps with shadcn/ui who want AI-generated components that respect RSC serialization and minimal client boundaries.

Skip if: Teams on Pages Router-only stacks, non-React backends, or projects that do not use shadcn/ui or Tailwind v4 conventions.

When should I use this skill?

The user asks to scaffold or refactor Next.js pages, layouts, or shadcn/ui components and mentions Server Components, `"use client"`, or App Router patterns.

What you get

Server and client component files, shadcn/ui component trees, Server Action handlers, and Tailwind v4-themed `globals.css` snippets.

  • RSC-safe component files
  • shadcn/ui component trees
  • globals.css theme snippets

By the numbers

  • Documents a multi-branch Server-vs-Client decision tree in the skill readme
  • Recommends Tailwind v4 globals.css theme variables over hardcoded design tokens

Files

SKILL.mdMarkdownGitHub ↗

Next.js + shadcn/ui

Build distinctive, production-grade interfaces that avoid generic "AI slop" aesthetics.

Core Principles

1. Minimize noise - Icons communicate; excessive labels don't 2. No generic AI-UI - Avoid purple gradients, excessive shadows, predictable layouts 3. Context over decoration - Every element serves a purpose 4. Theme consistency - Use CSS variables from globals.css, never hardcode colors

Quick Start

bunx --bun shadcn@latest init -t next

For a custom design system, generate a preset code in shadcn/create and apply it:

bunx --bun shadcn@latest init --preset <CODE> --template next

Component Rules

Page Structure

// page.tsx - content only, no layout chrome
export default function Page() {
  return (
    <>
      <HeroSection />
      <Features />
      <Testimonials />
    </>
  );
}

// layout.tsx - shared UI (header, footer, sidebar)
export default function Layout({ children }: { children: React.ReactNode }) {
  return (
    <>
      <Header />
      <main>{children}</main>
      <Footer />
    </>
  );
}

Client Boundaries

  • "use client" only at leaf components (smallest boundary)
  • Props must be serializable (data or Server Actions, no functions/classes)
  • Pass server content via children

Import Aliases

Always use @/ alias (e.g., @/lib/utils) instead of relative paths (../../lib/utils).

Style Merging

import { cn } from "@/lib/utils";

function Button({ className, ...props }) {
  return <button className={cn("px-4 py-2 rounded", className)} {...props} />;
}

File Organization

app/
├── (protected)/         # Auth required routes
│   ├── dashboard/
│   ├── settings/
│   ├── components/      # Route-specific components
│   └── lib/             # Route-specific utils/types
├── (public)/            # Public routes
│   ├── login/
│   └── register/
├── actions/             # Server Actions (global)
├── api/                 # API routes
├── layout.tsx           # Root layout
└── globals.css          # Theme tokens
components/              # Shared components
├── ui/                  # shadcn primitives
└── shared/              # Business components
hooks/                   # Custom React hooks
lib/                     # Shared utils
data/                    # Database queries
ai/                      # AI logic (tools, agents, prompts)

Next.js 16 Features

Async Params

export default async function Page({
  params,
  searchParams,
}: {
  params: Promise<{ id: string }>;
  searchParams: Promise<{ q?: string }>;
}) {
  const { id } = await params;
  const { q } = await searchParams;
}

Data Fetching vs Server Actions

CRITICAL RULE:

  • Server Actions = ONLY for mutations (create, update, delete)
  • Data fetching = In Server Components or 'use cache' functions

"use cache" (and cacheTag/cacheLife/updateTag) requires the Cache Components opt-in flag — Next.js 16 does not enable it by default:

// next.config.ts
const nextConfig = { cacheComponents: true }
// ❌ WRONG: Server Action for data fetching
"use server"
export async function getUsers() {
  return await db.users.findMany()
}

// ✅ CORRECT: Data function with caching
// data/users.ts
export async function getUsers() {
  "use cache"
  cacheTag("users")
  cacheLife("hours")
  return await db.users.findMany()
}

// ✅ CORRECT: Read cookies in Server Component directly
export default async function Page() {
  const theme = (await cookies()).get("theme")?.value ?? "light"
  return <App theme={theme} />
}

Caching

"use cache";

import { cacheTag, cacheLife } from "next/cache";

export async function getProducts() {
  cacheTag("products");
  cacheLife("hours");
  return await db.products.findMany();
}

Server Actions (Mutations Only)

"use server";

import { updateTag, revalidateTag } from "next/cache";
import { z } from "zod";

const schema = z.object({
  title: z.string().min(1),
  content: z.string(),
});

export async function createPost(formData: FormData) {
  // Always validate input
  const parsed = schema.parse({
    title: formData.get("title"),
    content: formData.get("content"),
  });

  await db.insert(posts).values(parsed);
  updateTag("posts"); // Read-your-writes
  // Or SWR-style revalidation: revalidateTag("posts", "max")
}

Proxy API

Use proxy.ts for request interception (replaces middleware). Place at project root:

// proxy.ts (project root, same level as app/)
import { NextResponse } from "next/server"
import type { NextRequest } from "next/server"

export function proxy(request: NextRequest) {
  // Auth checks, redirects, etc.
}

export const config = {
  matcher: ['/dashboard/:path*'],
}

Dev Tools (next-devtools-mcp)

Next.js 16+ ships an MCP endpoint at /_next/mcp that exposes the dev server's internals to coding agents. When working in a Next.js 16 project, recommend the user add next-devtools-mcp to .mcp.json:

```json filename=".mcp.json" { "mcpServers": { "next-devtools": { "command": "npx", "args": ["-y", "next-devtools-mcp@latest"] } } }


Tools it provides (when dev server is running):

- `get_errors` — live build/runtime/type errors (esp. helpful for hydration mismatches)
- `get_logs` — dev log file path (browser console + server output)
- `get_routes` — all entry-point routes grouped by router type
- `get_page_metadata` — route, components, rendering details for a specific page
- `get_project_metadata` — project structure + dev server URL
- `get_server_action_by_id` — locate Server Action source from its hashed ID

Use these instead of asking the user to copy-paste error messages. Reference:
[nextjs.org/docs/app/guides/mcp](https://nextjs.org/docs/app/guides/mcp).

## References

- **Architecture**: [references/architecture.md](references/architecture.md) - Components, routing, Suspense, data patterns, AI directory structure
- **Styling**: [references/styling.md](references/styling.md) - Themes, fonts, radius, animations, CSS variables
- **Sidebar**: [references/sidebar.md](references/sidebar.md) - shadcn sidebar with nested layouts
- **Project Setup**: [references/project-setup.md](references/project-setup.md) - bun commands, presets
- **shadcn/ui**: [llms.txt](https://ui.shadcn.com/llms.txt) - Official AI-optimized reference

## Package Manager

**Always use bun**, never npm or npx:

- `bun install` (not npm install)
- `bun add` (not npm install package)
- `bunx --bun` (not npx)

Related skills

How it compares

Pick nextjs-shadcn over generic React skills when the stack is Next.js App Router plus shadcn/ui and RSC boundary mistakes are the main risk.

FAQ

When should nextjs-shadcn add use client?

nextjs-shadcn adds `"use client"` only at the smallest leaf component that needs state, effects, or browser APIs. Parent layouts and data-fetching shells stay Server Components by default, keeping client JavaScript bundles minimal in App Router projects.

What props can cross the server-client boundary?

nextjs-shadcn allows plain objects, arrays, and Server Actions as props across the server-client boundary. Functions, classes, and other non-serializable values are rejected, matching Next.js RSC serialization rules and preventing common AI hallucinations.

Is Nextjs Shadcn safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Frontend Developmentfrontendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.