Use for frontend architecture boundaries: code ownership, directory roles, file placement, import direction, UI/component extraction, API/data contracts, fetching/query, URL state, mappers/schemas/DTOs, hooks/stores, architecture docs, and tool enforcement. Also use before agent-initiated architecture-enforcement changes in lint, CI, import-boundary checks, or similar automation—even without a user request—and for small UI changes that may leak business rules or external data into lower-level code.
66
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./skills/instruction/frontend-layered-architecture/SKILL.mdThe canonical home for this skill is frontend-layered-architecture in choegyumin/agent-skills
Frontend directory structures should not collapse into “pages and everything else.” Type-revealing but role-ambiguous folders such as components, hooks, models, utils, and shared can absorb all code. This skill does not exist to force a large architecture. It exists to prevent business rules, API calls, URL state, and similar logic from unconsciously leaking into inappropriate folders during implementation.
Code should be separated into layers by role, dependency, external data boundary, and orchestration responsibility. Lower-level code must not be made aware of higher-level context.
This skill does not enforce a specific methodology such as Feature-Sliced Design or Vertical Slice Architecture. Type-based, feature-based, domain-driven, and other directory structures can all be valid. What matters is whether roles and dependency direction are clear within the structure the project has chosen, whether external data contracts are isolated, and whether code responsibilities and frontend-owned domain logic are managed effectively.
In an existing project, treat architecture as intentional only when it is documented, user-approved, or consistently recognizable through role, dependency, and Data boundaries. Otherwise, apply this skill's baseline to new and changed code instead of treating repeated placement as authority.
If the project already uses layer terminology, prefer the project’s terms. Use the terms below only when there is no existing terminology, or when explaining structure. These abstract layer names are not default directory names; do not convert End-User, Domain, Shared, or Data into folders unless the user explicitly selected those names.
flowchart TB
End-User --> Domain
Domain --> Shared
End-User --> Data
Domain -. schemas/types by default .-> Data| Layer | Meaning |
|---|---|
| End-User | Screens delivered to users. The highest-level layer, such as pages and routes, where UI flow, data fetching, and orchestration are handled. |
| Domain | Reusable business rules, validation, calculations, and feature flags, similar to Clean Architecture Entities and Use Cases. In the baseline architecture recommended by this skill, Domain excludes API calls and external service access. |
| Shared | Pure code that knows no external context. This is the lowest-level layer. |
| Data | External data contracts and execution boundaries. API-related source code belongs here and is treated like frontend-consumed externally-owned code, even when frontend developers wrote it. |
These abstract layers are the minimum units for designing a sound frontend structure. Real projects may split them further, but this means at least four concepts are needed. That is why they are abstract layers.
Minimum guards:
ProductCard can be Shared if it only renders injected props, while a generic-looking buildSearchParams is not Shared if it knows router state, API request parameters, store state, or business rules.useQuery-style APIs) keeps Data execution, caching, and synchronization in End-User UI orchestration. Do not replace this frontend default merely because another language or framework commonly uses a different direction. Follow another direction only when documented or approved project rules establish it, a consistently recognizable existing architecture already uses it, or the user explicitly decides it.features and widgets to Domain, features may still be forbidden from importing UI orchestration in widgets.Classify the user’s purpose in one sentence, then read the first matching document. Do not use this file as a substitute for the routed document.
| User purpose | Read |
|---|---|
| Existing project structure judgment or change, including directory addition, removal, renaming, or reorganization, file placement, file extraction, import direction, or dependency boundary decisions | brownfield.md |
| New frontend project with no chosen directory/layer structure | greenfield.md |
Architecture documentation such as docs/architecture.md, directory rules, dependency rules, or Mermaid overview | writing-docs.md |
eslint-plugin-boundaries, ESLint, CI, import boundaries, or other tool-based enforcement of architecture rules | enforcing-rules.md |
| Placement or import direction remains unresolved after applying the main routed document, or broad brownfield audit needs a secondary checklist | best-practices.md |
Routing rules:
enforcing-rules.md even when the user did not request enforcement or architecture is not the session's primary purpose.brownfield.md for both structure decisions and user-requested structure changes. Do not treat a request for a new directory or layer structure as greenfield work.brownfield.md first, then check only the Common Mistakes table in best-practices.md as a secondary checklist. Do not apply examples as templates or override project-specific rules.best-practices.md by default.ee88381
Canonical home
since Aug 31, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.