implement-frontend

implement-frontend

Implementation standards for React/TypeScript/Next.js. Use when writing or reviewing frontend code, especially forms, state, hooks/components, and type safety.

7звезд
0форков
Обновлено 1/22/2026
SKILL.md
readonlyread-only
name
implement-frontend
description

Implementation standards for React/TypeScript/Next.js. Use when writing or reviewing frontend code, especially forms, state, hooks/components, and type safety.

Implement Frontend

Use this as the baseline for all frontend code. Fix violations.

Core rules

  • Keep a single source of truth for any data or state.
  • Enforce type safety: no any, no as casting, no ts-ignore.
  • Use React Hook Form for every form. No manual form state.
  • Use proto types as the contract; do not duplicate API types.
  • Components render; hooks own data fetching and business logic.

Code quality (baseline)

  • Use active verb names; use one word per concept.
  • Keep functions small, do one thing, and stay at one abstraction level.
  • Minimize arguments; avoid boolean flags; avoid negative conditionals.
  • Use else-if for multi-way decisions.
  • Replace magic numbers with named constants.
  • Comment intent, warnings, examples, or TODOs; never contradict code.
  • Remove commented-out or unused code.
  • Guard against hidden side effects.

Critical anti-patterns

  • Duplicate state or syncing state via useEffect.
  • API calls or business logic inside components.
  • zodResolver(schema as any) or other type escapes.
  • Form object in dependency arrays (use only formState fields).

References

  • See typescript-patterns.md for TypeScript and proto guidance.
  • See react-patterns.md for forms, hooks, and state.

Quick checks

  • Remove console.*, debugger, commented code, unused imports.
  • Use useId for IDs; avoid hardcoded IDs.
  • Zod v4 + createZodResolver.
  • React Query/Connect Query owns server state; RHF owns form state; useState only for UI.

Reliability & data fetching (required)

  • Optimistic updates must snapshot previous cache state and rollback on error.
  • Only optimistic-update for operations with a safe rollback; avoid for destructive actions unless server supports undo.
  • Retries are only for idempotent requests. Use exponential backoff with full jitter and cap attempts/time.
  • Always use AbortController for in-flight requests to prevent race conditions on unmount or rapid input.

Cache & invalidation (required)

  • React Query/Connect Query is the source of truth for server state; never copy server data into useState.
  • Mutations must invalidate or update only the affected queries; do not refetch everything.
  • setQueryData is allowed only for optimistic updates or small, scoped edits.

Performance & UX (required)

  • Follow audit-ui for accessibility and UX checklist items; use ui-animation for motion.
  • Lazy-load heavy UI (charts, editors, modals) with dynamic import and suspense fallback.
  • Reserve image sizes to avoid layout shift; use next/image when applicable.
  • Enforce bundle budgets in CI (document the budgets in the repo).

Observability (required)

  • Add error boundaries at route/layout level; report exceptions to Sentry (or project standard).
  • Tag client errors with userId/orgId and release (commit/semantic version), scrub PII.

Required structure (per feature)

components/<feature>/
  *.tsx
  hooks/                 # feature hooks only
  types/                 # schemas + UI types
  utils/
    proto-mappers.ts     # proto -> UI transforms
  constants.ts

Naming

  • Files: kebab-case. Components: PascalCase. Functions: camelCase. Constants: UPPER_SNAKE_CASE.

Every file should be ready to ship.

You Might Also Like

Related Skills

cache-components

cache-components

137Kdev-frontend

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

component-refactoring

component-refactoring

128Kdev-frontend

Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.

web-artifacts-builder

web-artifacts-builder

47Kdev-frontend

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.

frontend-design

frontend-design

47Kdev-frontend

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.

react-modernization

react-modernization

28Kdev-frontend

Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to latest React versions.

tailwind-design-system

tailwind-design-system

28Kdev-frontend

Build scalable design systems with Tailwind CSS v4, design tokens, component libraries, and responsive patterns. Use when creating component libraries, implementing design systems, or standardizing UI patterns.