본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)8.2k · #12532

frontend-architecture

하는 일

이 스킬은 프론트엔드 코드를 파일마다 한 가지 역할만 갖도록 나누는 방법을 AI에게 보여 줍니다. React, Next, Vue 프로젝트를 다룹니다. 코드가 커져도 깔끔하게 유지하려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓React, Next, Vue 프로젝트를 새로 시작하고 깔끔한 구조가 필요할 때.
  • ✓프론트엔드 파일에 화면, 데이터 가져오기, 검증이 섞여 있을 때.
  • ✓컴포넌트 파일이 너무 커져서 역할에 따라 나누고 싶은 경우.

스킬 링크

https://github.com/vudovn/ag-kit/blob/main/.agents/skills/frontend-architecture/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/vudovn/ag-kit/blob/main/.agents/skills/frontend-architecture/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 React 앱을 정리해 주세요. API 호출, 검증, 화면 코드가 각각 다른 파일에 있도록 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 어떤 코드가 화면, 로직, 데이터, 타입 같은 어떤 계층에 속하는지 설명합니다. AI는 파일을 만들거나 바꿀 때 그 규칙을 적용합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Frontend Architecture

How to organize frontend code so it scales. Separation of concerns over file-type folders. Applies to React/Next and Vue. For directory layout, follow app-builder. For visual design, see frontend-design. For React/Next performance, see nextjs-react-expert.


1. Separation of Concerns — the core rule

Split code into four layers by responsibility. A unit of code does ONE of these, not several:

Layer Holds Lives in
UI Rendering, markup, presentational state components/
Logic State, effects, data transforms, reusable UI logic hooks/ (React) · composables/ (Vue)
Data API calls, fetch/axios, cache keys lib/ / service files (*.api.ts)
Type TypeScript types, domain models types.ts / *.types.ts
Validation Form/data schemas *.schema.ts (zod/yup/valibot)

Directory layout (top-level folders) follows the project's scaffolding skill — do not invent a competing structure here. This skill is about which layer code belongs to, not where the folders sit.


2. File Responsibility & Size

One clear responsibility per file. Size is a signal, not a hard limit — a clear 230-line file beats a 90-line file that fetches, validates, renders, and juggles modals + toasts.

File type Comfortable range
UI component 80–180 lines
Page / screen 100–220 lines
Hook / composable 40–150 lines
API service 50–200 lines
Type / schema flexible

Split a file when it mixes UI + API + business logic + validation + state. Don't split a coherent file just to hit a number.


3. Components render UI; logic goes elsewhere

Components should primarily render. Push fetching/state/transforms into a hook or composable.

// ❌ Component owns the data layer
function ProductList() {
  const [products, setProducts] = useState([])
  useEffect(() => { fetch('/api/products').then(r => r.json()).then(setProducts) }, [])
  return <div>{/* render */}</div>
}

// ✅ Component renders; logic lives in a hook
function ProductList() {
  const { products, isLoading } = useProducts()
  if (isLoading) return <Loading />
  return <div>{/* render */}</div>
}
  • Custom hooks must start with use.
  • A component calling an API directly is acceptable only for the smallest one-off cases.

4. Next.js — Server Components by default

In the App Router, page.tsx and layout.tsx are Server Components. Reach for "use client" only when you actually need the client.

Server Component Client Component
Fetch data, read DB/API Form, modal, dropdown
Handle secret tokens Event handlers, animation
Render static/semi-static layout useState/useEffect, browser APIs (window, localStorage)

Keep client components small. Don't "use client" a whole page for one interactive button — extract the button into its own client component and keep the page a Server Component.


5. Vue — Composition API + composables

For full production apps, prefer the Composition API with <script setup> Single File Components. (Options API is fine for simple cases / progressive enhancement.)

  • components/ → UI
  • composables/ → reusable pure logic (useX)
  • service files → API calls

Use a composable for reusable pure logic; use a component when reusing both logic and layout.


6. State — start local, escalate only when needed

Need Use
Component-internal state useState / ref
Reusable state/logic in one feature custom hook / composable
Shared UI state in a subtree Context (React) / provide-inject (Vue)
Cross-app, complex, persisted Zustand / Pinia / Redux
Server state / API cache TanStack Query (react-query) / similar

Don't reach for global state (or Redux) on day one of a small app. Server state belongs in a query library, not a global store.


7. API in service files

Never scatter raw fetch/axios across components.

// user.api.ts
export async function getUsers() {
  const res = await http.get('/users')
  return res.data
}

// useUsers.ts
export function useUsers() {
  return useQuery({ queryKey: ['users'], queryFn: getUsers })
}

Always handle loading, error, and empty states explicitly.


8.

자주 묻는 질문

폴더 이름도 정해 주나요?

아닙니다. 폴더 구성은 프로젝트의 스캐폴딩 가이드를 따르며, 이 스킬은 코드가 어느 계층에 속하는지에 초점을 맞춥니다.

시각 디자인도 다루나요?

아닙니다. 이 스킬은 코드 구조를 다루며, 시각 디자인은 별도의 스킬이 담당합니다.

파일 크기 제한이 엄격한가요?

아닙니다. 파일 크기는 강제 한도가 아니라 참고 신호로 봅니다.

상세 정보

작성자의 원본 설명

How to organize frontend code — separation of concerns (UI / logic / data / type), file responsibility, state tiers, API services, schema validation, and framework conventions for React/Next and Vue. Structural rules, not visual design.

repo: vudovn/ag-kit

인기도

GitHub 스타
8.2k
순위
#12532
라이선스
MIT
업데이트
2026. 10. 18.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬