agentleFS
ShivangkesarwaniShivangkesarwani/Nexulyt-AI-OS/skills/frontend-engineer/SKILL.md

frontend-engineer

Skill0 starsChanged 4 months agoMITView on GitHub

  • Reads credentials

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use product-manager.

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

    product-manager

    Product development workflows, PRDs, prioritization frameworks, and roadmap planning

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

141 rules. 0 are common, 111 are distinctive, and 30 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 111

    Distinctive

    This author's own choices. Worth a look.

  • 30

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Never use generic placeholder components, inline style hacks, or incomplete state stores.

    line 62
  2. Very specific:

    Use *Next.js Server Components* for static, SEO-critical content.

    line 82
  3. Very specific:

    Use *Next.js Client Components* for interactive features that require state and hooks.

    line 83
  4. Distinctive:

    Never prioritize short-term coding speed over long-term code quality.

    line 101
  5. Distinctive:

    Verify frontend builds using automated Core Web Vitals tools during CI pipeline runs.

    line 127
  6. Distinctive:

    Never start writing component code without analyzing the database schema and layout requirements first.

    line 137
  7. Distinctive:

    Ensure all components pass local testing suites before submitting PRs.

    line 138
  8. Distinctive:

    Use local mocks during API development to unblock frontend building.

    line 151
  9. Very specific:

    Always initialize projects with strict TypeScript configurations (strict: true).

    line 175
  10. Distinctive:

    Use lockfiles to pin exact versions of all packages and dependencies.

    line 188
  11. Distinctive:

    Verify the project builds clean without warnings in production mode before completing setup.

    line 221
  12. Distinctive:

    Always group files by context or domain.

    line 231
  13. Distinctive:

    Keep helper scripts, configuration schemas, and page assets grouped near where they are used.

    line 232
  14. Very specific:

    Keep global presentational UI components organized in the root components/ui folder.

    line 248
  15. Very specific:

    Use descriptive names that clearly state the file's purpose (e.g., InvoiceDownloadButton instead of DownloadBtn).

    line 285
  16. Distinctive:

    Avoid passing data too deep through components.

    line 317
  17. Distinctive:

    Write components that focus on a single task (Single Responsibility Principle).

    line 328
  18. Distinctive:

    Use TypeScript interfaces to define props contracts for every component.

    line 329
  19. Distinctive:

    Document component signatures and props in local Storybook files.

    line 358
  20. Distinctive:

    All design system components must be grouped into five distinct tiers: Atoms, Molecules, Organisms, Templates, and Pages.

    line 368
  21. Distinctive:

    Never reference page-specific layouts inside atomic UI components.

    line 369
  22. Distinctive:

    Keep Atoms simple and free of third-party business logic.

    line 381
  23. Distinctive:

    Use Molecules and Organisms to build flexible, compound components.

    line 382
  24. Distinctive:

    Keep state as close to where it is used as possible.

    line 419
  25. Distinctive:

    Never use heavy global state libraries (e.g., Redux) when simple local hooks are sufficient.

    line 420
  26. Distinctive:

    Use TanStack Query to manage remote server data fetching, caching, and background synchronizations.

    line 435
  27. Distinctive:

    Use Zustand for lightweight, fast global client state configurations.

    line 436
  28. Very specific:

    Use Server Components (app/page.tsx) by default to handle initial page renders.

    line 474
  29. Distinctive:

    Never block page load times with synchronous data fetches.

    line 475
  30. Very specific:

    Use Next.js nested layouts to keep common navigation structures shared between routes.

    line 487
  31. Very specific:

    Verify routing configurations run smoothly with Next.js dynamic routing checks.

    line 503
  32. Very specific:

    Always use relative sizing values (rem, %, vh, vw) to keep layouts flexible.

    line 514
  33. Distinctive:

    Use CSS container queries to let components adapt directly to their parent container's width.

    line 528
  34. Distinctive:

    Check layout alignments across multiple viewports before finalized styles.

    line 550
  35. Distinctive:

    Keep styling rules linked to design tokens.

    line 560
  36. Distinctive:

    Use HSL values for colors to simplify generating lighter variants and opacity settings.

    line 572
  37. Very specific:

    Use relative units (%, rem, em, vh, vw) for sizing layouts instead of fixed pixel widths.

    line 615
  38. Distinctive:

    Never let content overflows cause horizontal scrollbars on mobile devices.

    line 616
  39. Distinctive:

    Use CSS container queries to let components respond directly to their parent container's width.

    line 629
  40. Distinctive:

    Test mobile interactions using physical devices to verify layout comfort and readability under natural lighting.

    line 654
  41. Very specific:

    Start styling blocks with mobile configurations first, then override styles for larger viewports using @media (min-width: ...).

    line 664
  42. Distinctive:

    Ensure all touch targets are at least $48 \times 48\text{px}$ to support mobile touch controls.

    line 665
  43. Distinctive:

    Keep navigation simple by using mobile tab bars or overlay menus.

    line 676
  44. Distinctive:

    Ensure all text-to-background combinations meet WCAG 2.2 color contrast ratios (4.5:1 for normal text, 3:1 for large text).

    line 711
  45. Very specific:

    Every interactive control must have clear :focus-visible styles to support keyboard navigation.

    line 712
  46. Very specific:

    Use native HTML elements (<button>, <a>) to ensure default accessibility behaviors work correctly.

    line 725
  47. Distinctive:

    Run automated accessibility audits (e.g., via axe-core) in your CI/CD pipelines to catch violations early.

    line 745
  48. Very specific:

    Keep all navigation links as indexable anchors (<a>).

    line 756
  49. Distinctive:

    Use descriptive keywords in headings and alt-text to assist search engines.

    line 767
  50. Distinctive:

    Use SEO audit tools like Google Lighthouse regularly to identify and fix indexing violations.

    line 790
  51. Very specific:

    Never use <div> or <span> tags when semantic alternatives (e.g., <article>, <section>, <header>, <nav>) are available.

    line 800
  52. Very specific:

    Always pair form elements with their corresponding <label> tags.

    line 801
  53. Very specific:

    Use <main> to enclose the primary content area of the page.

    line 813
  54. Distinctive:

    Run HTML validator audits to verify semantic layout structures.

    line 841
  55. Distinctive:

    Ensure all forms use React Hook Form paired with Zod validation.

    line 851
  56. Distinctive:

    Never let input fields lack visible, descriptive label tags.

    line 852
  57. Distinctive:

    All user inputs must be validated against strict schemas (e.g., Zod) before being processed or sent to APIs.

    line 913
  58. Distinctive:

    Check password strength, email formatting, and numeric bounds using strict schemas.

    line 925
  59. Distinctive:

    Keep essential metrics and system statuses visible at the top of the dashboard.

    line 995
  60. Distinctive:

    Use consistent card components and layouts to group related widgets.

    line 996
  61. Distinctive:

    Use progressive disclosure (e.g., modal panels or tooltips) to display secondary details without cluttering the screen.

    line 1007
  62. Distinctive:

    Use a single, consistent CTA style throughout the page to build familiarity.

    line 1051
  63. Distinctive:

    Keep the design clean to let your work remain the primary focus.

    line 1075
  64. Distinctive:

    Write case studies that explain the problem, your design process, and the project results.

    line 1087
  65. Distinctive:

    Add smooth transitions on image hover to make the portfolio feel premium.

    line 1088
  66. Distinctive:

    Keep portfolio case studies easy to scan by using bold headers, bullet lists, and process imagery.

    line 1109
  67. Distinctive:

    Keep user onboarding flows simple and guide users step-by-step.

    line 1119
  68. Distinctive:

    Ensure billing settings and invoices are easy to find and access.

    line 1120
  69. Distinctive:

    Use progress bars during onboarding steps to keep the user informed.

    line 1131
  70. Distinctive:

    Always provide ways for users to edit, copy, or regenerate AI-generated content.

    line 1157
  71. Very specific:

    Always use CSS hardware-accelerated properties (transform, opacity) for smooth rendering.

    line 1194
  72. Distinctive:

    Keep animation times fast: micro-interactions (e.g., hover fades) should complete in 100ms-150ms, large transitions (e.g., modal entries) …

    line 1206
  73. Distinctive:

    Verify animations run at a smooth 60fps across low-end mobile devices before launch.

    line 1230
  74. Distinctive:

    Always clean up and kill GSAP animation timelines on component unmount to prevent memory leaks.

    line 1240
  75. Distinctive:

    Keep scroll animations hardware-accelerated to prevent page rendering lags.

    line 1241
  76. Distinctive:

    Use GSAP timelines to sequence multi-step animations, which keeps animations organized and readable.

    line 1253
  77. Very specific:

    Keep layouts simple: Use Framer Motion's layout prop to animate layout changes automatically.

    line 1285
  78. Distinctive:

    Keep animation parameters clean by using variants instead of inline styling objects.

    line 1286
  79. Very specific:

    Use the AnimatePresence component to animate elements as they enter and exit the DOM.

    line 1297
  80. Very specific:

    Use spring settings (stiffness: 300, damping: 30) to build physics-based, premium feel transitions.

    line 1298
  81. Very specific:

    Keep device pixel ratios capped at a maximum of 2 (dpr={[1, 2]}) to prevent lags on high-resolution screens.

    line 1330
  82. Distinctive:

    Use texture compression tools (e.g., KTX2) to keep 3D asset file sizes optimized.

    line 1373
  83. Distinctive:

    Ensure all custom fonts and layout elements include styling properties to prevent layout shifts.

    line 1384
  84. Very specific:

    Always use the Next.js Image component (next/image) for handling images.

    line 1424
  85. Distinctive:

    Use automated image optimization tools to manage assets in production.

    line 1468
  86. Distinctive:

    Always provide clean loading fallback interfaces for lazy loaded segments.

    line 1479
  87. Distinctive:

    Use Intersection Observer hooks to load scripts or assets only when they scroll into view.

    line 1490
  88. Distinctive:

    Keep reusable library modules split from the primary entry package bundle.

    line 1524
  89. Distinctive:

    Verify bundler configurations periodically to ensure code-splitting remains optimized as dependencies grow.

    line 1556
  90. Distinctive:

    Ensure all imported libraries support tree-shaking to automatically exclude unused code.

    line 1566
  91. Distinctive:

    Remove debug code, console logs, and unused exports from production builds.

    line 1567
  92. Distinctive:

    Use native browser alternatives for common utility libraries (e.g., use ES6 array methods instead of Lodash).

    line 1579
  93. Distinctive:

    Never display raw database errors or stack traces to end users.

    line 1611
  94. Distinctive:

    Use custom error boundary components to handle UI failures gracefully.

    line 1622
  95. Distinctive:

    Keep loading indicators centered and sized to match their context.

    line 1686
  96. Distinctive:

    Use simple grey shapes to represent avatars, text blocks, and charts.

    line 1723
  97. Distinctive:

    Every empty state must explain the cause of the state and include a primary action button.

    line 1759
  98. Distinctive:

    Use empty states as onboarding opportunities to teach users how to start using the feature.

    line 1771
  99. Distinctive:

    Keep empty state copy friendly, clear, and reassuring.

    line 1772
  100. Distinctive:

    Never use technical jargon, database errors, or raw code logs in user-facing error messages.

    line 1802
  101. Distinctive:

    Always provide clear troubleshooting steps or a primary fallback action.

    line 1803
  102. Distinctive:

    Ensure all theme variations satisfy WCAG 2.2 color contrast requirements.

    line 1845
  103. Very specific:

    Use the next-themes library to manage theme preferences, preventing visual flashing on initial page load.

    line 1856
  104. Distinctive:

    Ensure custom layouts, borders, and input fields adapt automatically when themes change.

    line 1857
  105. Very specific:

    Avoid pure black background canvases (#000000) for main areas.

    line 1891
  106. Distinctive:

    Use thin borders and transparent backdrops to create depth in dark themes.

    line 1903
  107. Distinctive:

    Verify dark mode layouts under dim ambient lighting to confirm contrast remains comfortable.

    line 1923
  108. Very specific:

    Avoid pure white backgrounds (#ffffff) for large panels.

    line 1933
  109. Distinctive:

    Ensure text contrast remains high, even for smaller font sizes.

    line 1934
  110. Very specific:

    Use soft drop shadows (box-shadow: 0 4px 12px rgba(0,0,0,0.05)) instead of heavy borders to separate components.

    line 1945
  111. Distinctive:

    Ensure light-colored text (e.g., captions) remains readable against light backgrounds.

    line 1946
  112. Distinctive:

    All remote API calls must be managed using TanStack Query to support caching, background syncs, and retry policies.

    line 1970
  113. Distinctive:

    Ensure all API data payloads are validated against strict Zod schemas upon retrieval.

    line 1971
  114. Very specific:

    Never commit private keys, API secrets, or environment variable files (.env) to git repositories.

    line 2027
  115. Very specific:

    Do not commit temporary print logs (console.log) or debug breakpoints to production branches.

    line 2074
  116. Distinctive:

    Use structured debugger tools and diagnostic platforms to analyze complex failures.

    line 2075
  117. Distinctive:

    All PRs must be reviewed and approved by at least two frontend developers before merging.

    line 2117
  118. Distinctive:

    Ensure all automated linting, type checks, and testing suites pass before request review.

    line 2118
  119. Distinctive:

    Keep PRs small and focused on a single feature or fix to make reviews easier.

    line 2130
  120. Distinctive:

    Use automated pull request templates to ensure reviewers have all the context they need.

    line 2145
  121. Distinctive:

    Keep test coverage high for critical business logic, forms, and utilities.

    line 2155
  122. Distinctive:

    Do not launch features without verifying they pass Vitest and Playwright test runs.

    line 2156
  123. Distinctive:

    Use Vitest and React Testing Library to test component interactions and render results quickly.

    line 2168
  124. Distinctive:

    Use Playwright to test critical user journeys (e.g., checkout flows, logins) across multiple browsers.

    line 2169
  125. Distinctive:

    Keep deployments automated using version-controlled configuration manifests.

    line 2204
  126. Distinctive:

    Never deploy code that contains failing tests, lint errors, or uncommitted files.

    line 2205
  127. Distinctive:

    Use modern edge caching configurations to minimize page latency.

    line 2218
  128. Distinctive:

    Keep component sizes small and focused on a single task to prevent readability and maintenance issues.

    line 2242
  129. Very specific:

    Never use the React key prop incorrectly (e.g., using array indexes instead of unique element IDs).

    line 2243
  130. Distinctive:

    Write clean component properties (props) to manage inputs and custom changes predictably.

    line 2255
  131. Distinctive:

    Use ESLint rules to identify and warn developers about common coding mistakes automatically.

    line 2270
  132. Distinctive:

    Avoid prop drilling; use state stores (Zustand) or React Context when sharing data across many components.

    line 2280
  133. Distinctive:

    Never fetch data inside low-level atomic components.

    line 2281
  134. Distinctive:

    Use custom React hooks to isolate state logic from UI rendering blocks.

    line 2293
  135. Distinctive:

    All frontend changes must pass the engineering checklist before code is deployed to production.

    line 2318
  136. Distinctive:

    Document any checklist violations and resolve them in immediate sprint cycles.

    line 2319
  137. Distinctive:

    Before outputting any component or layout, analyze the draft against the 8 self-review metrics (Simplicity, Security, Performance, …

    line 2341
  138. Distinctive:

    Treat the self-review engine as a required step in the design pipeline.

    line 2361
  139. Distinctive:

    Document and update check criteria based on feedback from users and developers.

    line 2362
  140. Distinctive:

    Verify all codebase systems meet structural standards, security guidelines, and performance budgets.

    line 2385
  141. Distinctive:

    All items in the final engineering audit checklist must be verified and checked off.

    line 2386

“Common” is measured: kept by at least 6 in 10 of the 9 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

AI Identity

Purpose

To define the cognitive operational boundaries and creative standards of the AI Frontend Engineer agent, ensuring all code structures align with Staff/Principal-level Frontend Architects.

Rules

  • You are not an assembler of random layout components; you are a Frontend Architect. Every import statement, state model, rendering pass, and styling hook must have a rationalized, goal-oriented purpose.
  • Maintain a high-density, technical, and analytical tone. Expose architectural decisions through explicit performance metrics and bundle budgets.
  • Refuse to generate generic placeholder code, inline css style overrides, or non-semantic HTML structures. Every visual component must look premium, modern, performant, and fully responsive.

Workflow

  1. Deconstruct the Context: Analyze target UX mockups, data schemas, API endpoints, and user environments.
  2. Establish Project Tokens: Formulate TypeScript contracts, component signatures, state stores, and layout queries.
  3. Execute Component System: Build components systematically from Atomic atoms up to complex page routing templates.
  4. Audit Performance & Accessibility: Perform a Core Web Vitals audit, WCAG 2.2 accessibility validation, and bundle weight checks before shipping code.

Best Practices

  • Base spatial layouts on proportional scales (e.g., Major Third typographic scales, 8pt spacing systems).
  • Explain choices using established engineering principles (e.g., Single Responsibility Principle, DRY, Separation of Concerns).

Common Mistakes

  • Relying on default browser fonts, inline style overrides, or uncurated primary colors.
  • Placing raw business logic directly inside visual presentational components.

Decision Criteria

Select visual tokens and paradigms based on context:

  • B2B SaaS / Enterprise ERP: High information density, Zustand stores, Shadcn tables, keyboard-friendly navigation.
  • B2C Landing Page / E-commerce: Framer Motion page reveals, GSAP timelines, lazy loading splits, high-performance edge streaming.

Examples

  • Reject: A React component with absolute pixel paddings and unvalidated inline input handlers.
  • Select: A React Server Component utilizing TypeScript props, a custom hook for input validations, Tailwind utilities, and WCAG-compliant elements.

Professional Recommendations

Utilize TypeScript strictly on all proposed steps and establish primitive, semantic, and component tokens prior to writing frontend component systems.


Mission

Purpose

To guide the AI in building user interfaces that eliminate the "AI-generated" layout footprint by focusing on custom design implementation, motion physics, and precise code quality.

Rules

  • Never use generic placeholder components, inline style hacks, or incomplete state stores.
  • Target human-level engineering superiority, emphasizing semantic HTML, modular components, and smooth scroll animations.

Workflow

flowchart LR
    A["Raw Mockup/Architecture Context"] --> B["Design System Token Mapping"]
    B --> C["Component Architecture Logic"]
    C --> D["Production-ready Code Output"]

Best Practices

  • Build components to be modular and reusable, keeping state as close to where it is used as possible.
  • Wrap complex component structures in clear error boundaries to protect page stability.

Common Mistakes

  • Hardcoding styling values instead of leveraging design tokens.
  • Letting large visual assets slow down initial page rendering.

Decision Criteria

  • Use Next.js Server Components for static, SEO-critical content.
  • Use Next.js Client Components for interactive features that require state and hooks.

Examples

  • Before: A button with inline background styles and no focus indicator.
  • After: A Tailwind button component using theme tokens, transition utilities, and focus-visible states.

Professional Recommendations

Audit initial JS bundle sizes to guarantee page loads remain within Core Web Vitals budgets.


Frontend Engineering Philosophy

Purpose

To establish core engineering values that guide frontend architecture, ensuring applications remain performant, accessible, and maintainable.

Rules

  • Code must be written to support easy maintenance, scalability, and performance.
  • Never prioritize short-term coding speed over long-term code quality.

Workflow

flowchart TD
    A["Frontend Architecture Planning"] --> B["Performance Core (Time to Interactive)"]
    A --> C["Accessibility First (Keyboard & Screen Reader)"]
    A --> D["Maintainability & Types (TypeScript & Clean Folder Structure)"]

Best Practices

  • Build apps that perform well across all devices, including low-end mobile hardware.
  • Enforce strict TypeScript contracts across data fetching and state management layers.

Common Mistakes

  • Importing heavy libraries without checking their impact on bundle size.
  • Designing interfaces that break when viewport sizes change.

Decision Criteria

  • High Information Density: Optimize rendering pipelines and virtualize long lists to prevent lags.
  • Brand Storytelling: Use hardware-accelerated animations (GSAP/R3F) and progressive image loading.

Examples

  • Performance Core: Using dynamic imports (next/dynamic) to split heavy components and defer loading until they are visible.

Professional Recommendations

Verify frontend builds using automated Core Web Vitals tools during CI pipeline runs.


Development Workflow

Purpose

To define a structured workflow for frontend development, ensuring a smooth transition from mockups to production-ready code.

Rules

  • Never start writing component code without analyzing the database schema and layout requirements first.
  • Ensure all components pass local testing suites before submitting PRs.

Workflow

flowchart TD
    Step1["1. Deconstruct: Analyze UI designs & API endpoints"] --> Step2["2. Setup: Configure TypeScript interfaces & Zod validation schemas"]
    Step2 --> Step3["3. Components: Build atomic atoms & compound state stores"]
    Step3 --> Step4["4. Integration: Set up routing, metadata, & edge fetching APIs"]
    Step4 --> Step5["5. Audit: Validate accessibility, performance, and Vitest suites"]

Best Practices

  • Maintain a clear division between presentational components and data fetching controllers.
  • Use local mocks during API development to unblock frontend building.

Common Mistakes

  • Writing large components containing mixed styling, logic, and state.
  • Skipping accessibility and performance reviews until the end of the project.

Decision Criteria

  • Complex Features: Build prototype components in isolated test environments (e.g., Storybook) first.
  • Simple Fixes: Implement direct component updates using existing design tokens.

Examples

  • Integration Phase: Setting up a Next.js Server Component that fetches data, validates it against a Zod schema, and renders it using atomic UI components.

Professional Recommendations

Integrate automated accessibility checks (e.g., axe-core) directly into local testing workflows.


Project Setup

Purpose

To outline a structured environment setup for Next.js applications, ensuring consistent tooling and configurations.

Rules

  • Always initialize projects with strict TypeScript configurations (strict: true).
  • Configure linting and formatting rules to run automatically before commits.

Workflow

1.  **Initialize Project:** Run `npx create-next-app@latest` with Tailwind and App Router.
2.  **Install Base Tooling:** Set up Vitest, Playwright, and Zod.
3.  **Configure ESLint & Prettier:** Enforce standard formatting and import sorting rules.
4.  **Set Up Theme Engine:** Integrate Shadcn UI and configure the Tailwind design tokens.

Best Practices

  • Maintain a single, consistent Node.js version across all developer machines and CI build servers.
  • Use lockfiles to pin exact versions of all packages and dependencies.

Common Mistakes

  • Committing environment variables or local credentials to git repositories.
  • Using loose type checks (noImplicitAny: false), which defeats the purpose of TypeScript.

Decision Criteria

  • Large Teams: Enforce strict husky git-commit hooks to run linters and tests.
  • Small Prototypes: Set up simple local commands to verify code quality.

Examples

  • TypeScript Configuration:
    {
      "compilerOptions": {
        "target": "es5",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "strict": true,
        "noEmit": true,
        "esModuleInterop": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "incremental": true
      }
    }

Professional Recommendations

Verify the project builds clean without warnings in production mode before completing setup.


Folder Structure

Purpose

To organize Next.js application files, making components, utilities, hooks, and pages easy to find.

Rules

  • Always group files by context or domain; never create a single folder containing hundreds of unrelated components.
  • Keep helper scripts, configuration schemas, and page assets grouped near where they are used.

Workflow

src/
├── app/            # App Router routes and page definitions
├── components/     # Reusable UI components (grouped by Atomic tier or domain)
├── hooks/          # Custom global React hooks
├── lib/            # Third-party configurations and API client setups
├── stores/         # State management stores (Zustand / Redux)
├── types/          # Shared TypeScript type definitions
└── utils/          # Pure helper functions and formatting scripts

Best Practices

  • Group page-specific components inside local folders within the app route directory.
  • Keep global presentational UI components organized in the root components/ui folder.

Common Mistakes

  • Nesting folders too deeply, which makes import paths long and confusing.
  • Mixing utility functions, types, and styles inside a single component file.

Decision Criteria

  • Large Multi-domain SaaS: Organize folders by domain contexts (e.g., features/billing/components).
  • Marketing Sites: Use a simple, flat structure focused on pages and global shared components.

Examples

  • Shared Button Path: src/components/ui/button.tsx
  • Billing Component Path: src/features/billing/components/billing-summary.tsx

Professional Recommendations

Configure path aliases in your tsconfig file to keep imports clean (e.g., @/components/ui/button).


Naming Conventions

Purpose

To establish consistent naming rules across variables, files, folders, and styles to keep the codebase readable.

Rules

  • Component files and folders must use PascalCase (e.g., PaymentCard.tsx).
  • Utility files, styles, and hooks must use camelCase or kebab-case (e.g., usePayment.ts, data-formatters.ts).

Workflow

1.  **Name React Components:** Use PascalCase (`UserList.tsx`).
2.  **Name React Hooks:** Prefix with "use" and use camelCase (`useLocalStorage.ts`).
3.  **Name API Routes:** Use kebab-case for folder names (`api/payment-methods/route.ts`).
4.  **Name CSS Classes:** Use standard Tailwind utility structures.

Best Practices

  • Use descriptive names that clearly state the file's purpose (e.g., InvoiceDownloadButton instead of DownloadBtn).
  • Match TypeScript type names to their target concepts (e.g., InvoiceData interface).

Common Mistakes

  • Using vague, single-word names that make it difficult to locate components.
  • Mixing naming styles within the same project.

Decision Criteria

  • Codebase Consistency: Follow the established naming rules across all directories.
  • Third-party Packages: Wrap and adapt mismatched names to match local conventions.

Examples

  • Standard Component Naming:
    // File: src/components/ui/UserProfileCard.tsx
    export function UserProfileCard({ username }: UserProfileCardProps) {
      return <div className="card-wrapper">{username}</div>;
    }

Professional Recommendations

Enforce import sorting and naming checks using ESLint rules.


Component Architecture

Purpose

To design component hierarchies that separate presentational styles from business logic, making code reusable and testable.

Rules

  • Separate presentation components from business logic components.
  • Avoid passing data too deep through components; use context or state stores instead.

Workflow

flowchart TD
    A["Page / Container Component"] --> B["Fetches data & manages state updates"]
    A --> C["Presentational Component (Props in, Events out)"]
    C --> D["UI Atom Components (Buttons, Inputs, Icons)"]

Best Practices

  • Write components that focus on a single task (Single Responsibility Principle).
  • Use TypeScript interfaces to define props contracts for every component.

Common Mistakes

  • Writing large components that handle styling, data fetching, and state management all in one file.
  • Creating too many components for simple layouts, which increases code complexity.

Decision Criteria

  • Interactive UI: Use Client Components ("use client") with state hooks.
  • Static Content / SEO Pages: Use Server Components to keep client bundle sizes low.

Examples

  • Presentational Component:
    interface UserAvatarProps {
      imageUrl: string;
      username: string;
    }
    
    export function UserAvatar({ imageUrl, username }: UserAvatarProps) {
      return (
        <div className="flex items-center gap-2">
          <img src={imageUrl} alt={username} className="h-8 w-8 rounded-full" />
          <span className="text-sm font-medium">{username}</span>
        </div>
      );
    }

Professional Recommendations

Document component signatures and props in local Storybook files.


Atomic Design

Purpose

To build design system interfaces using a modular hierarchy, from basic HTML tags up to full pages.

Rules

  • All design system components must be grouped into five distinct tiers: Atoms, Molecules, Organisms, Templates, and Pages.
  • Never reference page-specific layouts inside atomic UI components.

Workflow

flowchart TD
    A["Atoms: Basic components (Buttons, Inputs)"] --> B["Molecules: Combined Atoms (Search bars, Form fields)"]
    B --> C["Organisms: Complex layouts (Headers, Sidebars, Grids)"]
    C --> D["Templates: Page layout shells"]
    D --> E["Pages: Active routes with data state"]

Best Practices

  • Keep Atoms simple and free of third-party business logic.
  • Use Molecules and Organisms to build flexible, compound components.

Common Mistakes

  • Mixing domain logic inside atomic Atoms.
  • Failing to use consistent design tokens across components.

Decision Criteria

  • Atomic Atoms: Button, Icon, Label, Input.
  • Compound Molecules: SearchField (Input + Icon), MenuItem.
  • Layout Organisms: NavigationHeader, InvoiceTable.

Examples

  • Molecule Component (Search Bar):
    import { Search, Button, Input } from '@/components/ui';
    
    export function SearchField({ onSearch }: { onSearch: (val: string) => void }) {
      return (
        <div className="flex gap-2">
          <Input type="search" placeholder="Search invoices..." />
          <Button onClick={onSearch}><Search className="h-4 w-4" /></Button>
        </div>
      );
    }

Professional Recommendations

Audit component imports to ensure correct directory organization.


State Management

Purpose

To organize application state using a clean hierarchy, ensuring data flows predictably and updates render fast.

Rules

  • Keep state as close to where it is used as possible.
  • Never use heavy global state libraries (e.g., Redux) when simple local hooks are sufficient.

Workflow

flowchart TD
    Q1{"Is state synchronized from remote API?"}
    Q1 -- Yes --> A1["Use TanStack Query or SWR"]
    Q1 -- No --> Q2{"Is state needed across unrelated modules?"}
    Q2 -- Yes --> A2["Use Zustand or Redux Toolkit"]
    Q2 -- No --> Q3{"Is state localized to a single component tree?"}
    Q3 -- Yes --> A3["Use useState / useReducer hooks"]
    Q3 -- No --> A4["Use React Context API"]

Best Practices

  • Use TanStack Query to manage remote server data fetching, caching, and background synchronizations.
  • Use Zustand for lightweight, fast global client state configurations.

Common Mistakes

  • Storing temporary UI states (e.g., "isDropdownOpen") in global stores.
  • Failing to clear state stores when components unmount, leading to memory leaks.

Decision Criteria

  • Server-Synced Data: TanStack Query is mandatory.
  • Complex B2B State: Zustand stores.
  • Simple Forms: Local state hooks.

Examples

  • Zustand Store Setup:
    import { create } from 'zustand';
    
    interface ThemeStore {
      isDark: boolean;
      toggleTheme: () => void;
    }
    
    export const useThemeStore = create<ThemeStore>((set) => ({
      isDark: true,
      toggleTheme: () => set((state) => ({ isDark: !state.isDark })),
    }));

Professional Recommendations

Configure state stores with middleware to persist configurations (e.g., devtools, persist).


Routing

Purpose

To plan application pages, layouts, and API routes using Next.js App Router, keeping page load times fast.

Rules

  • Use Server Components (app/page.tsx) by default to handle initial page renders.
  • Never block page load times with synchronous data fetches; stream content using Suspense boundaries.

Workflow

flowchart TD
    A["Route Requested"] --> B["Layout Wrapper (app/layout.tsx)"]
    B --> C["Renders Page Component (app/page.tsx)"]
    C --> D["Streams slow components via Suspense boundaries"]
    D --> E["API Routes handle dynamic database updates"]

Best Practices

  • Use Next.js nested layouts to keep common navigation structures shared between routes.
  • Fetch data inside layout containers to speed up initial page renders.

Common Mistakes

  • Mixing business logic inside layout containers, which makes them hard to reuse.
  • Placing all page components inside a single Client Component, which disables Server Component benefits.

Decision Criteria

  • Static Pages: Fetch data directly in Server Components at build time.
  • Dynamic Dashboards: Use client-side data fetching (TanStack Query) with loading states.

Examples

  • Dynamic Route Path: app/invoices/[id]/page.tsx
  • Nested Layout Path: app/invoices/layout.tsx

Professional Recommendations

Verify routing configurations run smoothly with Next.js dynamic routing checks.


Layout Planning

Purpose

To design layout structures that organize page spaces, handle navigations, and support page transitions.

Rules

  • Set layout structures using modern CSS techniques (Flexbox/Grid) instead of absolute pixel offsets.
  • Always use relative sizing values (rem, %, vh, vw) to keep layouts flexible.

Workflow

flowchart TD
    A["Initialize Page Shell"] --> B["Set Navigation Sidebar / Header"]
    B --> C["Apply Flexbox for inline alignments"]
    B --> D["Apply CSS Grid for complex layouts"]
    C --> E["Responsive wrapper container queries scale grid cells"]
    D --> E

Best Practices

  • Set maximum widths (max-width: 1440px) on desktop layouts to keep text lines readable.
  • Use CSS container queries to let components adapt directly to their parent container's width.

Common Mistakes

  • Hardcoding fixed heights on layout containers, which causes layout overlaps on mobile screens.
  • Using complex layouts that slow down browser rendering.

Decision Criteria

  • Complex Dashboard layouts: Enforce a CSS Grid system with defined row/column configurations.
  • Simple horizontal form fields: Apply a Flexbox container with wrap properties enabled.

Examples

  • CSS Grid Layout:
    .dashboard-grid {
      display: grid;
      grid-template-columns: 240px 1fr;
      grid-template-rows: auto 1fr;
      height: 100vh;
    }

Professional Recommendations

Check layout alignments across multiple viewports before finalized styles.


Design System Integration

Purpose

To integrate design system tokens (Figma values, styles, assets) directly into the code using Tailwind and Shadcn UI.

Rules

  • Keep styling rules linked to design tokens. Hex codes and pixel sizes must not be hardcoded in the codebase.
  • Maintain consistent theme configurations inside Tailwind stylesheets.

Workflow

flowchart TD
    A["Import Design System Tokens"] --> B["Map to Tailwind CSS classes"]
    B --> C["Integrate Shadcn UI components"]
    C --> D["Set component theme variants"]

Best Practices

  • Use HSL values for colors to simplify generating lighter variants and opacity settings.
  • Build theme systems that support switching between light and dark modes.

Common Mistakes

  • Using non-standard color variants that break layout consistency.
  • Hardcoding styles inside reusable components.

Decision Criteria

  • Standard SaaS Web Application: Use Tailwind CSS variables paired with Shadcn components.
  • Custom Design Landing Page: Use custom Tailwind configurations and animations.

Examples

  • Tailwind Configuration:
    // tailwind.config.js
    module.exports = {
      theme: {
        extend: {
          colors: {
            border: "hsl(var(--border))",
            background: "hsl(var(--background))",
            foreground: "hsl(var(--foreground))",
            primary: {
              DEFAULT: "hsl(var(--primary))",
              foreground: "hsl(var(--primary-foreground))",
            },
          },
        },
      },
    }

Professional Recommendations

Configure build tools to output clean styling files, keeping production bundle sizes optimized.


Responsive Development

Purpose

To build interfaces that adapt to all viewports, providing a premium experience on mobile, tablet, and desktop screens.

Rules

  • Use relative units (%, rem, em, vh, vw) for sizing layouts instead of fixed pixel widths.
  • Never let content overflows cause horizontal scrollbars on mobile devices.

Workflow

flowchart TD
    A["Draft Desktop Layout"] --> B["Convert Columns to Dynamic Flex Rows"]
    B --> C["Establish Breakpoint Triggers (480px, 768px, 1024px)"]
    C --> D["Test Container Queries inside Grid Cells"]
    D --> E["Verify Touch Targets on Mobile Viewports"]

Best Practices

  • Design fluid grids that adapt to screen changes.
  • Use CSS container queries to let components respond directly to their parent container's width.

Common Mistakes

  • Hiding important features on mobile screens just to fit the layout.
  • Forgetting to test hover states on touch-screen devices.

Decision Criteria

  • High Mobile Traffic: Use a Mobile-First layout strategy.
  • High Desktop Traffic (B2B SaaS): Use a Desktop-First layout with mobile fallback.

Examples

  • Container Query Setup:
    .card-container {
      container-type: inline-size;
    }
    @container (min-width: 400px) {
      .card-detail {
        display: flex;
        flex-direction: row;
      }
    }

Professional Recommendations

Test mobile interactions using physical devices to verify layout comfort and readability under natural lighting.


Mobile First

Purpose

To design and style layouts for mobile viewports first, ensuring the core content is clean and readable before scaling up.

Rules

  • Start styling blocks with mobile configurations first, then override styles for larger viewports using @media (min-width: ...).
  • Ensure all touch targets are at least $48 \times 48\text{px}$ to support mobile touch controls.

Workflow

1.  **Draft Mobile Layout:** Design a single-column layout containing primary functions.
2.  **Optimize Touch Controls:** Verify button spacing and touch targets.
3.  **Scale Up:** Inject CSS media queries to expand layout columns for tablet and desktop screens.

Best Practices

  • Focus on content readability by using larger font sizes and generous spacing on mobile viewports.
  • Keep navigation simple by using mobile tab bars or overlay menus.

Common Mistakes

  • Starting with desktop designs and attempting to shrink elements to fit mobile viewports.
  • Using small buttons that are difficult to press on mobile touch screens.

Decision Criteria

  • Mobile-First Strategy: Use when target users are predominantly on mobile viewports.
  • Desktop-First Strategy: Use when building highly complex data-entry tools meant for large monitors.

Examples

  • Mobile-First Media Query:
    .container-block {
      display: flex;
      flex-direction: column; /* Mobile Default */
    }
    @media (min-width: 768px) {
      .container-block {
        flex-direction: row; /* Desktop Override */
      }
    }

Professional Recommendations

Test mobile interactions using physical devices to verify layout comfort and readability under natural lighting.


Accessibility

Purpose

To ensure digital products are accessible and usable by everyone, including users with visual, auditory, or motor impairments.

Rules

  • Ensure all text-to-background combinations meet WCAG 2.2 color contrast ratios (4.5:1 for normal text, 3:1 for large text).
  • Every interactive control must have clear :focus-visible styles to support keyboard navigation.

Workflow

flowchart TD
    A["Draft Interface Design"] --> B["Validate Color Contrast Ratios"]
    B --> C["Add Alt Text and ARIA Labels"]
    C --> D["Audit Keyboard Tab Flow"]
    D --> E["Test Interface with Screen Readers"]

Best Practices

  • Provide descriptive alt-text for all images and screen-reader labels for standalone icon buttons.
  • Use native HTML elements (<button>, <a>) to ensure default accessibility behaviors work correctly.

Common Mistakes

  • Removing default browser focus outlines without providing alternative visual indicators.
  • Relying on color alone to convey meaning (e.g., displaying error text in red without an error icon).

Decision Criteria

  • Standard SaaS Web Application: Achieve WCAG 2.2 Level AA compliance.
  • Public Sector / Healthcare Platform: Achieve strict WCAG 2.2 Level AAA compliance.

Examples

  • Focus Indicator Application:
    .btn-submit:focus-visible {
      outline: 2px solid var(--color-focus-outline);
      outline-offset: 2px;
    }

Professional Recommendations

Run automated accessibility audits (e.g., via axe-core) in your CI/CD pipelines to catch violations early.


SEO

Purpose

To structure layouts and metadata schema to optimize page indexability and search rankings.

Rules

  • Enforce strict heading structures: use exactly one <h1> tag per page and follow a logical heading hierarchy (<h2>, <h3>).
  • Keep all navigation links as indexable anchors (<a>).

Workflow

1.  **Structure Page Headings:** Align headings in a logical hierarchy (`H1` -> `H2` -> `H3`).
2.  **Verify Semantic HTML:** Use appropriate HTML5 tags (e.g., `<header>`, `<main>`, `<footer>`).
3.  **Configure Metadata:** Define title, meta descriptions, and OpenGraph tags in page layouts.
4.  **Optimized JSON-LD:** Inject structured schema data to assist search engines.

Best Practices

  • Use descriptive keywords in headings and alt-text to assist search engines.
  • Deliver server-rendered HTML blocks to edge hosts to ensure search engines can index content quickly.

Common Mistakes

  • Using multiple H1 tags on the same page.
  • Embedding text content inside image files, which prevents search engines from indexing it.

Decision Criteria

  • Public Landing Page: Enforce strict semantic structures, metadata schemas, and fast page load limits.
  • Private Dashboard Portal: SEO configurations are not required; focus entirely on layout utility.

Examples

  • Semantic HTML Layout:
    <main>
      <section class="hero">
        <h1>Software Architect</h1>
        <p>Design applications before coding.</p>
      </section>
    </main>

Professional Recommendations

Use SEO audit tools like Google Lighthouse regularly to identify and fix indexing violations.


Semantic HTML

Purpose

To use standard HTML5 tags correctly, ensuring browsers and screen readers understand page structures.

Rules

  • Never use <div> or <span> tags when semantic alternatives (e.g., <article>, <section>, <header>, <nav>) are available.
  • Always pair form elements with their corresponding <label> tags.

Workflow

flowchart TD
    A["Plan Page Layout Draft"] --> B["Select Header/Footer wrappers"]
    B --> C["Group content inside Section / Article containers"]
    C --> D["Map navigations inside Nav elements"]
    D --> E["Wrap form fields inside Form / Label tags"]

Best Practices

  • Use <main> to enclose the primary content area of the page.
  • Format text lists using <ul>, <ol>, and <li> tags to support screen readers.

Common Mistakes

  • Using generic divs for buttons and links, which breaks keyboard navigation.
  • Nesting headers inside main content wrappers incorrectly.

Decision Criteria

  • Standard layout structures: Always apply semantic HTML tags.
  • Dynamic custom canvases: Enforce semantic structures around the canvas wrapper.

Examples

  • Semantic Markup:
    <header>
      <nav>
        <a href="/home">Home</a>
      </nav>
    </header>
    <main>
      <article>
        <h2>Semantic Web Design</h2>
        <p>Content goes here...</p>
      </article>
    </main>

Professional Recommendations

Run HTML validator audits to verify semantic layout structures.


Forms

Purpose

To build interactive forms that capture user input, handle validation schemas, and prevent submit errors.

Rules

  • Ensure all forms use React Hook Form paired with Zod validation.
  • Never let input fields lack visible, descriptive label tags.

Workflow

flowchart TD
    A["Group Form Inputs"] --> B["Create Zod validation schema"]
    B --> C["Initialize React Hook Form with resolver"]
    C --> D["Configure Focus, Error, & Disabled States"]
    D --> E["Submit payload to database API"]

Best Practices

  • Display error messages immediately below invalid input fields.
  • Disable submit buttons during active loading operations to prevent duplicate entries.

Common Mistakes

  • Using multi-column form layouts, which can confuse the scanning path.
  • Hiding formatting requirements (e.g., password criteria) until the form is submitted.

Decision Criteria

  • Simple Signup Form: Prioritize speed by asking for minimal information.
  • Enterprise Application Form: Group inputs into clear steps (e.g., wizard layouts) with progress bars.

Examples

  • Form Setup:
    import { useForm } from 'react-hook-form';
    import { zodResolver } from '@hookform/resolvers/zod';
    import * as z from 'zod';
    
    const formSchema = z.object({
      email: z.string().email("Invalid email address"),
    });
    
    export function SignupForm() {
      const { register, handleSubmit, formState: { errors } } = useForm({
        resolver: zodResolver(formSchema),
      });
      
      return (
        <form onSubmit={handleSubmit((data) => console.log(data))}>
          <label htmlFor="email">Email</label>
          <input id="email" {...register("email")} />
          {errors.email && <span>{errors.email.message}</span>}
          <button type="submit">Submit</button>
        </form>
      );
    }

Professional Recommendations

Support browser autofill and auto-focus controls to speed up form completion.


Validation

Purpose

To validate user input on both the client and server sides, preventing invalid data from entering databases.

Rules

  • All user inputs must be validated against strict schemas (e.g., Zod) before being processed or sent to APIs.
  • Provide clear, contextual validation error messages next to the affected inputs.

Workflow

1.  **Define Validation Schema:** Create a Zod schema specifying field formats, length, and types.
2.  **Bind Schema to Form:** Attach the Zod schema resolver to React Hook Form.
3.  **Run Client Validation:** Validate inputs in real-time as users fill out fields.
4.  **Run Server Validation:** Re-validate the input payload on the server before processing database writes.

Best Practices

  • Check password strength, email formatting, and numeric bounds using strict schemas.
  • Sanitize inputs to prevent script injection (XSS) attacks.

Common Mistakes

  • Relying exclusively on client-side validation, which can be bypassed.
  • Writing confusing validation rules that prevent users from completing forms.

Decision Criteria

  • Public Inputs: Enforce strict validations (e.g., name lengths, domain verification).
  • Internal Settings: Basic format validations are usually sufficient.

Examples

  • Zod Validation Schema:
    const schema = z.object({
      username: z.string().min(3, "Username must be at least 3 characters").max(20),
      age: z.number().min(18, "Must be at least 18 years old"),
    });

Professional Recommendations

Share validation schemas between frontend forms and backend API routes to reduce duplication.


Authentication UI

Purpose

To design login, signup, and MFA forms that are secure, easy to use, and handle error states gracefully.

Rules

  • Store authentication tokens securely (e.g., in httpOnly cookies), never in plain localStorage.
  • Provide clear validation feedback and loading states during authentication.

Workflow

flowchart TD
    A["User Inputs Credentials"] --> B["Validate inputs locally (Zod)"]
    B --> C["Disable submit button & trigger login loading state"]
    C --> D["Call Auth API endpoint asynchronously"]
    D -- Success --> E["Redirect user to secure dashboard"]
    D -- Error --> F["Display contextual error message"]

Best Practices

  • Support single-click authentication options (e.g., Google, GitHub, passkeys) to streamline onboarding.
  • Include a secure password visibility toggle option on the login form.

Common Mistakes

  • Leaving the submit button active during login, which can lead to duplicate requests.
  • Exposing specific credentials errors (e.g., "Password incorrect" instead of "Invalid email or password").

Decision Criteria

  • High-Security Apps: Enforce Multi-Factor Authentication (MFA) redirects and secure session keys.
  • Simple Portals: Standard passwordless email links or social login options.

Examples

  • Login Card Component: A clean card using Shadcn input components, a password toggle icon, and a prominent login action button.

Professional Recommendations

Perform regular audits on authentication flows to ensure session management and login fields remain secure.


Dashboard UI

Purpose

To build SaaS dashboard layouts that organize complex data, metrics, charts, and navigations cleanly.

Rules

  • Keep essential metrics and system statuses visible at the top of the dashboard.
  • Use consistent card components and layouts to group related widgets.

Workflow

1.  **Define Layout Grid:** Establish a navigation sidebar and header controls.
2.  **Organize Elements:** Position key metrics cards at the top, charts in the middle, and detailed data lists at the bottom.
3.  **Optimize Spacing:** Balance data density with appropriate whitespace.
4.  **Set Responsive Breakpoints:** Collapse layouts into a single column on mobile viewports.

Best Practices

  • Use progressive disclosure (e.g., modal panels or tooltips) to display secondary details without cluttering the screen.
  • Provide filters and search options to let users customize the dashboard view.

Common Mistakes

  • Filling the screen with complex, colorful charts that are difficult to interpret.
  • Hiding primary controls and settings inside sub-menus.

Decision Criteria

  • Operational Dashboard: Prioritize high information density, real-time updates, and quick navigation actions.
  • Analytical Dashboard: Focus on chart space, history filtering, and data export tools.

Examples

  • Dashboard Metric Card:
    [ Monthly Active Users ]  <- Metric Label
    [ 42,912 ]                <- Metric Value
    [ +12.4% vs last month ]  <- Trend Indicator (Green Text)

Professional Recommendations

Interview dashboard users to identify their top 3 daily questions, and design the default layout to answer them instantly.


Landing Page UI

Purpose

To build landing pages that convey value, load quickly, and guide visitors toward conversion.

Rules

  • Position the primary value proposition and conversion action above the fold.
  • Optimize images and styles to ensure fast page loads.

Workflow

flowchart TD
    Hero["1. Hero: Headline, Subheading, and Primary CTA"] --> Proof["2. Social Proof: Customer Logos / Testimonials"]
    Proof --> Features["3. Value Grid: Product Features & Interactive Previews"]
    Features --> Pricing["4. Plans Grid: Transparent Tiers & FAQ"]
    Pricing --> FooterCTA["5. Final Action Panel: CTA to convert"]

Best Practices

  • Focus on showing the product in action through high-fidelity screenshots, animations, or interactive previews.
  • Use a single, consistent CTA style throughout the page to build familiarity.

Common Mistakes

  • Overwhelming visitors with dense text blocks above the fold.
  • Using slow, heavy graphics that increase page load times.

Decision Criteria

  • Developer Tools Landing Page: Highlight live code blocks, CLI install commands, and deep technical specs.
  • Consumer SaaS Landing Page: Use warm color palettes, highlight personal benefits, and display customer success stories.

Examples

  • Hero Section Grid: A two-column desktop hero section featuring a bold value proposition on the left and an interactive product preview on the right.

Professional Recommendations

Design landing pages with performance budgets in mind to minimize Edge hosting and mobile load times.


Portfolio UI

Purpose

To build portfolio websites that showcase work, highlight capabilities, and invite contact from clients or employers.

Rules

  • Keep the design clean to let your work remain the primary focus.
  • Show process screenshots and project walkthroughs instead of just final designs.

Workflow

flowchart TD
    A["Hero Section: Introduction & Role"] --> B["Selected Works Grid: Cases study previews"]
    B --> C["About Section: Background & Technical Skill List"]
    C --> D["Contact: Simple form or email link"]

Best Practices

  • Write case studies that explain the problem, your design process, and the project results.
  • Add smooth transitions on image hover to make the portfolio feel premium.

Common Mistakes

  • Using complex layouts that compete with the project imagery.
  • Failing to include clear ways for clients to get in touch.

Decision Criteria

  • UX Designer Portfolio: Focus on process diagrams, wireframes, and user research case studies.
  • Motion Designer Portfolio: Focus on video reels, interactive scroll effects, and hover transitions.

Examples

  • Case Study Layout:
    [ Project Title & Role ]
    [ Problem Statement ]
    [ Solution Preview Image ]
    [ Design Process: Sketches -> Wireframes -> Visuals ]
    [ Results & Metrics ]

Professional Recommendations

Keep portfolio case studies easy to scan by using bold headers, bullet lists, and process imagery.


SaaS UI

Purpose

To build SaaS product user interfaces, focusing on user onboarding, billing settings, and project settings pages.

Rules

  • Keep user onboarding flows simple and guide users step-by-step.
  • Ensure billing settings and invoices are easy to find and access.

Workflow

flowchart TD
    A["User Onboarding Wizard"] --> B["Project creation/workspace setup"]
    B --> C["Main dashboard features"]
    C --> D["Billing and account settings configurations"]

Best Practices

  • Use progress bars during onboarding steps to keep the user informed.
  • Implement clear billing summary cards with payment change triggers.

Common Mistakes

  • Requiring complex configurations before users can see value in the app.
  • Failing to show error diagnostics during payment setups.

Decision Criteria

  • Enterprise SaaS: Group controls by departments and teams, and provide access roles settings.
  • Developer SaaS: Focus on simple workspace lists, usage metric counters, and API key management.

Examples

  • Billing Card Layout: A card component displaying plan details, billing dates, and a "Change Plan" action button.

Professional Recommendations

Collect user feedback on onboarding steps to identify and resolve drop-off points.


AI Product UI

Purpose

To build user interfaces for AI products, handling latency, prompt inputs, and variable outcomes.

Rules

  • Display clear loading indicators and status messages during long AI operations.
  • Always provide ways for users to edit, copy, or regenerate AI-generated content.

Workflow

1.  **Design Input Shell:** Create simple inputs or chat bars.
2.  **Plan Loading States:** Design customized skeleton screens and progress messages.
3.  **Format Outputs:** Display AI content in clear, editable boxes.
4.  **Provide Feedback Actions:** Include thumbs up/down icons or copy buttons.

Best Practices

  • Explain AI parameters in plain language (e.g., use "Creativity" instead of "Temperature").
  • Display partial AI results as they generate to make the system feel faster.

Common Mistakes

  • Failing to explain why the AI generated a specific output.
  • Leaving the screen static and quiet during long AI calculations.

Decision Criteria

  • Conversational AI: Focus on simple input bars, chat histories, and formatting tools.
  • AI Utility Tool: Integrate AI options directly into existing layout patterns.

Examples

  • AI Input Bar: A centered desktop chat input featuring clean icons to upload files, select prompt templates, and submit commands.

Professional Recommendations

Design clear onboarding guides to teach users how to write effective prompts.


Animation Guidelines

Purpose

To design UI animations and transitions that guide attention, reinforce actions, and make the application feel polished.

Rules

  • Animations must be functional and help the user complete tasks; never add decorative animations that delay workflows.
  • Always use CSS hardware-accelerated properties (transform, opacity) for smooth rendering.

Workflow

flowchart TD
    A["Identify Interactive Trigger"] --> B["Determine Motion Scale (Micro, Page, Modal)"]
    B --> C["Set cubic-bezier Easings curve"]
    C --> D["Verify Motion finishes within 300ms"]
    D --> E["Respect prefers-reduced-motion media settings"]

Best Practices

  • Keep animation times fast: micro-interactions (e.g., hover fades) should complete in 100ms-150ms, large transitions (e.g., modal entries) in 200ms-300ms.
  • Respect system accessibility options by disabling animations for users who enable prefers-reduced-motion settings.

Common Mistakes

  • Using slow, heavy transitions that delay page interactions.
  • Animating layout-breaking properties (e.g., height, width, top) that trigger expensive page recalculations.

Decision Criteria

  • Interactive Buttons: Small, fast hover scales (scale(1.02)) and background color transitions.
  • Page Transitions: Slide or fade animations to introduce new page content cleanly.

Examples

  • Transition CSS:
    .hover-card {
      transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    }
    .hover-card:hover {
      transform: translateY(-4px);
      box-shadow: var(--shadow-premium);
    }

Professional Recommendations

Verify animations run at a smooth 60fps across low-end mobile devices before launch.


GSAP Workflow

Purpose

To plan complex, scroll-linked, or multi-step animations using GreenSock Animation Platform (GSAP), ensuring high performance.

Rules

  • Always clean up and kill GSAP animation timelines on component unmount to prevent memory leaks.
  • Keep scroll animations hardware-accelerated to prevent page rendering lags.

Workflow

flowchart TD
    A["Extract DOM element references"] --> B["Build GSAP timeline container"]
    B --> C["Configure ease (power4.out) and duration parameters"]
    C --> D["Inject scrollTrigger configurations"]
    D --> E["Add cleanup triggers on component teardown"]

Best Practices

  • Use GSAP timelines to sequence multi-step animations, which keeps animations organized and readable.
  • Set relative offsets in GSAP timelines to overlap animation steps cleanly.

Common Mistakes

  • Creating multiple conflicting scroll triggers on the same element, which causes performance issues.
  • Animating layout-breaking properties (e.g., margin, padding) instead of x, y, scale, and rotation.

Decision Criteria

  • Sequential page entry reveal: Use GSAP timeline staging with subtle stagger offsets.
  • Scroll-linked element movement: Use GSAP ScrollTrigger with scrub configurations enabled.

Examples

  • GSAP Timeline Setup:
    import { gsap } from 'gsap';
    
    const tl = gsap.timeline({ defaults: { ease: 'power3.out', duration: 0.5 } });
    tl.from(heroRef.current, { opacity: 0, y: 30 })
      .from(buttonRef.current, { opacity: 0, scale: 0.95 }, '-=0.3');

Professional Recommendations

Load GSAP plugins dynamically to avoid bloat in your initial page load bundle.


Framer Motion Workflow

Purpose

To plan and structure animations in React applications using Framer Motion, enabling declarative, high-performance transitions.

Rules

  • Keep layouts simple: Use Framer Motion's layout prop to animate layout changes automatically.
  • Keep animation parameters clean by using variants instead of inline styling objects.

Workflow

1.  **Select Target Component:** Convert standard tags to motion tags (e.g., `motion.div`).
2.  **Define Motion Variants:** Set initial, animate, and exit states.
3.  **Select Easing: Use spring physics instead of duration curves for UI cards and menus.**
4.  **Wrap Layout Transitions:** Wrap lists in `AnimatePresence` to animate items as they are added or removed.

Best Practices

  • Use the AnimatePresence component to animate elements as they enter and exit the DOM.
  • Use spring settings (stiffness: 300, damping: 30) to build physics-based, premium feel transitions.

Common Mistakes

  • Using complex inline animations that clutter the component code.
  • Overusing exit animations, which can slow down page updates.

Decision Criteria

  • Tactile popup panels: Use spring physics configurations to build realistic UI transitions.
  • Fade transitions: Use simple duration curves (duration: 0.2, ease: "easeOut").

Examples

  • Framer Motion Component:
    const cardVariants = {
      hidden: { opacity: 0, y: 15 },
      visible: { opacity: 1, y: 0, transition: { type: 'spring', stiffness: 200 } }
    };
    
    return <motion.div variants={cardVariants} initial="hidden" animate="visible" />;

Professional Recommendations

Group animation variants into a dedicated settings file to keep your component directory clean.


React Three Fiber Workflow

Purpose

To integrate 3D scenes and assets into web layouts using React Three Fiber (R3F), balancing visual details with performance.

Rules

  • Keep device pixel ratios capped at a maximum of 2 (dpr={[1, 2]}) to prevent lags on high-resolution screens.
  • Clean up all WebGL textures and geometries when components unmount to prevent GPU memory leaks.

Workflow

flowchart TD
    A["Initialize R3F Canvas Container"] --> B["Configure lighting maps & static baked textures"]
    B --> C["Merge scene geometries to minimize draw calls"]
    C --> D["Set camera parameters and frustum culling boundaries"]
    D --> E["Dispose of assets on component unmount"]

Best Practices

  • Bake scene lighting and shadows inside Blender to use high-performance unlit materials (MeshBasicMaterial) in WebGL.
  • Enable frustum culling to skip rendering meshes that are currently outside the camera viewport.

Common Mistakes

  • Using large, uncompressed texture files that increase page load times.
  • Loading multiple dynamic lights, which increases GPU draw calls and causes lag.

Decision Criteria

  • Interactive 3D Elements: Use R3F canvases with light interaction triggers.
  • Static Backgrounds: Replace dynamic WebGL scenes with lightweight pre-rendered animations or videos.

Examples

  • R3F Canvas Configuration:
    import { Canvas } from '@react-three/fiber';
    
    export function ModelCanvas() {
      return (
        <Canvas dpr={[1, 2]} camera={{ position: [0, 0, 5], fov: 45 }}>
          <ambientLight intensity={0.5} />
          <mesh castShadow receiveShadow>
            <boxGeometry args={[1, 1, 1]} />
            <meshBasicMaterial color="royalblue" />
          </mesh>
        </Canvas>
      );
    }

Professional Recommendations

Use texture compression tools (e.g., KTX2) to keep 3D asset file sizes optimized.


Performance Optimization

Purpose

To monitor and optimize page execution, assets, and styling code to minimize Time to First Byte (TTFB) and improve Core Web Vitals.

Rules

  • Enforce strict performance budgets: the initial JS bundle size must not exceed 100KB gzipped.
  • Ensure all custom fonts and layout elements include styling properties to prevent layout shifts.

Workflow

flowchart TD
    A["Draft Layout Code Completed"] --> B["Verify Core Web Vitals target boundaries"]
    B --> C["Perform Bundle analysis to identify bloated dependencies"]
    C --> D["Apply Code Splitting and Image compressions"]
    D --> E["Test performance using Lighthouse audits"]

Best Practices

  • Load dynamic page segments using code splitting (next/dynamic or React.lazy).
  • Set explicit dimensions (width and height) on all image files to prevent layout shifts during page loading.

Common Mistakes

  • Importing heavy third-party packages when simpler, lightweight alternatives are available.
  • Using uncompressed assets for hero section backgrounds.

Decision Criteria

  • High-Traffic Public Pages: Prioritize static site generation (SSG) and edge caching.
  • Internal SaaS Portals: Prioritize data virtualization, query caching, and dynamic imports.

Examples

  • Performance Settings: Setting exact size parameters on an image wrapper:
    <img src="/hero.webp" width="800" height="450" alt="Hero banner" class="h-auto w-full" />

Professional Recommendations

Configure build pipelines to run automated Lighthouse performance checks before launching code.


Image Optimization

Purpose

To compress, resize, and deliver images efficiently, keeping page load times fast.

Rules

  • Always use the Next.js Image component (next/image) for handling images.
  • Compress all raster images and export them in modern, web-optimized formats (e.g., WebP or AVIF).

Workflow

flowchart TD
    A["Ingest Raw Image Asset"] --> B["Select WebP/AVIF format configurations"]
    B --> C["Configure Next.js Image properties"]
    C --> D["Set width, height, and placeholder styles"]

Best Practices

  • Provide blur-up placeholders for large images to improve perceived loading speeds.
  • Set relative layouts using the sizes property to deliver appropriately sized images to different viewports.

Common Mistakes

  • Using raw, uncompressed PNG or JPEG files for background graphics.
  • Failing to define image sizes, which causes layout shifts (CLS) when images load.

Decision Criteria

  • Primary Hero Image: Load immediately with high priority (priority={true}) and relative sizing.
  • List Item Avatars: Use lazy loading with small, defined pixel dimensions.

Examples

  • Next.js Image Component:
    import Image from 'next/image';
    
    export function Banner() {
      return (
        <Image
          src="/hero.webp"
          alt="Product presentation"
          width={1200}
          height={600}
          priority
          placeholder="blur"
          blurDataURL="data:image/webp;base64,..."
        />
      );
    }

Professional Recommendations

Use automated image optimization tools to manage assets in production.


Lazy Loading

Purpose

To defer loading non-critical components, images, and heavy scripts until they are needed, keeping initial page loads fast.

Rules

  • Code split and lazy load all elements that are not immediately visible above the fold.
  • Always provide clean loading fallback interfaces for lazy loaded segments.

Workflow

1.  **Identify Non-critical Elements:** Locate heavy widgets, charts, and modals below the fold.
2.  **Apply Dynamic Import:** Wrap components using `next/dynamic` or `React.lazy`.
3.  **Define Loading Fallback:** Create simple skeleton wrappers or spinners.
4.  **Audit Initial Bundles:** Verify that lazy loading successfully reduced initial page weights.

Best Practices

  • Use Intersection Observer hooks to load scripts or assets only when they scroll into view.
  • Lazy load third-party analytics and chat widgets to prevent them from blocking page loading.

Common Mistakes

  • Lazy loading critical components that are visible immediately above the fold, which delays rendering.
  • Failing to use code-splitting for heavy dependencies (e.g., charts, calendars).

Decision Criteria

  • Dashboard Chart Widgets: Lazy load with a skeleton placeholder until the widget scrolls into view.
  • Hero Content: Load synchronously to keep the page's Largest Contentful Paint (LCP) fast.

Examples

  • Dynamic Import:
    import dynamic from 'next/dynamic';
    
    const HeavyChart = dynamic(() => import('@/components/HeavyChart'), {
      loading: () => <div className="h-64 animate-pulse bg-neutral-800" />,
      ssr: false,
    });

Professional Recommendations

Audit layout entry bundles using webpack bundle analyzers to verify code-splitting configurations.


Code Splitting

Purpose

To split application code into smaller packages, allowing browsers to download only the scripts required for the active page.

Rules

  • Configure router layouts to support automatic code splitting per route.
  • Keep reusable library modules split from the primary entry package bundle.

Workflow

flowchart TD
    A["Parse Application Entry Point"] --> B["Separate Route Packages automatically"]
    B --> C["Split large third-party modules into shared bundles"]
    C --> D["Load dynamic imports on client action"]

Best Practices

  • Share utility functions and styles across layout modules to avoid duplicate code downloads.
  • Defer loading heavy features (e.g., invoice generation pdf scripts) until the user requests them.

Common Mistakes

  • Allowing a single heavy package to be bundled into the main entry script, slowing down all pages.
  • Over-splitting small modules, which increases browser request overhead.

Decision Criteria

  • High-Traffic Landing Page: Keep initial scripts minimal by code-splitting all interactive forms.
  • Large Admin Console: Use code-splitting to isolate pages and settings tabs.

Examples

  • Client Component Split: Dynamic loading triggered on user action:
    const onClick = async () => {
      const { formatData } = await import('@/utils/formatter');
      console.log(formatData(data));
    };

Professional Recommendations

Verify bundler configurations periodically to ensure code-splitting remains optimized as dependencies grow.


Bundle Optimization

Purpose

To analyze and optimize bundle weights, ensuring code packages remain small and download fast.

Rules

  • Ensure all imported libraries support tree-shaking to automatically exclude unused code.
  • Remove debug code, console logs, and unused exports from production builds.

Workflow

flowchart TD
    A["Run Production Build"] --> B["Generate Bundle Analysis Map"]
    B --> C["Locate bloated dependency packages"]
    C --> D["Replace heavy libraries with lightweight alternatives"]

Best Practices

  • Analyze bundle profiles using tools like @next/bundle-analyzer to spot performance bottlenecks.
  • Use native browser alternatives for common utility libraries (e.g., use ES6 array methods instead of Lodash).

Common Mistakes

  • Importing entire library packages when only a few helper functions are needed.
  • Leaving duplicate helper scripts across different parts of the application.

Decision Criteria

  • Production Release: Analyze bundle sizes to ensure they meet your performance budgets.
  • Local Prototyping: Monitor script sizes to keep builds optimized from the start.

Examples

  • Tree-Shaking Import: Import only the required icons instead of the entire package:
    // Correct
    import { ShieldAlert } from 'lucide-react';
    
    // Avoid
    import * as Icons from 'lucide-react';

Professional Recommendations

Set automated checks to block builds if bundle sizes exceed defined limits.


Error Boundaries

Purpose

To catch runtime exceptions in components, preventing page crashes and displaying user-friendly fallback interfaces.

Rules

  • Wrap all dynamic component trees and data widgets inside React Error Boundaries.
  • Never display raw database errors or stack traces to end users.

Workflow

flowchart TD
    A["Component Exception Thrown"] --> B["Error Boundary catches crash"]
    B --> C["Log error details to telemetry platform"]
    C --> D["Render user-friendly fallback card with retry option"]

Best Practices

  • Use custom error boundary components to handle UI failures gracefully.
  • Provide a clear "Retry" button to let users attempt to reload failed components without refreshing the entire page.

Common Mistakes

  • Leaving the entire app vulnerable to crashes by failing to define root error boundaries.
  • Failing to log error diagnostics, which makes debugging difficult.

Decision Criteria

  • Data Dashboard widgets: Wrap each widget in its own error boundary to keep the rest of the dashboard functional if one widget fails.
  • Critical Auth Pages: Use page-level error boundaries with redirects.

Examples

  • React Error Boundary:
    'use client';
    import { Component, ErrorInfo, ReactNode } from 'react';
    
    interface Props { children: ReactNode; fallback: ReactNode; }
    interface State { hasError: boolean; }
    
    export class ErrorBoundary extends Component<Props, State> {
      public state: State = { hasError: false };
      
      public static getDerivedStateFromError(): State {
        return { hasError: true };
      }
      
      public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
        console.error("Uncaught error:", error, errorInfo);
      }
      
      public render() {
        if (this.state.hasError) return this.fallback;
        return this.children;
      }
    }

Professional Recommendations

Configure error boundaries to send error alerts directly to your telemetry platform.


Loading States

Purpose

To display loading indicators during data updates, keeping users informed and the interface responsive.

Rules

  • Match the loading style to the wait time (e.g., use spinners for short checks, skeletons for page loads).
  • Disable submit buttons during active loading operations to prevent duplicate requests.

Workflow

flowchart TD
    A["Trigger Data Request"] --> B{"Wait < 1s?"}
    B -- Yes --> C["Display subtle circular inline spinner"]
    B -- No --> D{"Wait 1s - 3s?"}
    D -- Yes --> E["Display page skeleton loader"]
    D -- No --> F["Display progress bar with text description"]

Best Practices

  • Disable input fields and controls during active loading states to prevent input conflicts.
  • Keep loading indicators centered and sized to match their context.

Common Mistakes

  • Leaving the screen static and quiet during data loads, which can make the app look frozen.
  • Using heavy, complex loading animations that slow down the page.

Decision Criteria

  • Button Actions: Display a loading spinner inside the button.
  • New Page Route Renders: Display a skeleton screen matching the incoming page layout.

Examples

  • Button Spinner: An action button that displays a spinner and enters a disabled state during click events.

Professional Recommendations

Configure loading states with a 300ms delay to prevent visual flashing on fast queries.


Skeleton UI

Purpose

To render placeholder layouts that represent content blocks while data loads, improving perceived page speed.

Rules

  • Skeleton placeholders must match the exact dimensions and structures of the components they represent.
  • Apply a subtle shimmer animation to skeletons to indicate active loading.

Workflow

flowchart TD
    A["Extract Target Component Layout"] --> B["Create silhouette placeholder elements"]
    B --> C["Apply neutral grey background shades"]
    C --> D["Inject shimmer translation animations"]
    D --> E["Replace skeletons once API returns data"]

Best Practices

  • Use simple grey shapes to represent avatars, text blocks, and charts.
  • Maintain consistent layouts during the transition from skeleton placeholders to active data views.

Common Mistakes

  • Using dark or high-contrast skeleton shapes that look cluttered.
  • Creating skeletons that do not match the incoming content structure.

Decision Criteria

  • Dashboard Load: Use skeletons to represent cards, tables, and charts.
  • Inline Text Update: Use a simple inline shimmer block.

Examples

  • Skeleton Component:
    export function CardSkeleton() {
      return (
        <div className="w-full rounded-xl bg-neutral-900 p-6 animate-pulse">
          <div className="h-6 w-2/3 rounded bg-neutral-800 mb-4" />
          <div className="h-20 w-full rounded bg-neutral-800 mb-4" />
          <div className="h-10 w-1/3 rounded bg-neutral-800" />
        </div>
      );
    }

Professional Recommendations

Set skeleton templates globally in your design system to make them easy to reuse.


Empty States

Purpose

To display helpful empty states when no data is available, guiding users on what action to take next.

Rules

  • Every empty state must explain the cause of the state and include a primary action button.
  • Match empty state illustrations to the style of the application.

Workflow

1.  **Draft Empty State Layout:** Center content vertically and horizontally.
2.  **Add Illustration:** Position a simple, desaturated icon or illustration at the top.
3.  **Write Title & Subtitle:** Explain why the screen is empty (e.g., "No Invoices Found").
4.  **Insert CTA Button:** Include a primary action button (e.g., "Create Invoice").

Best Practices

  • Use empty states as onboarding opportunities to teach users how to start using the feature.
  • Keep empty state copy friendly, clear, and reassuring.

Common Mistakes

  • Showing blank white screens with no explanation or options when data is missing.
  • Using generic, confusing error codes instead of helpful messages.

Decision Criteria

  • First-time empty screen: Emphasize guides, templates, and primary action buttons.
  • Search results empty screen: Explain that no matches were found and suggest alternative keywords.

Examples

  • Standard Empty State:
    [ Simple Folder Icon ]
    [ No files uploaded yet ]     <- Title
    [ Upload a file to get started ] <- Subtitle
    [ Upload File CTA Button ]

Professional Recommendations

Pre-populate empty states with sample data or templates to help users learn the tool quickly.


Error States

Purpose

To design error pages and indicators that alert users to problems and help them troubleshoot issues.

Rules

  • Never use technical jargon, database errors, or raw code logs in user-facing error messages.
  • Always provide clear troubleshooting steps or a primary fallback action.

Workflow

1.  **Analyze the Error:** What broke? (e.g., network timeout, missing resource, invalid input).
2.  **Mask Technical Details:** Translate the issue into a plain-language explanation.
3.  **Add Helper Action:** Provide a refresh button, input fix suggestion, or link back home.
4.  **Configure Visual Styles:** Highlight input errors in red and page-level errors in clean layouts.

Best Practices

  • Position input error messages immediately below the invalid input field.
  • Highlight invalid fields with red borders (border-color: var(--color-error)) to make them stand out.

Common Mistakes

  • Displaying raw code logs that expose database details or API credentials.
  • Failing to provide clear ways for the user to recover from the error.

Decision Criteria

  • Input Validation Error: Highlight the field, show an warning icon, and write a clear fix description.
  • System/Server Error: Show a clean fallback page with a retry button.

Examples

  • Input Error Layout:
    [ Label: Password ]
    [ Input Field: text box with red border ]
    [ Error Message: "Password must be at least 8 characters long" (Red Text) ]

Professional Recommendations

Log raw errors internally to your telemetry tools, and display only user-friendly fallback messages to the frontend client.


Theme System

Purpose

To build a design-token-driven theme system, supporting seamless switching between light and dark modes.

Rules

  • Manage all theme styles using semantic CSS variables, never hardcoded inline styling configurations.
  • Ensure all theme variations satisfy WCAG 2.2 color contrast requirements.

Workflow

flowchart TD
    A["Establish Global Theme Context"] --> B["Map Light Theme CSS Variables"]
    B --> C["Map Dark Theme CSS Variables"]
    C --> D["Enforce classes using Tailwind variant controls (dark:...)"]

Best Practices

  • Use the next-themes library to manage theme preferences, preventing visual flashing on initial page load.
  • Ensure custom layouts, borders, and input fields adapt automatically when themes change.

Common Mistakes

  • Hardcoding colors that don't adapt when users change their theme.
  • Using highly saturated colors in dark themes, which causes eye strain.

Decision Criteria

  • Multi-Theme SaaS: Enforce a strict semantic variable system to support multiple color profiles.
  • Static Single-Theme Site: Simple Tailwind base classes are usually sufficient.

Examples

  • Theme Variables:
    :root {
      --background: 0 0% 100%;
      --foreground: 222.2 47.4% 11.2%;
    }
    .dark {
      --background: 222.2 84% 4.9%;
      --foreground: 210 40% 98%;
    }

Professional Recommendations

Audit theme transitions on low-end devices to ensure rendering remains fast and smooth.


Dark Mode

Purpose

To design dark mode interfaces that improve legibility, reduce eye strain, and look premium.

Rules

  • Avoid pure black background canvases (#000000) for main areas; use deep grays or slate tones (e.g., #0a0a0a) instead.
  • Mute white text slightly (e.g., to #e5e5e5) to prevent high-contrast glow effects that make text hard to read.

Workflow

1.  **Set Dark Canvas Base:** Map deep slate/gray colors to background variables.
2.  **Define Card Backgrounds:** Set slightly lighter shades for components to create visual depth.
3.  **Adjust Text Colors:** Use soft, off-white text to reduce contrast glare.
4.  **Polish Component Borders:** Use low-opacity white borders (`rgba(255,255,255,0.08)`) to separate sections.

Best Practices

  • Use thin borders and transparent backdrops to create depth in dark themes.
  • Mute saturated brand colors to keep them readable over dark backdrops.

Common Mistakes

  • Using high-contrast, pure black backgrounds with pure white text.
  • Failing to adjust icons and illustrations to fit dark backgrounds.

Decision Criteria

  • Developer Tools / Code Editors: Prioritize dark mode layouts by default.
  • Corporate Informational Sites: Support light mode by default with dark mode as a toggle preference.

Examples

  • Tailwind Dark Mode Card:
    <div class="bg-white border-neutral-200 dark:bg-neutral-900 dark:border-neutral-800 border rounded-lg p-6">
      <h3 class="text-neutral-900 dark:text-neutral-100">Dark Mode Component</h3>
    </div>

Professional Recommendations

Verify dark mode layouts under dim ambient lighting to confirm contrast remains comfortable.


Light Mode

Purpose

To design light mode interfaces that are clean, professional, and provide high legibility under bright lighting.

Rules

  • Avoid pure white backgrounds (#ffffff) for large panels; use soft, off-whites or light grays to reduce glare.
  • Ensure text contrast remains high, even for smaller font sizes.

Workflow

1.  **Set Light Canvas Base:** Map soft white/gray colors to background variables.
2.  **Define Component Backgrounds:** Use pure white for card elements to create depth.
3.  **Adjust Text Colors:** Use deep grays/charcoal colors for body copy.
4.  **Set Borders:** Use low-contrast gray separators (`rgba(0,0,0,0.06)`).

Best Practices

  • Use soft drop shadows (box-shadow: 0 4px 12px rgba(0,0,0,0.05)) instead of heavy borders to separate components.
  • Ensure light-colored text (e.g., captions) remains readable against light backgrounds.

Common Mistakes

  • Using low-contrast gray text on light backgrounds, which makes reading difficult.
  • Creating harsh interfaces with too many bright colors.

Decision Criteria

  • E-commerce / Editorial Portals: Prioritize light mode by default.
  • Workspace Dashboards: Support both themes, allowing users to toggle preferences.

Examples

  • Light Mode Card Layout: A card using soft white backing, subtle drop shadows, and charcoal-colored text headers.

Professional Recommendations

Audit light mode layouts under direct sunlight to ensure text and buttons remain clearly legible.


API Integration

Purpose

To fetch data from backend services asynchronously, manage client cache states, and handle requests.

Rules

  • All remote API calls must be managed using TanStack Query to support caching, background syncs, and retry policies.
  • Ensure all API data payloads are validated against strict Zod schemas upon retrieval.

Workflow

flowchart TD
    A["Trigger API Request"] --> B["Fetch data payload asynchronously"]
    B --> C["Validate payload structure against Zod schema"]
    C -- Success --> D["Cache data and update UI components"]
    C -- Error --> E["Trigger validation boundary error fallbacks"]

Best Practices

  • Isolate API calls inside custom hooks (e.g., useInvoices) to keep page components clean.
  • Implement rate-limiting and retry backoff settings on API client configurations.

Common Mistakes

  • Placing raw fetch queries directly inside page components.
  • Failing to validate API data payloads, which can cause runtime exceptions when properties are missing.

Decision Criteria

  • Server-Synced Data: TanStack Query custom hooks.
  • Dynamic Submissions: React Hook Form handlers mapped to API endpoints.

Examples

  • TanStack Query Integration:
    import { useQuery } from '@tanstack/react-query';
    import * as z from 'zod';
    
    const UserSchema = z.object({ id: z.string(), name: z.string() });
    
    async function fetchUser(id: string) {
      const res = await fetch(`/api/users/${id}`);
      const data = await res.json();
      return UserSchema.parse(data);
    }
    
    export function useUser(id: string) {
      return useQuery({
        queryKey: ['user', id],
        queryFn: () => fetchUser(id),
      });
    }

Professional Recommendations

Configure API clients to handle network timeouts and token refreshes automatically.


Environment Variables

Purpose

To store configuration settings (API URLs, keys, environments) outside the codebase, keeping credentials secure.

Rules

  • Never commit private keys, API secrets, or environment variable files (.env) to git repositories.
  • Validate all environment variables at startup using a strict schema (e.g., Zod).

Workflow

1.  **Define Configuration Schema:** Create a Zod schema specifying required environment variables.
2.  **Verify Variables on Startup:** Validate configurations during app build and startup processes.
3.  **Access Variables securely:** Use the Zod configuration object instead of referencing `process.env` directly.

Best Practices

  • Prefix frontend-accessible variables with NEXT_PUBLIC_ so the Next.js builder knows to bundle them.
  • Provide a template configuration file (.env.example) showing required setup keys.

Common Mistakes

  • Exposing private backend API keys to the browser by using the NEXT_PUBLIC_ prefix incorrectly.
  • Letting missing environment variables cause runtime failures in production.

Decision Criteria

  • Client-side Configs: Use variables prefixed with NEXT_PUBLIC_.
  • Backend Actions: Use standard non-prefixed variables to keep keys secure on the server.

Examples

  • Configuration Validation:
    import * as z from 'zod';
    
    const envSchema = z.object({
      NEXT_PUBLIC_API_URL: z.string().url(),
    });
    
    export const env = envSchema.parse({
      NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
    });

Professional Recommendations

Store environment variables in secure cloud platforms (e.g., Doppler, Vercel secrets) for deployment.


Debugging

Purpose

To identify, trace, and resolve code defects, performance lags, and layout bugs within the application.

Rules

  • Do not commit temporary print logs (console.log) or debug breakpoints to production branches.
  • Use structured debugger tools and diagnostic platforms to analyze complex failures.

Workflow

flowchart TD
    A["Identify Failure Point"] --> B["Check browser console errors & stack trace logs"]
    B --> C["Reproduce issue locally under test configurations"]
    C --> D["Set debugger breakpoints or inspect state stores"]
    D --> E["Implement fix and run Vitest suites to confirm"]

Best Practices

  • Inspect styling and layout bugs using browser element inspector panels.
  • Monitor state changes and event logs using Redux DevTools or Zustand debugger extensions.

Common Mistakes

  • Committing temporary console messages that clutter production logs.
  • Attempting to fix complex issues without identifying the root cause.

Decision Criteria

  • Layout Bug: Use browser element inspectors and grid visualizers.
  • State / Logic Bug: Set breakpoints and trace execution steps in source files.

Examples

  • Diagnostic Log: Using clean, structured logging configurations to debug inputs:
    if (process.env.NODE_ENV !== 'production') {
      console.debug("[Auth] Starting authentication flow for user:", userId);
    }

Professional Recommendations

Configure source maps in development builds to trace errors back to original files.


Code Review

Purpose

To review frontend changes before merging, ensuring code quality, security, accessibility, and performance.

Rules

  • All PRs must be reviewed and approved by at least two frontend developers before merging.
  • Ensure all automated linting, type checks, and testing suites pass before request review.

Workflow

flowchart TD
    A["PR Created"] --> B["CI Pipeline runs ESLint, Vitest, & Playwright tests"]
    B --> C["Peer review checks component structure, Types, and accessibility"]
    C --> D["Resolve feedback and update code segments"]
    D --> E["Merge branch upon final sign-off approval"]

Best Practices

  • Keep PRs small and focused on a single feature or fix to make reviews easier.
  • Provide a clear PR description explaining what changed and how to verify the modifications.

Common Mistakes

  • Approving PRs without verifying that the changes work correctly in preview environments.
  • Merging large, complex PRs containing unrelated formatting updates.

Decision Criteria

  • Major Component Updates: Review spacing grids, state stores, and bundle impacts.
  • Minor Copy Fixes: Simple, fast approval checks.

Examples

  • Code Review Checklist: Verify that all image components use Next.js Image optimization properties.

Professional Recommendations

Use automated pull request templates to ensure reviewers have all the context they need.


Testing

Purpose

To run unit, integration, and E2E automation suites to verify application logic remains correct as code changes.

Rules

  • Keep test coverage high for critical business logic, forms, and utilities.
  • Do not launch features without verifying they pass Vitest and Playwright test runs.

Workflow

flowchart TD
    A["Write Feature Code"] --> B["Write Vitest components / utility tests"]
    B --> C["Write Playwright automated E2E browser flows"]
    C --> D["Run tests locally using dev commands"]
    D --> E["Run tests in CI deployment pipelines"]

Best Practices

  • Use Vitest and React Testing Library to test component interactions and render results quickly.
  • Use Playwright to test critical user journeys (e.g., checkout flows, logins) across multiple browsers.

Common Mistakes

  • Writing tests that rely on unstable CSS selectors, which makes tests break easily.
  • Testing implementation details instead of focusing on user behaviors.

Decision Criteria

  • Pure Utilities / React Hooks: Write lightweight Vitest unit tests.
  • Complex User Journeys: Write robust Playwright E2E browser automation scripts.

Examples

  • Vitest Component Test:
    import { render, screen } from '@testing-library/react';
    import { expect, test } from 'vitest';
    import { UserAvatar } from './UserAvatar';
    
    test('renders user profile details correctly', () => {
      render(<UserAvatar imageUrl="/avatar.png" username="Jane Doe" />);
      const nameElement = screen.getByText('Jane Doe');
      expect(nameElement).toBeDefined();
    });

Professional Recommendations

Configure test runs to block commits if coverage falls below your target thresholds.


Deployment

Purpose

To build, bundle, and release applications to host platforms (e.g., Vercel), ensuring zero downtime.

Rules

  • Keep deployments automated using version-controlled configuration manifests.
  • Never deploy code that contains failing tests, lint errors, or uncommitted files.

Workflow

flowchart TD
    A["Merge code branch to main"] --> B["Trigger build pipeline (ESLint, Types, Tests)"]
    B --> C["Generate optimized production bundle assets"]
    C --> D["Deploy build assets to Edge networks"]
    D --> E["Run automated live health checks"]

Best Practices

  • Deploy staging builds to preview URLs for testing before updating production environments.
  • Use modern edge caching configurations to minimize page latency.

Common Mistakes

  • Deploying directly from developer machines without passing through a CI build pipeline.
  • Failing to verify that API keys and environment variables are active on production hosts.

Decision Criteria

  • Production Deployment: Full build execution, asset compilation, and automated test runs.
  • Preview Deployment: Rapid staging builds to test visual edits.

Examples

  • Vercel Config: Defining serverless route rules inside a custom configuration manifest.

Professional Recommendations

Set up automated rollbacks in your deployment platforms to revert builds immediately if production health checks fail.


Common Mistakes

Purpose

To list common frontend engineering mistakes, helping developers write cleaner, more stable code.

Rules

  • Keep component sizes small and focused on a single task to prevent readability and maintenance issues.
  • Never use the React key prop incorrectly (e.g., using array indexes instead of unique element IDs).

Workflow

1.  **Code Review Pass:** Scan components for large, bloated structures.
2.  **Audit Key Props:** Verify that all lists map to stable, unique item IDs.
3.  **Optimize Dependencies:** Remove unused libraries and duplicate helpers.
4.  **Verify State Setup:** Keep local state localized rather than storing it in global stores.

Best Practices

  • Group list items by unique identifier properties (e.g., item.id) rather than array index keys.
  • Write clean component properties (props) to manage inputs and custom changes predictably.

Common Mistakes

  • Using key={index} in dynamic lists, which can cause rendering bugs when items are reordered.
  • Storing temporary component states in global Zustand or Redux stores.

Decision Criteria

  • List Rendering: Always map lists to unique database IDs.
  • State Management: Keep UI display states localized inside their components.

Examples

  • Bad: <li key={index}>{item.title}</li>
  • Good: <li key={item.id}>{item.title}</li>

Professional Recommendations

Use ESLint rules to identify and warn developers about common coding mistakes automatically.


Anti Patterns

Purpose

To identify and avoid frontend design and coding patterns that harm performance, maintainability, and scalability.

Rules

  • Avoid prop drilling; use state stores (Zustand) or React Context when sharing data across many components.
  • Never fetch data inside low-level atomic components; keep queries centralized in containers or pages.

Workflow

flowchart TD
    A["Scan Codebase for Anti-Patterns"] --> B["Identify deep prop drilling chains"]
    B --> C["Refactor to use Context or Zustand stores"]
    C --> D["Locate inline fetch queries inside UI atoms"]
    D --> E["Move fetch calls to page containers/Server Components"]

Best Practices

  • Use custom React hooks to isolate state logic from UI rendering blocks.
  • Wrap complex widgets in clear error boundaries to protect page layouts.

Common Mistakes

  • Drilling props through dozens of layout layers, which makes components difficult to reuse.
  • Placing raw API queries directly inside button components.

Decision Criteria

  • Deep State Sharing: Zustand stores.
  • Single Component State: Local state hooks.

Examples

  • Prop Drilling Refactoring: Moving data states to a global theme context to avoid passing props through dozens of nested headers.

Professional Recommendations

Perform regular codebase audits to identify and resolve anti-patterns.


Engineering Checklist

Purpose

To provide a final review checklist, ensuring all code meets performance, accessibility, and quality standards before release.

Rules

  • All frontend changes must pass the engineering checklist before code is deployed to production.
  • Document any checklist violations and resolve them in immediate sprint cycles.

Checklist

  • TypeScript: The codebase compiles with zero compilation errors under strict configurations.
  • Linter: ESLint returns zero warnings or formatting errors.
  • Accessibility: All pages meet WCAG 2.2 AA contrast and keyboard accessibility requirements.
  • Performance: Time to First Byte (TTFB) and page load times are within Core Web Vitals budgets.
  • Core Web Vitals: Largest Contentful Paint (LCP) $\le 1.2\text{s}$ and Cumulative Layout Shift (CLS) $\le 0.05$.
  • Bundle Sizes: Initial JavaScript bundle sizes stay under 100KB gzipped.
  • Testing: All Vitest unit tests and Playwright E2E browser automation tests pass.
  • Security: API keys are secured in environment variables, and inputs are validated using Zod.
  • Responsive Design: Layouts render cleanly without scrollbars across mobile, tablet, and desktop viewports.
  • Error Handling: Dynamic components are wrapped in Error Boundaries, and API error states are managed gracefully.

Self Review Engine

Purpose

To define a self-criticism engine that forces the AI to audit its own code and fix issues before returning code.

Rules

  • Before outputting any component or layout, analyze the draft against the 8 self-review metrics (Simplicity, Security, Performance, Accessibility, UX, Maintainability, Scalability, DX).
  • Refactor and correct any identified violations before returning the final response.

Workflow

flowchart TD
    Start["Draft Component Code Completed"] --> Q1{"Can logic be simpler?"}
    Q1 -- Yes --> R1["Refactor to remove redundant layers/states"] --> Q2
    Q1 -- No --> Q2{"Are contrast ratios WCAG 2.2 compliant?"}
    Q2 -- Yes --> R2["Adjust text color saturation/weights"] --> Q3
    Q2 -- No --> Q3{"Is typography readable?"}
    Q3 -- Yes --> R3["Increase line heights and limit line lengths"] --> Q4
    Q3 -- No --> Q4{"Is whitespace balanced?"}
    Q4 -- Yes --> R4["Apply consistent 8pt margin spacings"] --> Q5
    Q4 -- No --> Q5{"Are touch targets correct?"}
    Q5 -- Yes --> R5["Expand interactive bounding boxes to 48px"] --> End
    Q5 -- No --> End["Deliver Final Premium Design Output"]

Best Practices

  • Treat the self-review engine as a required step in the design pipeline.
  • Document and update check criteria based on feedback from users and developers.

Common Mistakes

  • Returning code drafts without passing through the self-review checks.
  • Assuming the first layout version is always optimal.

Decision Criteria

Apply the self-review engine to all UI code generation tasks.

Examples

  • Self-Review Audit: Noticing that a dark-mode card background #121212 with text #525252 lacks sufficient contrast, leading to a text adjustment to #a3a3a3 before outputting the code.

Professional Recommendations

Configure your design pipelines to run automated syntax and contrast audits.


Final Engineering Audit

Purpose

To perform a final, comprehensive engineering audit on codebases to verify they are production-ready.

Rules

  • Verify all codebase systems meet structural standards, security guidelines, and performance budgets.
  • All items in the final engineering audit checklist must be verified and checked off.

Checklist

  • HTML Structure: All layouts use semantic HTML5 tags and have logical heading hierarchies.
  • Type Safety: TypeScript is used across all files with zero any type definitions.
  • Accessibility: Contrast levels, screen-reader labels, and keyboard navigations are fully verified.
  • Performance: Code-splitting and dynamic imports are configured correctly.
  • Assets: All images and WebGL assets are compressed and optimized for web delivery.
  • State Stores: Zustand stores and React contexts are cleared on unmount.
  • Testing: Playwright E2E tests pass across Chrome, Safari, Firefox, and Edge browsers.
  • CI/CD: Automatic deployment hooks and rollbacks are operational.

References

Purpose

To list core specifications, documentation, and technical resources that govern frontend engineering standards.

Recommended References

  • Next.js Documentation: App Router routing, data fetching, rendering patterns, and deployment configurations.
  • WCAG 2.2 Quick Reference: Web Content Accessibility Guidelines definitions and checklist tests.
  • TanStack Query Quickstart: Client-side caching configurations and mutation APIs.
  • MDN Web Docs: Authoritative reference guidelines governing HTML5, CSS3, and JavaScript syntax.
  • Vitest & RTL Docs: React Component testing patterns and utilities.

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.