frontend-development
16
总安装量
5
周安装量
#21417
全站排名
安装命令
npx skills add https://github.com/carvalab/k-skills --skill frontend-development
Agent 安装分布
claude-code
3
trae
2
antigravity
2
codex
2
windsurf
2
gemini-cli
2
Skill 文档
Frontend Development
Next.js (latest) App Router with TypeScript. Server-first architecture.
Related Skills:
kavak-documentation– USE FIRST for Kavak-specific patterns, GitLab CI, Docker templatesvercel-react-best-practices– USE THIS for performance (bundle size, waterfalls, caching, re-renders, memoization)- Check
.claude/CLAUDE.mdfor project-specific conventions- Check
.cursor/rules/*for project-specific conventionsMCP:
- Use
kavak-platform/plati_querytool to query Kavak internal documentation before implementing- Use
next-devtoolsMCP server if available for debugging, route inspection, and build analysis
Quick Start
| Task | Pattern |
|---|---|
| New page | Server Component by default |
| Data fetching | Server Component async fetch |
| Mutations | Server Actions + Zod + revalidatePath |
| Styling | MUI sx prop, inline if <100 lines |
| State | Server = fetch, Client = useState only when needed |
Core Principles
- Server by Default: Components are Server Components unless they need
useState/useEffect/events - Server Actions for Mutations: Replace API routes for internal app logic
- Opt-in Caching: Use
'use cache'directive for explicit caching - Minimal Client JS: Keep
'use client'components small and leaf-level - Type Everything: Strict TypeScript, Zod for runtime validation
Performance: For bundle optimization, waterfalls, memoization, see
vercel-react-best-practices
Server vs Client Decision
Need useState/useEffect/onClick? â 'use client'
Need browser APIs (localStorage)? â 'use client'
Just rendering data? â Server Component (default)
Rule: Keep Client Components small. Most of tree stays server-rendered.
Data Fetching Pattern
// app/users/page.tsx - Server Component (default)
export default async function UsersPage() {
const users = await db.user.findMany(); // Runs on server
return <UserList users={users} />;
}
No TanStack Query needed – Server Components handle data fetching natively.
Server Actions Pattern
// app/actions.ts
'use server';
import { z } from 'zod';
import { revalidatePath } from 'next/cache';
const schema = z.object({ title: z.string().min(1) });
export async function createPost(formData: FormData) {
const parsed = schema.safeParse({ title: formData.get('title') });
if (!parsed.success) return { error: parsed.error.flatten() };
await db.post.create({ data: parsed.data });
revalidatePath('/posts');
return { success: true };
}
When to use Server Actions vs API Routes:
- Server Actions â Internal mutations, form submissions
- Route Handlers â Public APIs, webhooks, large uploads, streaming
Critical Rules
Never
// â Large 'use client' at top of tree
'use client'; // Marks entire subtree as client
// â Expose secrets to client
const apiKey = process.env.SECRET_KEY; // In client component
// â Old MUI Grid syntax
<Grid xs={12} md={6}>
Always
// â
Small leaf-level client components
// â
Validate Server Action inputs with Zod
// â
MUI Grid size prop
<Grid size={{ xs: 12, md: 6 }}>
File Conventions
app/
âââ layout.tsx # Root layout (Server)
âââ page.tsx # Home page
âââ loading.tsx # Loading UI (Suspense fallback)
âââ error.tsx # Error boundary ('use client')
âââ not-found.tsx # 404 page
âââ users/
â âââ page.tsx # /users
â âââ [id]/
â â âââ page.tsx # /users/:id
â âââ actions.ts # Server Actions
âââ api/
âââ webhook/
âââ route.ts # Route Handler (public API)
Common Workflows
New Feature
- Create
app/{route}/page.tsx(Server Component) - Add
loading.tsxfor Suspense boundary - Create Server Actions in
actions.ts - Add Client Components only where needed
Performance Issue
â Run vercel-react-best-practices skill for optimization rules
Styling Component
- Use MUI
sxprop withSxProps<Theme> - Inline styles if <100 lines, separate
.styles.tsif >100 - Grid:
size={{ xs: 12, md: 6 }}
References
| Reference | When to Use |
|---|---|
references/nextjs.md |
App Router, RSC, Server Actions, caching |
references/component-patterns.md |
React.FC, hooks order, dialogs, forms |
references/styling.md |
MUI sx prop, Grid, theming |
references/typescript.md |
Types, generics, Zod validation |
references/project-structure.md |
features/ vs components/, organization |
Performance/Optimization â vercel-react-best-practices skill
Technology Stack
| Layer | Technology |
|---|---|
| Framework | Next.js (App Router, latest) |
| Type Safety | TypeScript (strict) + Zod |
| Data Fetching | Server Components (async) |
| Mutations | Server Actions + revalidatePath |
| Client State | useState (minimal) |
| Styling | MUI (latest) |
| Forms | Server Actions + useActionState |
Note: TanStack Query only if you need real-time polling or complex optimistic updates. See references/data-fetching.md.