frontend-patterns
БесплатноЗапускает вложенные скриптыНе проверенFrontend patterns for modern web frameworks, component libraries, auth flows, and analytics. Use when building UI components, creating pages, implementing…
от bybren-llc★ 431 звезда на GitHubОб этом скилле
Frontend Patterns Skill
TEMPLATE: This skill uses
{{PLACEHOLDER}}tokens. Replace with your project values before use.
Purpose
Ensure consistent frontend development using established patterns for your framework (Next.js App Router, React, etc.), authentication provider, UI component library, and analytics platform.
When This Skill Applies
- Building new UI components or pages
- Implementing authentication flows
- Adding forms with validation
- Integrating analytics events
- Creating protected/authenticated routes
- Working with component libraries (shadcn/ui, Radix, etc.)
Server vs Client Components
// SERVER COMPONENT (default) - Use for:
// - Data fetching
// - Auth checks
// - SEO-critical content
import { auth } from "{{AUTH_SERVER_IMPORT}}";
export default async function DashboardPage() {
const { userId } = await auth();
// Fetch data server-side...
}
// CLIENT COMPONENT - Use for:
// - Interactivity (onClick, onChange)
// - Browser APIs (localStorage, window)
// - Hooks (useState, useEffect)
"use client";
import { useState } from "react";
export function InteractiveWidget() {
const [count, setCount] = useState(0);
// Interactive logic...
}
Protected Pages
CRITICAL: Always use forced dynamic rendering for authenticated pages:
import { auth } from "{{AUTH_SERVER_IMPORT}}";
import { redirect } from "next/navigation";
// REQUIRED - Auth context unavailable at build time
export const dynamic = "force-dynamic";
export default async function ProtectedPage() {
const { userId } = await auth();
if (!userId) {
redirect("/sign-in");
}
// Render protected content...
}
Route Organization
app/
+-- (auth)/ # Auth routes (sign-in, sign-up)
+-- (marketing)/ # Public marketing pages
| +-- page.tsx # Homepage
| +-- pricing/page.tsx
+-- dashboard/ # Protected user area
| +-- page.tsx
| +-- _components/ # Page-specific components
+-- admin/ # Admin-only area
+-- page.tsx
Authentication Patterns
Server Component Auth
import { auth } from "{{AUTH_SERVER_IMPORT}}";
export default async function Page() {
const { userId } = await auth();
// userId is string | null
}
Client Component Auth
"use client";
import { useUser, useAuth } from "{{AUTH_CLIENT_IMPORT}}";
export function UserProfile() {
const { user, isLoaded, isSignedIn } = useUser();
const { signOut } = useAuth();
if (!isLoaded) return <Skeleton />;
if (!isSignedIn) return <SignInPrompt />;
return <div>Welcome, {user.firstName}!</div>;
}
Admin Verification
import { auth } from "{{AUTH_SERVER_IMPORT}}";
import { redirect } from "next/navigation";
export const dynamic = "force-dynamic";
export default async function AdminPage() {
const { userId, orgId, orgRole } = await auth();
if (!userId) {
redirect("/sign-in");
}
// Verify admin role
const ADMIN_ORG_ID = process.env.{{ADMIN_ORG_ENV_VAR}};
const ADMIN_ROLE = "org:admin";
if (orgId !== ADMIN_ORG_ID || orgRole !== ADMIN_ROLE) {
redirect("/admin-denied");
}
// Render admin content...
}
Component Library Patterns
Import Convention
// Always use path alias for components
import { Button } from "{{UI_COMPONENTS_PATH}}/button";
import { Card, CardHeader, CardTitle, CardContent } from "{{UI_COMPONENTS_PATH}}/card";
import { Input } from "{{UI_COMPONENTS_PATH}}/input";
Form Pattern (React Hook Form + Zod)
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Button } from "{{UI_COMPONENTS_PATH}}/button";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "{{UI_COMPONENTS_PATH}}/form";
import { Input } from "{{UI_COMPONENTS_PATH}}/input";
const FormSchema = z.object({
email: z.string().email("Invalid email"),
name: z.string().min(1, "Name is required"),
});
type FormData = z.infer<typeof FormSchema>;
export function MyForm() {
const form = useForm<FormData>({
resolver: zodResolver(FormSchema),
defaultValues: { email: "", name: "" },
});
async function onSubmit(data: FormData) {
// Handle submission...
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
);
}
Analytics Patterns
Event Naming Convention
Use snake_case
Установить frontend-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл frontend-patterns?
Frontend patterns for modern web frameworks, component libraries, auth flows, and analytics. Use when building UI components, creating pages, implementing auth flows, adding analytics events, or working with component libraries. Do NOT use for API-only or backend-only changes.
Как установить скилл frontend-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-patterns запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic