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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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/→ UIcomposables/→ 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.
댓글
- …
이 저장소의 다른 스킬
batch-operations
8.2k에이전트가 함수 이름 바꾸기나 오래된 import 교체처럼 같은 변경을 여러 파일에 한꺼번에 적용하도록 돕습니다.
brainstorming
8.2k에이전트가 새로운 것이나 복잡한 것을 만들기 전에 명확한 질문을 하도록 가르쳐 목표를 먼저 이해하게 합니다.
code-review-checklist
8.2k에이전트에게 정확성, 보안, 성능, 테스트, 문서를 검토하는 체크리스트를 주고, AI 관련 위험도 포함합니다.
code-review-graph
8.2k에이전트가 구조 지도를 이용해 큰 프로젝트의 코드를 검토하도록 돕고, 변경과 관련된 파일만 읽게 합니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.