Frontend dev guidelines

From Dokhacgiakhoa/Agent-Skills-4-Vibe-Coding-CLI · View interactive version

Frontend dev guidelines is an AI agent skill from the GitHub repository Dokhacgiakhoa/Agent-Skills-4-Vibe-Coding-CLI. Opinionated frontend development standards for modern React + TypeScript applications. Covers Suspense-first data fetching, lazy loading, feature-based architecture, MUI v7 styling, TanStack Router, performance optimization, and strict TypeScript practices.

How to use this skill

Skill file

Frontend Development Guidelines

(React · TypeScript · Suspense-First · Production-Grade)

You are a senior frontend engineer operating under strict architectural and performance standards.

Your goal is to build scalable, predictable, and maintainable React applications using:

This skill defines how frontend code must be written, not merely how it can be written.


1. Frontend Feasibility & Complexity Index (FFCI)

Before implementing a component, page, or feature, assess feasibility.

FFCI Dimensions (1–5)

| Dimension | Question |

| --------------------- | ---------------------------------------------------------------- |

| Architectural Fit | Does this align with feature-based structure and Suspense model? |

| Complexity Load | How complex is state, data, and interaction logic? |

| Performance Risk | Does it introduce rendering, bundle, or CLS risk? |

| Reusability | Can this be reused without modification? |

| Maintenance Cost | How hard will this be to reason about in 6 months? |

Score Formula

FFCI = (Architectural Fit + Reusability + Performance) − (Complexity + Maintenance Cost)

Range: -5 → +15

Interpretation

| FFCI | Meaning | Action |

| --------- | ---------- | ----------------- |

| 10–15 | Excellent | Proceed |

| 6–9 | Acceptable | Proceed with care |

| 3–5 | Risky | Simplify or split |

| ≤ 2 | Poor | Redesign |


2. Core Architectural Doctrine (Non-Negotiable)

1. Suspense Is the Default

2. Lazy Load Anything Heavy

3. Feature-Based Organization

4. TypeScript Is Strict


3. When to Use This Skill

Use frontend-dev-guidelines when:


4. Quick Start Checklists

New Component Checklist


New Feature Checklist


5. Import Aliases (Required)

| Alias | Path |

| ------------- | ---------------- |

| @/ | src/ |

| ~types | src/types |

| ~components | src/components |

| ~features | src/features |

Aliases must be used consistently. Relative imports beyond one level are discouraged.


6. Component Standards

Required Structure Order

  1. Types / Props
  2. Hooks
  3. Derived values (useMemo)
  4. Handlers (useCallback)
  5. Render
  6. Default export

Lazy Loading Pattern

const HeavyComponent = React.lazy(() => import('./HeavyComponent'));

Always wrapped in <SuspenseLoader>.


7. Data Fetching Doctrine

Primary Pattern

Forbidden Patterns

❌ isLoading

❌ manual spinners

❌ fetch logic inside components

❌ API calls without feature API layer

API Layer Rules


8. Routing Standards (TanStack Router)

export const Route = createFileRoute('/my-route/')({
  component: MyPage,
  loader: () => ({ crumb: 'My Route' }),
});

9. Styling Standards (MUI v7)

Inline vs Separate

Grid Syntax (v7 Only)

<Grid size={{ xs: 12, md: 6 }} /> // ✅
<Grid xs={12} md={6} />          // ❌

Theme access must always be type-safe.


10. Loading & Error Handling

Absolute Rule

❌ Never return early loaders

✅ Always rely on Suspense boundaries

User Feedback


11. Performance Defaults

Performance regressions are bugs.


12. TypeScript Standards


13. Canonical File Structure

src/
  features/
    my-feature/
      api/
      components/
      hooks/
      helpers/
      types/
      index.ts

  components/
    SuspenseLoader/
    CustomAppBar/

  routes/
    my-route/
      index.tsx

14. Canonical Component Template

import React, { useState, useCallback } from 'react';
import { Box, Paper } from '@mui/material';
import { useSuspenseQuery } from '@tanstack/react-query';
import { featureApi } from '../api/featureApi';
import type { FeatureData } from '~types/feature';

interface MyComponentProps {
  id: number;
  onAction?: () => void;
}

export const MyComponent: React.FC<MyComponentProps> = ({ id, onAction }) => {
  const [state, setState] = useState('');

  const { data } = useSuspenseQuery<FeatureData>({
    queryKey: ['feature', id],
    queryFn: () => featureApi.getFeature(id),
  });

  const handleAction = useCallback(() => {
    setState('updated');
    onAction?.();
  }, [onAction]);

  return (
    <Box sx={{ p: 2 }}>
      <Paper sx={{ p: 3 }}>
        {/* Content */}
      </Paper>
    </Box>
  );
};

export default MyComponent;

15. Anti-Patterns (Immediate Rejection)

❌ Early loading returns

❌ Feature logic in components/

❌ Shared state via prop drilling instead of hooks

❌ Inline API calls

❌ Untyped responses

❌ Multiple responsibilities in one component


16. Integration With Other Skills


17. Operator Validation Checklist

Before finalizing code:


18. Skill Status

Status: Stable, opinionated, and enforceable

Intended Use: Production React codebases with long-term maintenance horizons

🧠 Knowledge Modules (Fractal Skills)

1. [common-patterns](./sub-skills/common-patterns.md)

2. [complete-examples](./sub-skills/complete-examples.md)

3. [component-patterns](./sub-skills/component-patterns.md)

4. [data-fetching](./sub-skills/data-fetching.md)

5. [file-organization](./sub-skills/file-organization.md)

6. [loading-and-error-states](./sub-skills/loading-and-error-states.md)

7. [performance](./sub-skills/performance.md)

8. [routing-guide](./sub-skills/routing-guide.md)

9. [styling-guide](./sub-skills/styling-guide.md)

10. [typescript-standards](./sub-skills/typescript-standards.md)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.