| name | new-component |
| description | Scaffold a new React component following project conventions — section separators, Props interface, named exports, proper placement in _components/ or components/ |
New Component Scaffolding
Generate a new component that follows all homeflix conventions. The user provides the component name and location.
Inputs
The user should specify:
- Component name — PascalCase (e.g.,
CastSection, MovieStats)
- Location — Either:
- A route path for route-private components → placed in
_components/ under that route
components/ for shared cross-route components
- Data-fetching? — Whether this component owns a query (most do in this codebase)
- Multi-file? — Whether it needs sub-components in separate files (folder with
index.tsx) or is standalone (single .tsx file)
Template: Single-file data-fetching component
This is the most common pattern. Generate this unless told otherwise:
'use client';
import { useQuery } from '@tanstack/react-query';
import { Query } from '@/components/query';
import { Skeleton } from '@/components/ui/skeleton';
function {Name}Loading() {
return (
<div className="space-y-4">
<Skeleton className="h-6 w-48" />
<Skeleton className="h-32 w-full" />
</div>
);
}
interface {Name}ContentProps {
}
function {Name}Content({}: {Name}ContentProps) {
return (
<section>
{/* TODO: Implement success state */}
</section>
);
}
interface {Name}Props {
}
function {Name}({}: {Name}Props) {
return null;
}
export type { {Name}Props };
export { {Name} };
Template: Single-file static component (no query)
For components that receive all data via props:
'use client';
interface {Name}Props {
}
function {Name}({}: {Name}Props) {
return (
<div>
{/* TODO: Implement */}
</div>
);
}
export type { {Name}Props };
export { {Name} };
Template: Multi-file component (folder)
When the component has 2+ private sub-components, create a folder:
{kebab-name}/
├── index.tsx # Main export, wires query → states
├── {sub-component}.tsx # Private sub-component
└── {sub-component}.tsx # Private sub-component
The index.tsx follows the same section structure. Sub-component files are simpler — just the component and its exports.
Naming Rules
- Files: kebab-case (
cast-section.tsx, movie-header/)
- Components: PascalCase (
CastSection, MovieHeader)
- Props:
{ComponentName}Props interface above the component
- Loading:
{ComponentName}Loading function
- Success content:
{ComponentName}Content function
- Error:
{ComponentName}Error function (optional, many sections return () => null)
Placement Rules
| Scenario | Location |
|---|
| Used only by one route | app/(protected)/{route}/_components/{name}.tsx |
| Used by multiple routes | components/{domain}/{name}.tsx (e.g., components/media/) |
| UI primitive | components/ui/ (shadcn — auto-generated) |
| Query wrapper | components/query/ |
Checklist
After generating the component: