agentleFS
FaisalAlqarniFaisalAlqarni/sp-ecc/skills/frontend-patterns/SKILL.md

frontend-patterns

Skill9 starsChanged 10 months agoMITView on GitHub

Framework-agnostic UI development patterns for component composition, state management, data fetching, forms, accessibility, performance, and animation. Applies to React, Vue, Svelte, Rails views, Flutter, and any UI framework.

46 other projects use a version of this.

Adopted by

Most recently taken up by

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.
  • tpavanipradeepSkill

    kotlin-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-ySkill

    configure-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

  • mryeastcodeSkill

    nuxt4-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

  • InfopibeSkill

    content-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

  • InfopibeSkill

    ralphinho-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

  • WorldFlowAISkill

    project-guidelines-example

    Also in 18 projects that use this

  • +3 more from Infopibe

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 7

    Distinctive

    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:

    Prefer composition over inheritance — combine simple components to build complex ones

    line 16
  2. Distinctive:

    Use slot-based composition for flexible layouts (children, named slots, content blocks)

    line 17
  3. Distinctive:

    Every data fetch has 3 states: loading, success, error.

    line 43
  4. Distinctive:

    Use optimistic updates for instant-feeling interactions (update UI before server confirms)

    line 50
  5. Distinctive:

    Use controlled forms with explicit state

    line 61
  6. Distinctive:

    Prefer CSS-only solutions — they're lighter and more performant

    line 120
  7. Distinctive:

    Use framework animation libraries (Framer Motion, Vue Transitions, CSS Animations API) for complex orchestrated sequences

    line 121

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

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

UI Development Patterns

Universal patterns for building maintainable, performant user interfaces. These principles apply across all UI frameworks — React, Vue, Svelte, Angular, Rails ERB/Hotwire, Flutter, SwiftUI, and beyond.

Component Composition

Build UIs from small, single-responsibility, composable units.

Principles:

  • Each component does ONE thing well
  • Prefer composition over inheritance — combine simple components to build complex ones
  • Use slot-based composition for flexible layouts (children, named slots, content blocks)
  • Compound components share state through context/providers — the parent holds state, children consume it
  • Extract reusable components when a pattern appears 2+ times

Anti-patterns:

  • God components that handle rendering, data fetching, and business logic
  • Prop drilling through 4+ levels — use context/providers instead
  • Tightly coupling components to specific data shapes — accept generic props

State Management

Three categories of state — choose the simplest option that works:

Local State — Component-scoped, not shared. Toggle visibility, form input values, animation state. Keep it local.

Shared State — App-wide, multiple components need it. Auth status, theme, shopping cart. Use your framework's store/context mechanism. Don't over-architect — start local, elevate only when needed.

Server State — Cached API data with loading/error/stale semantics. Treat separately from UI state. Use dedicated data-fetching patterns (see below). Server state has unique concerns: caching, revalidation, optimistic updates.

Anti-patterns:

  • Putting everything in global state — most state is local
  • Duplicating server data in client state instead of caching
  • Managing derived state manually — compute it from source state

Data Fetching

Every data fetch has 3 states: loading, success, error. Handle all 3.

Principles:

  • Show loading indicators for operations > 200ms
  • Display meaningful error messages with retry options
  • Cache responses when appropriate — avoid redundant network calls
  • Debounce search/filter inputs (300-500ms)
  • Use optimistic updates for instant-feeling interactions (update UI before server confirms)
  • Handle stale data — show cached data while revalidating in background

Anti-patterns:

  • Ignoring error states — users see blank screens
  • Fetching on every render without caching
  • Blocking the entire UI during a single fetch

Form Handling

Principles:

  • Use controlled forms with explicit state
  • Validate on submit (not on every keystroke, unless UX requires inline validation)
  • Show errors near the relevant field, not in a generic banner
  • Clear field errors when the user starts correcting
  • Handle submission states: idle → submitting → success/error
  • Disable submit button during submission to prevent double-submit
  • Preserve form data on validation failure — never clear the form on error

Anti-patterns:

  • Silent validation failures — user doesn't know what's wrong
  • Validating on every keystroke without debounce (distracting)
  • Resetting the form on error (user loses their input)

Accessibility

Semantic HTML first — use button, nav, main, article, header, footer, section, label, fieldset — not div for everything. Correct semantics give you keyboard support and screen reader support for free.

ARIA when semantics aren't enough:

  • aria-label for icon-only buttons
  • aria-expanded for collapsible sections
  • aria-live for dynamic content updates
  • role="dialog" with aria-modal="true" for modals

Keyboard navigation:

  • Arrow keys in lists and menus
  • Escape to close overlays/modals
  • Enter/Space to activate buttons and links
  • Tab order follows visual layout

Focus management:

  • Trap focus inside modals (Tab cycles within modal, not behind it)
  • Restore focus to trigger element when modal closes
  • Auto-focus the first interactive element in new views

Color contrast: WCAG AA minimum (4.5:1 for text, 3:1 for large text).

Performance

Principles:

  • Lazy load heavy components — don't load what the user hasn't requested
  • Virtualize long lists — rendering 1000 items kills performance; render only visible items
  • Memoize expensive computations — recalculate only when inputs change
  • Code-split by route — each page loads only its own code
  • Minimize re-renders — avoid unnecessary state updates that cascade through the component tree
  • Optimize images — use appropriate formats (WebP/AVIF), lazy load below-fold images, provide srcset for responsive sizes

Anti-patterns:

  • Rendering 1000+ list items without virtualization
  • Loading all routes upfront in a SPA
  • Re-computing derived data on every render
  • Importing entire libraries when you need one function

Animation

Principles:

  • CSS transitions for simple state changes (hover, focus, visibility)
  • Scroll-triggered animations for engagement — elements animate as they enter viewport
  • Staggered reveals for lists — each item animates with a small delay (animation-delay: calc(index * 50ms))
  • Micro-interactions on hover/focus for polish — scale, shadow, color shifts
  • Prefer CSS-only solutions — they're lighter and more performant
  • Use framework animation libraries (Framer Motion, Vue Transitions, CSS Animations API) for complex orchestrated sequences
  • Respect prefers-reduced-motion — disable animations for users who opt out

High-impact moments:

  • Page load: one well-orchestrated staggered reveal creates more delight than scattered effects
  • State transitions: smooth crossfades between views, not jarring cuts
  • Feedback: button press effects, form submission confirmations

Anti-patterns:

  • Animation on every element (overwhelming, distracting)
  • Long durations (>500ms feels sluggish for UI transitions)
  • Ignoring reduced-motion preferences

Remember: Choose patterns that fit your project's complexity. A simple form doesn't need a state machine. A static page doesn't need virtualization. Apply the right level of architecture for the problem at hand.

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.