frontend-patterns
Skill419 starsChanged 4 months agoMITView on GitHub
Frontend patterns for Next.js App Router, Clerk auth, shadcn/Radix UI, and PostHog analytics. Use when building UI components, creating pages, implementing auth flows, or adding analytics events. Ensures consistent UX patterns and accessibility standards.
- Reads credentials
46 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- themusecatcher/ai-coding-kittheir own version, first seen Sep 15, 2026
- venables/skillstheir own version, first seen Sep 12, 2026
- talayash/agentriumtheir own version, first seen Sep 11, 2026
- KbWen/agentic-ostheir own version, first seen Sep 10, 2026
- best-radar/bradar-everything-claude-codetheir own version, first seen Sep 6, 2026
Used with
Projects with it also use kotlin-testing, configure-ecc and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tpavanipradeepSkillkotlin-testing
Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.
Also in 6 projects that use this
saxon-ySkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 12 projects that use this
mryeastcodeSkillnuxt4-patterns
Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.
Also in 5 projects that use this
InfopibeSkillcontent-hash-cache-pattern
Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.
Also in 11 projects that use this
InfopibeSkillralphinho-rfc-pipeline
RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.
Also in 9 projects that use this
WorldFlowAISkillproject-guidelines-example
Also in 18 projects that use this
- +3 more from Infopibe
Other versions46 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- adyba/pi-safe-workflow★ 061% same
Wrote their own version · 45
- WorldFlowAI/everything-claude-code★ 4ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- KbWen/agentic-os★ 206same name
- cloudnative-co/claude-code-starter-kit★ 151same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- hellangleZ/burn-in-cceverywhere-ralph★ 112same name
- Jamkris/everything-gemini-code★ 87same name
- tranhieutt/software_development_department★ 72same name
35 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/00-core-principles.mdcCursor rule
- .cursor/rules/01-git-workflow.mdcCursor rule
- .cursor/rules/02-pattern-discovery.mdcCursor rule
- .cursor/rules/03-safe-ai-dlc.mdcCursor rule
- .cursor/rules/04-knowledge-vault.mdcCursor rule
- .cursor/rules/10-backend-python.mdcCursor rule
- .cursor/rules/11-frontend-react.mdcCursor rule
- .cursor/rules/12-database-sql.mdcCursor rule
- .cursor/rules/13-testing.mdcCursor rule
- .cursor/rules/14-spec-creation.mdcCursor rule
- .cursor/rules/15-deployment.mdcCursor rule
- .cursor/rules/16-stripe-payments.mdcCursor rule
- .cursor/rules/20-agent-architect.mdcCursor rule
- .cursor/rules/21-agent-backend.mdcCursor rule
- .cursor/rules/22-agent-qas.mdcCursor rule
- .cursor/rules/23-agent-security.mdcCursor rule
- .cursor/rules/30-background-agents.mdcCursor rule
- .cursor/rules/31-mcp-integration.mdcCursor rule
- .cursor/rules/README.mdCursor rule
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- frontend-patternsSkill
- git-advancedSkill
- linear-sopSkill
- migration-patternsSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- git-advancedSkill
- linear-sopSkill
- migration-patternsSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Ensure consistent frontend development using established patterns for Next.js App Router, Clerk authentication, shadcn/ui components, and …
- Very specific: line 59
CRITICAL: Always use export const dynamic = 'force-dynamic' for authenticated pages:
- Distinctive: line 127
When auth is disabled via feature flags, provide graceful fallbacks:
- Distinctive: line 272
Use snake_case with category prefix:
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend Patterns Skill
Purpose
Ensure consistent frontend development using established patterns for Next.js App Router, Clerk authentication, shadcn/ui components, and PostHog analytics.
When This Skill Applies
Invoke this skill when:
- Building new UI components or pages
- Implementing authentication flows
- Adding forms with validation
- Integrating PostHog analytics events
- Creating protected/authenticated routes
- Working with shadcn/ui or Radix components
Next.js App Router Patterns
Server vs Client Components
// SERVER COMPONENT (default) - Use for:
// - Data fetching
// - Auth checks
// - SEO-critical content
// app/dashboard/page.tsx
import { auth } from "@clerk/nextjs/server";
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)
// app/dashboard/_components/interactive-widget.tsx
("use client");
import { useState } from "react";
export function InteractiveWidget() {
const [count, setCount] = useState(0);
// Interactive logic...
}Protected Pages
CRITICAL: Always use export const dynamic = 'force-dynamic' for authenticated pages:
// app/dashboard/[page]/page.tsx
import { auth } from "@clerk/nextjs/server";
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)
│ ├── sign-in/[[...sign-in]]/page.tsx
│ └── sign-up/[[...sign-up]]/page.tsx
├── (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.tsxClerk Authentication Patterns
Auth-Enabled Mode
// Server component auth check
import { auth } from '@clerk/nextjs/server';
export default async function Page() {
const { userId } = await auth();
// userId is string | null
}
// Client component auth
"use client"
import { useUser, useAuth } from '@clerk/nextjs';
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>;
}Auth-Disabled Mode (Feature Toggle)
When auth is disabled via feature flags, provide graceful fallbacks:
// Check feature flag
import { FEATURES } from '@/config/features';
export function AuthWrapper({ children }) {
if (!FEATURES.AUTH_ENABLED) {
// Show demo/guest experience
return <GuestExperience>{children}</GuestExperience>;
}
return <AuthenticatedWrapper>{children}</AuthenticatedWrapper>;
}Admin Verification
// app/admin/page.tsx
import { auth } from "@clerk/nextjs/server";
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.CLERK_ADMIN_ORG_ID;
const ADMIN_ROLE = "org:admin";
if (orgId !== ADMIN_ORG_ID || orgRole !== ADMIN_ROLE) {
redirect("/admin-denied");
}
// Render admin content...
}shadcn/ui Component Patterns
Import Convention
// Always use @/components/ui path alias
import { Button } from "@/components/ui/button";
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";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 '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { Input } from '@/components/ui/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>
);
}Button Variants
// Primary action
<Button>Save Changes</Button>
// Secondary action
<Button variant="secondary">Cancel</Button>
// Destructive action
<Button variant="destructive">Delete</Button>
// Ghost/subtle
<Button variant="ghost">Learn More</Button>
// Link style
<Button variant="link" asChild>
<Link href="/docs">Documentation</Link>
</Button>
// Loading state
<Button disabled={isLoading}>
{isLoading ? 'Saving...' : 'Save'}
</Button>PostHog Analytics Patterns
Event Naming Convention
Use snake_case with category prefix:
// User actions
"user_signed_up";
"user_signed_in";
"user_profile_updated";
// Feature usage
"feature_dark_mode_toggled";
"feature_export_clicked";
// Payments
"payment_checkout_started";
"payment_completed";
"subscription_upgraded";
// Content
"content_video_watched";
"content_pdf_downloaded";
// Navigation
"page_viewed";
"cta_clicked";Event Tracking
"use client"
import { usePostHog } from 'posthog-js/react';
export function TrackableButton() {
const posthog = usePostHog();
function handleClick() {
posthog?.capture('cta_clicked', {
button_text: 'Get Started',
page: '/pricing',
variant: 'primary',
});
}
return <Button onClick={handleClick}>Get Started</Button>;
}Page View Tracking
// Automatic via PostHogProvider (already configured)
// Manual tracking for SPAs:
"use client";
import { usePathname } from "next/navigation";
import { usePostHog } from "posthog-js/react";
import { useEffect } from "react";
export function PageViewTracker() {
const pathname = usePathname();
const posthog = usePostHog();
useEffect(() => {
if (pathname && posthog) {
posthog.capture("$pageview", { path: pathname });
}
}, [pathname, posthog]);
return null;
}Feature Flags
"use client"
import { useFeatureFlagEnabled } from 'posthog-js/react';
export function FeatureFlaggedComponent() {
const showNewFeature = useFeatureFlagEnabled('new-checkout-flow');
if (showNewFeature) {
return <NewCheckoutFlow />;
}
return <LegacyCheckoutFlow />;
}Accessibility Checklist
Required for All Components
- Keyboard Navigation: All interactive elements focusable via Tab
- Focus Indicators: Visible focus ring (Tailwind:
focus:ring-2) - Color Contrast: 4.5:1 minimum for text
- Alt Text: All images have descriptive alt text
- ARIA Labels: Form inputs have labels or aria-label
- Error States: Form errors announced to screen readers
Patterns
// Accessible button
<Button aria-label="Close dialog">
<X className="h-4 w-4" />
</Button>
// Accessible form field
<FormItem>
<FormLabel htmlFor="email">Email</FormLabel>
<FormControl>
<Input id="email" type="email" aria-describedby="email-error" />
</FormControl>
<FormMessage id="email-error" />
</FormItem>
// Skip link for keyboard users
<a href="#main-content" className="sr-only focus:not-sr-only">
Skip to main content
</a>Responsive Design Patterns
Tailwind Breakpoints
// Mobile-first approach
<div className="
px-4 // Mobile: 16px padding
md:px-6 // Tablet: 24px padding
lg:px-8 // Desktop: 32px padding
">
// Responsive grid
<div className="
grid
grid-cols-1 // Mobile: 1 column
md:grid-cols-2 // Tablet: 2 columns
lg:grid-cols-3 // Desktop: 3 columns
gap-4
">
// Hide/show at breakpoints
<div className="hidden md:block">Desktop only</div>
<div className="md:hidden">Mobile only</div>Container Pattern
// Standard container
<div className="container mx-auto px-4 md:px-6">
{/* Content */}
</div>
// Max-width constrained
<div className="max-w-4xl mx-auto px-4">
{/* Narrower content like articles */}
</div>Common Mistakes to Avoid
DON'T Do This
// ❌ Missing 'use client' for interactive components
import { useState } from 'react'; // Will error!
// ❌ Using hooks in server components
export default async function Page() {
const [state, setState] = useState(); // Will error!
}
// ❌ Missing force-dynamic on auth pages
export default async function ProtectedPage() {
const { userId } = await auth(); // May fail at build!
}
// ❌ Direct DOM manipulation
document.getElementById('foo'); // Use refs instead
// ❌ Inline styles (use Tailwind)
<div style={{ marginTop: '20px' }}> // Use className="mt-5"DO This Instead
// ✅ Proper client component
"use client"
import { useState } from 'react';
// ✅ Server component with auth
export const dynamic = 'force-dynamic';
export default async function Page() {
const { userId } = await auth();
}
// ✅ Use refs for DOM access
const inputRef = useRef<HTMLInputElement>(null);
// ✅ Tailwind classes
<div className="mt-5">Authoritative References
- UI Patterns:
patterns_library/ui/authenticated-page.md- Protected page patternform-with-validation.md- React Hook Form + Zoddata-table.md- Server-side paginated tablesmarketing-page.md- Public marketing pages
- Component Library:
components/ui/(shadcn/ui) - PostHog Setup:
lib/posthog/ - Feature Flags:
config/features.ts
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

