agentleFS
troskatertroskater/flowdeck-claude/skills/frontend-pattern/SKILL.md

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

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
  1. Distinctive:

    Use compound components when related UI shares state and interaction semantics:

    line 24
  2. Distinctive:

    Use compositor-friendly properties only:

    line 140

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 useState or 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

ConcernTooling
Server stateTanStack Query, SWR, tRPC
Client stateZustand, Jotai, signals
URL statesearch params, route segments
Form stateReact 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.