en un clic
new-component
Create a new React component with TypeScript and tests
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Menu
Create a new React component with TypeScript and tests
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Basé sur la classification professionnelle SOC
Create a complete feature module for Expo with screen, components, hooks, and services
Create a new Expo Router screen with proper structure
Create a well-formatted conventional commit with proper message
Review code changes for quality, security, and best practices
Run tests and analyze results, fix failing tests
Create a new Next.js API route handler with validation
| name | new-component |
| description | Create a new React component with TypeScript and tests |
| user-invocable | true |
| argument-hint | ["ComponentName"] |
| allowed-tools | Write, Read, Glob |
Create a new React component following project conventions.
Component name: $ARGUMENTS
Determine Location
Create Files
import { forwardRef, type ComponentPropsWithoutRef } from 'react'
import { cn } from '@/lib/utils'
export interface ComponentNameProps extends ComponentPropsWithoutRef<'div'> {
/** Description of variant prop */
variant?: 'default' | 'primary' | 'secondary'
/** Description of size prop */
size?: 'sm' | 'md' | 'lg'
}
const ComponentName = forwardRef<HTMLDivElement, ComponentNameProps>(
({ className, variant = 'default', size = 'md', children, ...props }, ref) => {
return (
<div
ref={ref}
className={cn(
'base-styles',
{
'variant-default': variant === 'default',
'variant-primary': variant === 'primary',
'variant-secondary': variant === 'secondary',
},
{
'size-sm': size === 'sm',
'size-md': size === 'md',
'size-lg': size === 'lg',
},
className
)}
{...props}
>
{children}
</div>
)
}
)
ComponentName.displayName = 'ComponentName'
export { ComponentName }
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { ComponentName } from './ComponentName'
describe('ComponentName', () => {
it('renders children correctly', () => {
render(<ComponentName>Test content</ComponentName>)
expect(screen.getByText('Test content')).toBeInTheDocument()
})
it('applies default variant styles', () => {
render(<ComponentName data-testid="component">Content</ComponentName>)
expect(screen.getByTestId('component')).toHaveClass('variant-default')
})
it('applies custom variant styles', () => {
render(<ComponentName data-testid="component" variant="primary">Content</ComponentName>)
expect(screen.getByTestId('component')).toHaveClass('variant-primary')
})
it('applies size classes', () => {
render(<ComponentName data-testid="component" size="lg">Content</ComponentName>)
expect(screen.getByTestId('component')).toHaveClass('size-lg')
})
it('merges custom className', () => {
render(<ComponentName data-testid="component" className="custom-class">Content</ComponentName>)
expect(screen.getByTestId('component')).toHaveClass('custom-class')
})
it('forwards ref correctly', () => {
const ref = { current: null }
render(<ComponentName ref={ref}>Content</ComponentName>)
expect(ref.current).toBeInstanceOf(HTMLDivElement)
})
})
export { ComponentName, type ComponentNameProps } from './ComponentName'