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

frontend-patterns

Skill65 starsChanged 3 months agoMITView on GitHub

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

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 26 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 26 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)

  • Other versions82 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. KbWen/agentic-os★ 22499% same

    Wrote their own version · 81

    1. affaan-m/ECC★ 246ksame name
    2. rommapp/romm★ 14ksame name
    3. xu-xiang/everything-claude-code-zh★ 1.9ksame name
    4. bybren-llc/safe-agentic-workflow★ 405same name
    5. loulanyue/awesome-claude-notes★ 272same name
    6. cloudnative-co/claude-code-starter-kit★ 153same name
    7. tpavanipradeep/everything-claude-code★ 104same name
    8. mturac/everything-openai-codex★ 89same name
    9. mit-network/everything-claude-code★ 76same name
    10. tranhieutt/software_development_department★ 71same name

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

  • Used alongsideProjects with it also use brand-discovery, agent-sort 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.
    • ysyecustSkill

      brand-discovery

      Use when a brand needs to discover or articulate its identity through structured multi-session interviews. Covers purpose, positioning, audience, personality, voice, narrative, and founder-brand tension across 8 modules using laddering, 5 Whys, and projective techniques. Produces a resumable session with disk-persisted state and a master brandbook (90_SYNTHESIS.md).

      Also in 6 projects that use this

    • niloykumarbarmanSkill

      agent-sort

      Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

      Also in 13 projects that use this

    • royaluniondesign-sysSkill

      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 10 projects that use this

    • loulanyueSkill

      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 9 projects that use this

    • ronmkrSkill

      vite-patterns

      Vite build tool patterns including config, plugins, HMR, env variables, proxy setup, SSR, library mode, dependency pre-bundling, and build optimization. Activate when working with vite.config.ts, Vite plugins, or Vite-based projects.

      Also in 8 projects that use this

    • royaluniondesign-sysSkill

      content-hash-cache-pattern

      Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

      Also in 14 projects that use this

  • In this repository16 other files it gives its agents.

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.