agentleFS
KbWenKbWen/agent-virtual-office/.agents/skills/frontend-patterns/SKILL.md

frontend-patterns

Skill35 starsChanged 4 months agoMITView on GitHub

Apply frontend conventions when components, pages, forms, or client state change.

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

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

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 4

    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:

    Lift state up: only when sibling components need it

    line 48
  2. Distinctive:

    Never duplicate server state in client store

    line 51
  3. Distinctive:

    Use data-fetching hooks (React Query, SWR, or equivalent) instead of raw fetch/axios in components

    line 55
  4. Distinctive:

    Use a form library for complex forms (React Hook Form, Formik, or equivalent)

    line 60

“Common” is measured: kept by at least 6 in 10 of the 10 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
<!-- This is a SCAFFOLD skill -->

Frontend Patterns

When to Apply

  • Classification: feature, architecture-change (if touching UI)
  • Phase: /implement (component design & build), /review (pattern compliance), /test (UI state coverage)
  • Trigger: Task involves creating or modifying UI components, pages, routes, or client-side state

Conventions

Customize after /app-init: Replace these generic conventions with your project's ADR and framework-specific patterns.

Component Structure

  • One component per file
  • Component file name matches export name (PascalCase)
  • Co-locate component-specific styles, tests, and types
  • Separate page-level components from reusable UI components

Suggested Directory Pattern

src/
├── components/        # Reusable UI components (Button, Modal, Card)
│   └── <Name>/
│       ├── <Name>.tsx
│       ├── <Name>.test.tsx
│       └── index.ts
├── pages/             # Page-level components (route targets)
│   └── <PageName>/
│       ├── <PageName>.tsx
│       ├── components/ # Page-specific components (not reusable)
│       └── hooks/      # Page-specific hooks
├── hooks/             # Shared custom hooks
├── services/          # API client functions
├── stores/            # State management (if applicable)
├── types/             # Shared TypeScript types
└── utils/             # Pure utility functions

State Management Principles

  • Local state first: useState/useReducer for component-specific state
  • Lift state up only when sibling components need it
  • Global state (store) only for truly app-wide state: auth, theme, user preferences
  • Server state (API data) managed by data-fetching library (React Query, SWR, etc.) — NOT in global store
  • Never duplicate server state in client store

Data Fetching

  • Centralize API calls in services/ directory
  • Use data-fetching hooks (React Query, SWR, or equivalent) instead of raw fetch/axios in components
  • Handle loading, error, and empty states for every data-dependent component
  • Implement optimistic updates for better UX where appropriate

Form Handling

  • Use a form library for complex forms (React Hook Form, Formik, or equivalent)
  • Validate on client AND server (client validation is UX, server validation is security)
  • Show inline errors next to fields, not just at form top
  • Disable submit button during submission (prevent double-submit)

Error Handling

  • Global error boundary for unexpected crashes
  • Per-component error handling for expected failures (API errors)
  • User-friendly error messages (never show raw error objects)
  • Retry mechanism for transient failures (network errors)

Checklist

During /implement:

  • Every data-dependent component handles: loading, error, empty, and success states
  • No business logic in components (extract to hooks or services)
  • No hardcoded strings (use constants or i18n keys)
  • Accessible: semantic HTML, aria labels on interactive elements, keyboard navigation
  • Responsive: works on mobile viewport (unless spec explicitly excludes mobile)
  • No direct API calls in components (use service layer)

During /review:

  • No prop drilling deeper than 2 levels (use context or composition)
  • No unnecessary re-renders (check memo/callback usage)
  • No sensitive data stored in localStorage/client state
  • Route guards for authenticated pages
  • Loading indicators for async operations

Heading-Scoped Read Note

For phase-entry loading, read only:

  • When to Apply
  • Checklist

Load Conventions, Anti-Patterns, and References on full read or cache miss only.

Anti-Patterns

  • God component: Component with 300+ lines doing everything. Split into smaller components.
  • Prop drilling: Passing props through 3+ levels of components. Use context or composition.
  • useEffect for everything: Using useEffect for derived state (use useMemo) or event handling (use event handlers).
  • Index as key: Using array index as React key in dynamic lists.
  • Fetch in render: Calling fetch/axios directly in component body or useEffect without a data-fetching library.
  • CSS-in-JS soup: Inline styles everywhere instead of consistent styling approach.
  • Ignoring empty state: Showing a blank page when data array is empty instead of a helpful message.
  • Alert/Console for errors: Using alert() or only console.error() instead of proper UI error handling.

References

  • Project ADR: docs/adr/ADR-002-project-architecture.md § Directory Structure, Naming
  • Spec template: .agentcortex/templates/spec-app-feature.md § Frontend
  • Security guardrails: .agent/rules/security_guardrails.md (A03: XSS prevention, A07: Auth)

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.