cli/templates/skills/frontend-nextjs/SKILL.md
Next.js frontend development conventions. Use when working on Next.js/React projects with App Router.
npx skillsauth add binhtranquoc/agent-kit-skill frontend-nextjsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides specific conventions for Next.js frontend development.
project-standards skillAll components in app/ are Server Components by default. Only add "use client" when interactivity is strictly needed.
// Server Component (default) - No directive needed
async function UserProfile({ userId }: { userId: string }) {
const user = await getUser(userId); // Direct data fetching
return <div>{user.name}</div>;
}
// Client Component - Only when needed
"use client";
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}
Fetch data directly in Server Components using async/await. Avoid useEffect for data fetching.
app/
├── (auth)/ # Route group (no URL impact)
│ ├── login/
│ │ └── page.tsx
│ └── register/
│ └── page.tsx
├── (dashboard)/
│ ├── layout.tsx # Shared layout
│ ├── page.tsx # /dashboard
│ └── settings/
│ └── page.tsx # /dashboard/settings
├── api/
│ └── users/
│ └── route.ts # API route
├── _components/ # Private folder (excluded from routing)
│ ├── Header.tsx
│ └── Footer.tsx
└── globals.css
page.tsx: Route UIlayout.tsx: Shared UI (wrappers)loading.tsx: Loading states (Suspense)error.tsx: Error boundarynot-found.tsx: 404 pageSTRICTLY use next/image with defined dimensions.
import Image from 'next/image';
// Good
<Image
src="/hero.jpg"
alt="Hero image"
width={1200}
height={600}
priority // For above-the-fold images
/>
// With fill
<div className="relative h-64 w-full">
<Image src="/bg.jpg" alt="Background" fill className="object-cover" />
</div>
Use next/font to optimize loading.
import { Inter } from 'next/font/google';
const inter = Inter({ subsets: ['latin'] });
export default function RootLayout({ children }) {
return (
<html lang="en" className={inter.className}>
<body>{children}</body>
</html>
);
}
Use Server Actions for form submissions instead of API routes.
// app/actions.ts
"use server";
export async function createUser(formData: FormData) {
const email = formData.get('email');
// Server-side logic
await db.user.create({ data: { email } });
revalidatePath('/users');
}
// app/users/new/page.tsx
import { createUser } from '../actions';
export default function NewUserPage() {
return (
<form action={createUser}>
<input name="email" type="email" required />
<button type="submit">Create</button>
</form>
);
}
Prioritize storing search parameters in the URL.
"use client";
import { useSearchParams, useRouter } from 'next/navigation';
function ProductFilters() {
const searchParams = useSearchParams();
const router = useRouter();
const setFilter = (key: string, value: string) => {
const params = new URLSearchParams(searchParams);
params.set(key, value);
router.push(`?${params.toString()}`);
};
return (
<select onChange={(e) => setFilter('category', e.target.value)}>
{/* options */}
</select>
);
}
// Component with Props interface
interface CardProps {
title: string;
children: React.ReactNode;
variant?: 'default' | 'outlined';
}
export function Card({ title, children, variant = 'default' }: CardProps) {
return (
<div className={cn('rounded-lg p-4', variants[variant])}>
<h3 className="font-bold">{title}</h3>
{children}
</div>
);
}
development
Activate Code Reviewer mode for code review and quality assurance. Use when reviewing code for bugs, security issues, or optimization opportunities.
development
Default Implementer mode for writing production code. Use for general coding tasks following project conventions.
development
Activate Debugger mode for systematic bug fixing. Use when debugging errors, investigating issues, or fixing bugs.
testing
Activate Architect mode for system design and architecture decisions. Use when planning features, designing systems, or making architectural choices.