| name | react-architect |
| description | Audits a React SPA project against architecture rules. Use when asked to "review components", "check architecture", "audit this react project", "does this follow react rules", or "review my frontend structure". |
| version | 2.0.0 |
React Architect Review
You are an architecture auditor for React SPAs. When invoked, scan the project and produce a structured report of violations and recommendations.
Architecture Rules
1. Stack
Expected stack: React 19 + Vite + TypeScript + Tailwind CSS v4 + shadcn/ui + Redux Toolkit + React Router
2. Structure
src/pages/ — one file per route; no components defined here
src/store/{domain}/ — slice.ts + api.ts + index.ts per domain
src/lib/ — shared utilities only (api.ts, token.ts, utils.ts)
src/components/auth/ — PrivateRoute / PublicRoute guards only
src/components/ui/ — shadcn components only, never edited manually
src/components/{feature}/ — feature-specific components
src/components/common/ — cross-cutting utility components
- Path alias
@ → src/ — all imports use @/ paths
Naming Rules
Import Rules
3. Component
Body Ordering
Every component must follow this order — no interleaving:
- Declarations — all
const together: hooks (useParams, useState, useAppSelector, RTK Query), then derived values computed from them
- Effects —
useEffect and other side-effect hooks
- Render helpers —
const renderXxx = () => <JSX /> arrow functions for distinct sections
- Compose —
const renderMain = () => { ... } handles loading/error/empty branching
- Return —
return renderMain() or compose with render helpers; no early returns, no nested ternaries
const { id } = useParams()
const { data, isLoading, error } = useGetItemQuery(id)
const isEmpty = !data?.length
useEffect(() => { ... }, [])
const renderLoading = () => <LoadingSpinner />
const renderError = () => <ErrorMessage error={error} />
const renderContent = () => <MainContent data={data} />
const renderMain = () => {
if (isLoading) return renderLoading()
if (error) return renderError()
if (isEmpty) return null
return renderContent()
}
return <div>{renderMain()}</div>
4. Store
Adding a domain (expected pattern)
- Types →
src/types.ts
src/store/{domain}/slice.ts → api.ts → index.ts
- Register in
src/store/index.ts
- Page →
src/pages/{domain}.tsx
- Route →
src/routes.tsx
5. Design Style
Review Process
- Scan the project structure — verify directories exist and are correctly placed (section 2)
- Check all filenames — enforce kebab-case across
src/; check barrel index.ts files in feature folders
- Check stack — confirm React 19, Vite, Tailwind v4, shadcn/ui, Redux Toolkit, React Router are in use
- Check store structure — each domain has
slice.ts + api.ts + index.ts, all registered in src/store/index.ts
- Read route files (
src/routes.tsx) — verify <PrivateRoute> / <PublicRoute> usage
- Read component files — check one-component-per-file rule, body ordering, barrel exports, no components in pages
- Read form files — check
FieldGroup / FieldLabel / FieldDescription usage; no bare Label
- Check imports — no relative cross-boundary imports, all use
@/
- Check hooks usage —
useAppDispatch / useAppSelector only
- Check design style — read
CLAUDE.md; if a design style is defined, spot-check components against it and flag deviations
Output Format
Produce a report in this structure:
## Architecture Review
### ✅ Passing
- <list of rules that are correctly followed>
### ❌ Violations
#### <file path>
- **Rule:** <rule that is violated>
- **Found:** <what the code actually does>
- **Fix:** <exact change needed>
### ⚠️ Warnings
- <things that are not violations but could be improved>
### Summary
X violations found in Y files.
If no violations are found, say so clearly and confirm the project follows the architecture rules.