1.3 KiB
1.3 KiB
name, description, disable-model-invocation
| name | description | disable-model-invocation |
|---|---|---|
| scaffold-component | Generate a new React component following project conventions | true |
Scaffold Component
Generate a new component at the specified path with proper structure.
Usage
/scaffold-component ComponentName path/to/component
Process
-
Parse Arguments
- First argument: Component name (PascalCase)
- Second argument: Path relative to
src/components/
-
Create Component File
"use client"; import { cls } from "@/lib/utils"; interface $NAMEProps { className?: string; } const $NAME = ({ className }: $NAMEProps) => { return <div className={cls("", className)}>{/* TODO: Implement */}</div>; }; export default $NAME; -
Determine if Hook is Needed
- Ask user if component needs state/effects
- If yes, create hook file at
src/hooks/{domain}/use{Name}.ts
-
Determine if Constants are Needed
- Ask user if component has static text
- If yes, create constants file at
src/constants/{domain}/{name}.ts
File Naming
- Component:
ComponentName.tsx(PascalCase) - Hook:
useComponentName.ts(camelCase with use prefix) - Constants:
componentName.ts(camelCase)
Output
Report created files and remind user to:
- Add necessary imports
- Implement the component logic
- Add to parent component/page