Claude-skill-registry architecting-structure
Enforces "Feature-First" architecture across standard frameworks. Use to scaffold new projects, refactor messy ones, or enforce clean file organization rules.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/architecting-structure" ~/.claude/skills/majiayu000-claude-skill-registry-architecting-structure && rm -rf "$T"
manifest:
skills/data/architecting-structure/SKILL.mdsource content
Code Structure Architect
When to use this skill
- When the user asks to "set up the folders" for a new project.
- When the user asks to "clean up" or "refactor" a messy directory.
- When the user asks "where should I put this file?".
- When starting any new Next.js, Flutter, Python, or standard web project.
Core Philosophy: Feature-First
We strictly follow Feature-First Architecture (Vertical Slicing). Code that changes together stays together.
- Bad (Type-First):
,/components
,/hooks
(Separates logic by file type)./services - Good (Feature-First):
,/features/auth
(Groups explicitly by user value)./features/dashboard
Workflow
1. Scaffolding (New Project)
- Identify Framework: Detect if it's Next.js, Flutter, Python, etc.
- Apply Template: Use the specific directory map below.
- Create Core: Generate
(shared logic) andcore/
(business logic) folders immediately.features/
2. Refactoring (Cleanup)
- Audit: List all files.
- Group: Identify "features" (e.g., "Login", "Profile", "Feed").
- Move:
- Move generic UI (buttons, cards) ->
.components/ui/ - Move shared utilities (dates, formatting) ->
.utils/ - Move feature logic ->
.features/<feature-name>/
- Move generic UI (buttons, cards) ->
- Export: Create barrel files (
/index.ts
) only for the public API of a feature.barrier.dart
3. Enforcement (Check)
- Review: Check if a new file is being created in the root or a 'dump' folder.
- Block: "Stop. This belongs in
. Do not put logic infeatures/<name>
."pages/
Framework Standards
A. Next.js (App Router)
: Routing layer ONLY. (page.tsx, layout.tsx, route.ts). NO LOGIC.app/
-> Imports fromapp/(auth)/login/page.tsx@/features/auth
: The brain.features/features/auth/components/LoginForm.tsxfeatures/auth/hooks/useLogin.ts
(Server Actions)features/auth/actions/login.ts
: Shared dumb UI.components/
(Shadcn)components/ui/button.tsxcomponents/layout/header.tsx
: Singletons (Prisma, Stripe, Redis clients).lib/
B. Flutter (Clean + Riverpod)
: Entry point.lib/main.dart
: Routing, Themes, Constants, Extensions.lib/core/
:lib/features/features/auth/presentation/screens/features/auth/presentation/widgets/features/auth/data/repositories/features/auth/domain/models/
: Widgets used across multiple features.lib/shared/
C. Python (FastAPI / General)
: App init.app/main.py
: Config, Security, DB session.app/core/
: V1 endpoints.app/routers/
: Admin routes.app/internal/
(Optional): If logic is heavy.app/services/- Note: Python often prefers flat structures initially. Group by "Domain" (e.g.,
,app/users/
) if the app grows.app/items/
Best Practices (Recommended)
- Filenames:
- JS/TS:
for variables/functions,camelCase
for Components/Classes,PascalCase
for folders/routes.kebab-case - Dart: always
for filenames.snake_case - Python: always
.snake_case
- JS/TS:
- Barrel Files: Avoid them for internal usage (causes circular deps). Use them ONLY to expose a Feature's public API to the rest of the app:
- Right:
(whereimport { LoginForm } from '@/features/auth'
exists).features/auth/index.ts - Wrong:
(import directly:import { Button } from '@/components'
).@/components/Button
- Right:
Self-Correction Checklist
Before creating a file, ask:
- "Is this file specific to one feature (e.g., 'Delete Task Button')?" -> Put in
.features/tasks/components - "Is this file generic (e.g., 'Red Delete Button')?" -> Put in
.components/ui - "Is this file a page?" -> Put in
(Next.js) orapp/
(Flutter), but keep it empty (logic goes to feature).screens/