Back to skills
SKILL.md
Frontend Architecture System
ASecurityBuild and maintain a production-grade frontend architecture covering design tokens, component patterns (shadcn/ui), responsive design, theming, and Next.js performance optimization. This skill consolidates 7 frontend sub-skills into one comprehensive reference that @Frontend and @UIDesigner consume for every interface task.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added November 24, 2026
Works with
Security analysis
100/100Pro scans all 4 files and shows the line behind each finding
npx -y skills add iDorgham/Workspace-Factory --skill frontend_architecture_system --agent claude-codeAre you the author of Frontend Architecture System?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/idorgham-frontend-architecture-system)---
type: Skill
subagents: [core-validator, integrity-bot]
agents: [master-guide, swarm-router]
dependencies: [core-orchestration, global-sync]
version: 1.0.0
---
# Frontend Architecture & Design System
## Purpose
Build and maintain a production-grade frontend architecture covering design tokens, component patterns (shadcn/ui), responsive design, theming, and Next.js performance optimization. This skill consolidates 7 frontend sub-skills into one comprehensive reference that @Frontend and @UIDesigner consume for every interface task.
**Measurable Impact:**
- Before: 7 scattered 35-55 line files → inconsistent component patterns, duplicate styling
- After: Single architecture document → consistent output from any agent, zero style conflicts
- Before: No performance budget → 4-6s LCP, 60+ Lighthouse perf score
- After: Optimized RSC boundaries + code splitting → <2.5s LCP, 90+ Lighthouse
**Consolidates:** `tailwind`, `shadcn-mcp`, `shadcn-composable`, `tokens-design`, `responsive-design`, `nextjs-performance`, `theme-auditor`
---
## Technique 1 — Design Token System
### Token Architecture
```css
/* globals.css — Design token foundation */
@layer base {
:root {
/* === Color System (HSL) === */
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 240 5.9% 10%;
/* === Spacing Scale (rem) === */
--space-1: 0.25rem; /* 4px */
--space-2: 0.5rem; /* 8px */
--space-3: 0.75rem; /* 12px */
--space-4: 1rem; /* 16px */
--space-6: 1.5rem; /* 24px */
--space-8: 2rem; /* 32px */
--space-12: 3rem; /* 48px */
--space-16: 4rem; /* 64px */
/* === Typography === */
--font-sans: 'Inter', system-ui, sans-serif;
--font-arabic: 'Cairo', 'Tajawal', sans-serif;
--font-mono: 'JetBrains Mono', monospace;
/* === Border Radius === */
--radius: 0.5rem;
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius));
--radius-lg: calc(var(--radius) + 4px);
--radius-full: 9999px;
}
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--muted: 240 3.7% 15.9%;
--border: 240 3.7% 15.9%;
/* ... complete dark mode tokens */
}
}
/* Arabic font application */
[lang^="ar"] {
font-family: var(--font-arabic), var(--font-sans);
line-height: 1.8; /* Arabic needs more line height */
}
```
### Token Usage Rules
```markdown
## Token Contract (Never Break These)
1. NEVER use raw hex/rgb colors → always `hsl(var(--token))`
2. NEVER use raw px for spacing → always `var(--space-X)` or Tailwind scale
3. NEVER use hardcoded font stacks → always `var(--font-sans/arabic/mono)`
4. NEVER use hardcoded border-radius → always `var(--radius-X)`
5. Theme audit: `grep -rn '#[0-9a-f]\{3,8\}' src/` should return ZERO results
```
---
## Technique 2 — shadcn/ui Component Architecture
### Component Composition Pattern
```tsx
// Pattern: Extend shadcn primitives, never modify originals
// components/ui/button.tsx stays UNTOUCHED from shadcn
// components/custom/submit-button.tsx extends it:
import { Button, ButtonProps } from '@/components/ui/button';
import { Loader2 } from 'lucide-react';
interface SubmitButtonProps extends ButtonProps {
isLoading?: boolean;
loadingText?: string;
}
export function SubmitButton({
isLoading, loadingText = 'Saving...', children, disabled, ...props
}: SubmitButtonProps) {
return (
<Button disabled={disabled || isLoading} {...props}>
{isLoading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
{loadingText}
</>
) : children}
</Button>
);
}
```
### Component Organization
```markdown
## Directory Structure
components/
├── ui/ # shadcn primitives (NEVER modify directly)
│ ├── button.tsx
│ ├── dialog.tsx
│ ├── input.tsx
│ └── ...
├── custom/ # Your extensions of shadcn primitives
│ ├── submit-button.tsx
│ ├── search-input.tsx
│ └── data-table.tsx
├── layout/ # Page-level layout components
│ ├── header.tsx
│ ├── sidebar.tsx
│ └── footer.tsx
└── features/ # Feature-specific composed components
├── dashboard/
├── settings/
└── onboarding/
## Rules:
- ui/* → auto-generated by shadcn CLI, never hand-edit
- custom/* → your wrappers that compose ui/* components
- layout/* → structural components used across pages
- features/* → domain-specific components that combine multiple ui/custom
```
---
## Technique 3 — Responsive Design System
### Breakpoint Strategy
```css
/* Breakpoint tokens — mobile-first */
/* sm: 640px — Large phones landscape */
/* md: 768px — Tablets */
/* lg: 1024px — Small laptops */
/* xl: 1280px — Desktops */
/* 2xl: 1536px — Large screens */
/* Mobile-first: base styles = mobile, then override up */
.container {
padding-inline: var(--space-4); /* 16px on mobile */
}
@media (min-width: 768px) {
.container {
padding-inline: var(--space-8); /* 32px on tablet+ */
}
}
@media (min-width: 1280px) {
.container {
padding-inline: var(--space-12); /* 48px on desktop */
max-width: 1280px;
margin-inline: auto;
}
}
```
### Responsive Component Pattern
```tsx
// Hook: useMediaQuery for JS-based responsive logic (use sparingly)
'use client';
import { useState, useEffect } from 'react';
export function useMediaQuery(query: string): boolean {
const [matches, setMatches] = useState(false);
useEffect(() => {
const media = window.matchMedia(query);
setMatches(media.matches);
const listener = (e: MediaQueryListEvent) => setMatches(e.matches);
media.addEventListener('change', listener);
return () => media.removeEventListener('change', listener);
}, [query]);
return matches;
}
// Usage
const isMobile = useMediaQuery('(max-width: 768px)');
// Show drawer on mobile, sidebar on desktop
{isMobile ? <MobileDrawer /> : <DesktopSidebar />}
```
---
## Technique 4 — Next.js Performance Optimization
### Server Component Boundaries
```markdown
## RSC Boundary Rules
SERVER Component (default — prefer this):
✅ Data fetching (async/await directly in component)
✅ Database queries (Prisma, Drizzle)
✅ Accessing secrets (env vars)
✅ Heavy rendering logic
✅ Large dependencies that shouldn't ship to client
→ 0KB added to client bundle
CLIENT Component ('use client'):
✅ useState, useEffect, useRef (React hooks)
✅ Event handlers (onClick, onChange)
✅ Browser APIs (localStorage, window, navigator)
✅ Interactive libraries (Framer Motion, React Hook Form)
→ Adds to client bundle — minimize scope
## Pattern: Narrow Client Boundaries
// ❌ BAD: Entire page is client component
'use client';
export default function DashboardPage() { /* everything here */ }
// ✅ GOOD: Only interactive parts are client
export default async function DashboardPage() {
const data = await fetchData(); // Server — no client JS
return (
<div>
<StaticHeader data={data} /> {/* Server — 0KB */}
<InteractiveChart data={data} /> {/* Client — only chart JS */}
<DataTable data={data} /> {/* Server — 0KB */}
</div>
);
}
```
### Performance Checklist
```markdown
## Next.js Performance Audit
Images:
□ All images use next/image (automatic WebP, lazy loading, sizing)
□ LCP image has priority={true}
□ No layout shift from images (explicit width/height or fill + sizes)
Fonts:
□ Using next/font (self-hosted, no external request)
□ font-display: swap configured
□ Arabic font loaded only for Arabic locale (conditional)
Code splitting:
□ Dynamic imports for heavy components: dynamic(() => import('./HeavyChart'))
□ Route groups don't share unnecessary layouts
□ Third-party scripts use next/script with strategy="lazyOnload"
Data fetching:
□ Parallel data fetching where possible (Promise.all, not sequential await)
□ React.cache() for deduplicating same request in render tree
□ ISR with revalidate for semi-static pages
Bundle analysis:
□ Run: ANALYZE=true pnpm build (with @next/bundle-analyzer)
□ No client-side import of server-only libraries (moment.js, lodash full)
□ Total First Load JS < 100KB (excluding framework chunks)
```
### Theme System (Dark/Light + Custom)
```typescript
// lib/theme.ts — Theme provider with system detection
'use client';
import { ThemeProvider as NextThemesProvider } from 'next-themes';
export function ThemeProvider({ children }: { children: React.ReactNode }) {
return (
<NextThemesProvider
attribute="class" // Apply 'dark' class to <html>
defaultTheme="system" // Respect OS preference
enableSystem={true}
disableTransitionOnChange // Prevent FOUC on theme switch
storageKey="theme" // localStorage key
>
{children}
</NextThemesProvider>
);
}
// Theme audit script: find hardcoded colors
// grep -rn '#[0-9a-fA-F]\{3,8\}\|rgb\|rgba\|hsl(' src/ --include='*.tsx' --include='*.css'
// Should return ZERO results (all colors should use CSS variables)
```
---
## Anti-Pattern Catalog
| ID | Anti-Pattern | Risk | Fix |
|----|-------------|------|-----|
| FE-001 | Hardcoded hex colors in components | **HIGH** — Breaks dark mode, inconsistent | Use `hsl(var(--token))` CSS variables exclusively |
| FE-002 | Modifying shadcn ui/* files directly | **HIGH** — Breaks on shadcn updates | Extend in custom/* directory; keep ui/* pristine |
| FE-003 | Entire page marked 'use client' | **HIGH** — Ships all code to client, breaks RSC | Narrow client boundary to interactive parts only |
| FE-004 | No next/image for images | **MEDIUM** — Larger files, no lazy loading, CLS | Always use next/image with width/height or fill |
| FE-005 | Desktop-first CSS | **MEDIUM** — Mobile layouts break | Mobile-first: base = mobile, @media min-width for larger |
| FE-006 | Importing full lodash/moment | **HIGH** — 70KB+ added to client bundle | Use date-fns or native Intl; lodash-es with tree-shaking |
| FE-007 | No font preloading | **MEDIUM** — FOUT (Flash of Unstyled Text) | Use next/font with font-display: swap |
| FE-008 | Missing dark mode token for new components | **MEDIUM** — Broken dark mode for new features | Every new CSS variable needs both :root and .dark values |
## 🌍 Regional Calibration (MENA Context)
- **Cultural Alignment:** Ensure all logic respects regional business etiquette and MENA market expectations.
- **RTL Compliance:** Logic must explicitly handle Right-to-Left (RTL) flow where relevant.
## 🛡️ Critical Failure Modes (Anti-Patterns)
- **Anti-Pattern:** Generic Output -> *Correction:* Apply sector-specific professional rules from RULE.md.
- **Anti-Pattern:** Global-Only Logic -> *Correction:* Verify against MENA regional calibration.
---
## Success Criteria
- [ ] All colors use CSS custom properties — zero hardcoded hex/rgb values
- [ ] shadcn ui/ directory untouched; all customizations in custom/
- [ ] Mobile-first responsive: base = mobile, breakpoints add complexity
- [ ] Server Components by default; 'use client' only for interactive parts
- [ ] next/image used for all images with proper width/height
- [ ] next/font for Latin + Arabic fonts (self-hosted, no external CDN)
- [ ] Theme system: dark/light/system with next-themes
- [ ] Bundle < 100KB First Load JS (audited with bundle-analyzer)
- [ ] Arabic font conditionally loaded only for Arabic locale
- [ ] Lighthouse Performance score ≥ 90 on mobileFiles in this skill
- SKILL.md
- core.py
- manifest.yaml
- tests/test_core.py
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.