frontend-pattern
Skill0 starsChanged 22 days agoMITView on GitHub
Frontend development patterns — component composition, state management, URL-as-state, data fetching, and animation best practices for React/TypeScript web applications
In this repository32 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- api-designSkill
- arch-constraint-guardSkill
- backend-patternsSkill
- clean-architectureSkill
- codebase-mappingSkill
- context-budgetSkill
- cqrsSkill
- ddd-architectureSkill
- debug-flowSkill
- dependency-auditSkill
- django-patternsSkill
- django-tddSkill
- event-driven-architectureSkill
- fd-codenavSkill
- fd-mapSkill
- git-releaseSkill
- git-workflowSkill
- golang-patternsSkill
- hexagonal-architectureSkill
- java-patternsSkill
- layered-architectureSkill
- performance-profilingSkill
- postgres-patternsSkill
- python-patternsSkill
- refactor-guideSkill
- research-firstSkill
- rust-patternsSkill
- saga-architectureSkill
- security-scanSkill
- tdd-workflowSkill
- test-gap-detectorSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Use compound components when related UI shares state and interaction semantics:
- Distinctive: line 140
Use compositor-friendly properties only:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend Pattern Skill
Implements maintainable, performant frontend patterns using React and TypeScript.
When to Activate
Activate when:
- Building new UI components
- Setting up state management
- Implementing data fetching
- Adding animations or transitions
- Structuring a new feature module
Component Patterns
Compound Components
Use compound components when related UI shares state and interaction semantics:
<Tabs defaultValue="overview">
<Tabs.List>
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="settings">Settings</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="overview">...</Tabs.Content>
<Tabs.Content value="settings">...</Tabs.Content>
</Tabs>- Parent owns state via
useStateor context - Children consume via context — no prop drilling
- Keeps keyboard handling, ARIA, and focus logic in the headless layer
Container / Presentational Split
// Container — owns data loading and side effects
function UserProfileContainer({ userId }: { userId: string }) {
const { data, isLoading } = useUser(userId);
if (isLoading) return <Skeleton />;
return <UserProfileView user={data} />;
}
// Presentational — receives props, renders UI
function UserProfileView({ user }: { user: User }) {
return (
<div>
<Avatar src={user.avatar} />
<h1>{user.name}</h1>
</div>
);
}State Management
| Concern | Tooling |
| Server state | TanStack Query, SWR, tRPC |
| Client state | Zustand, Jotai, signals |
| URL state | search params, route segments |
| Form state | React Hook Form or equivalent |
Do not duplicate server state into client stores. Derive values instead of storing redundant computed state.
URL As State
Persist shareable, bookmarkable state in the URL:
// Good: filters, sort, pagination in URL
const [searchParams, setSearchParams] = useSearchParams();
const filter = searchParams.get('filter') ?? 'all';
// Usage
<button onClick={() => setSearchParams({ filter: 'active' })}>
Active
</button>Data Fetching Patterns
Stale-While-Revalidate
Return cached data immediately, revalidate in background:
const { data } = useQuery({
queryKey: ['users', userId],
queryFn: () => fetchUser(userId),
staleTime: 5 * 60 * 1000, // 5 minutes
});Optimistic Updates
const mutation = useMutation({
mutationFn: updateUser,
onMutate: async (newData) => {
await queryClient.cancelQueries({ queryKey: ['user', newData.id] });
const previous = queryClient.getQueryData(['user', newData.id]);
queryClient.setQueryData(['user', newData.id], newData);
return { previous };
},
onError: (err, newData, context) => {
queryClient.setQueryData(['user', newData.id], context.previous);
},
});CSS Custom Properties
Define design tokens as CSS variables — do not hardcode values:
:root {
--color-surface: oklch(98% 0 0);
--color-text: oklch(18% 0 0);
--color-accent: oklch(68% 0.21 250);
--text-base: clamp(1rem, 0.92rem + 0.4vw, 1.125rem);
--space-section: clamp(4rem, 3rem + 5vw, 10rem);
--duration-fast: 150ms;
--duration-normal: 300ms;
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}Animation Guidelines
Use compositor-friendly properties only:
✅ transform, opacity, clip-path, filter
❌ width, height, top, left, margin, padding, border, font-size// Good
const style = { opacity: isVisible ? 1 : 0, transform: `translateY(${isVisible ? 0 : 20}px)` };
// Bad
const style = { height: isVisible ? 'auto' : 0 };Related Skills
- code-review — Review frontend code for quality
- security-scan — Check for XSS and injection vulnerabilities
- test-coverage — Ensure UI component tests exist
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.

