frontend-architecture
यह क्या करती है
यह स्किल आपके AI को फ़्रंटएंड कोड इस तरह बाँटना सिखाती है कि हर फ़ाइल का एक ही काम हो। इसमें React, Next और Vue प्रोजेक्ट शामिल हैं। यह उन डेवलपर्स के लिए है जिन्हें कोड बढ़ने के साथ भी व्यवस्थित रखना है।
कब इस्तेमाल करें
- ✓जब आप नया React, Next या Vue प्रोजेक्ट शुरू करें और साफ़ ढाँचा चाहिए।
- ✓जब आपकी फ़्रंटएंड फ़ाइलों में डिस्प्ले, डेटा लाना और वैलिडेशन आपस में मिल गए हों।
- ✓जब कोई कंपोनेंट फ़ाइल बहुत बड़ी हो गई हो और आप उसे ज़िम्मेदारी के हिसाब से बाँटना चाहें।
Skill का लिंक
https://github.com/vudovn/ag-kit/blob/main/.agents/skills/frontend-architecture/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे React ऐप को इस तरह व्यवस्थित कीजिए कि API कॉल, वैलिडेशन और डिस्प्ले कोड अलग-अलग फ़ाइलों में हों।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 18/10/2026
कमेंट
- …
इस repository की और skills
batch-operations
8.2kयह आपके एजेंट को एक ही बदलाव कई फ़ाइलों में एक साथ करने में मदद करती है, जैसे किसी फ़ंक्शन का नाम बदलना या पुराना इम्पोर्ट हर जगह बदलना।
brainstorming
8.2kयह आपके एजेंट को कुछ भी नया या जटिल बनाने से पहले स्पष्ट सवाल पूछना सिखाती है, ताकि वह पहले आपका लक्ष्य समझे।
code-review-checklist
8.2kयह आपके एजेंट को सही होने, सुरक्षा, प्रदर्शन, परीक्षण और डॉक्यूमेंटेशन के लिए कोड जाँचने की चेकलिस्ट देती है, AI से जुड़े जोखिमों सहित।
code-review-graph
8.2kयह आपके एजेंट को संरचना के मानचित्र से बड़े प्रोजेक्ट में कोड समीक्षा करने में मदद करती है, ताकि वह केवल बदलाव से प्रभावित फ़ाइलें पढ़े।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।