一键导入
frontend-component
// Create React/Vue component with TypeScript, tests, and styles. Auto-invoke when user says "create component", "add component", "new component", or "build component".
// Create React/Vue component with TypeScript, tests, and styles. Auto-invoke when user says "create component", "add component", "new component", or "build component".
Create REST/GraphQL API endpoint with validation, error handling, and tests. Auto-invoke when user says "add endpoint", "create API", "new route", or "add route".
Generate backend tests (unit, integration, mocks). Auto-invoke when user says "write test for", "add test", "test this", or "create test".
Create database migration with schema changes and rollback. Auto-invoke when user says "create migration", "add table", "modify schema", or "change database".
Generate frontend component tests (unit, snapshot, e2e). Auto-invoke when user says "test this component", "write component test", or "add component test".
Clear conversation context while preserving knowledge via context marker. Use when user says "clear context", "start fresh", "done with this task", or when approaching token limits.
Initialize Navigator documentation structure in a project. Auto-invokes when user says "Initialize Navigator", "Set up Navigator", "Create Navigator structure", or "Bootstrap Navigator".
| name | frontend-component |
| description | Create React/Vue component with TypeScript, tests, and styles. Auto-invoke when user says "create component", "add component", "new component", or "build component". |
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash |
| version | 1.0.0 |
Generate production-ready React/Vue components with TypeScript, tests, and styles following modern best practices.
Auto-invoke when user mentions:
Ask user for component details:
Component name: [PascalCase name, e.g., UserProfile]
Component type:
- simple (basic functional component)
- with-hooks (useState, useEffect, etc.)
- container (data fetching component)
Styling approach:
- css-modules (default)
- styled-components
- tailwind
Props needed: [Optional: describe expected props]
Validate component name:
functions/name_validator.pyIMPORTANT: This step MUST be executed for complex components.
Before generating files, confirm interpretation with user.
Display verification:
I understood you want:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Component: {NAME}
Type: {TYPE} (inferred because: {REASON})
Location: src/components/{NAME}/
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Detected patterns from your codebase:
- Styling: {CSS_APPROACH} (found {EVIDENCE})
- Testing: {TEST_LIBRARY} (found in package.json)
- Similar component: {EXISTING_COMPONENT} at {PATH}
Props I'll generate:
{PROPS_PREVIEW}
Proceed with generation? [Y/n]
Skip verification if (HIGH-STAKES ONLY mode):
Always verify if:
Based on component type and requirements:
Use predefined function: functions/props_interface_generator.py
# Generates TypeScript interface based on component requirements
python3 functions/props_interface_generator.py \
--name "UserProfile" \
--props "userId:string,onUpdate:function,isActive:boolean"
Output:
interface UserProfileProps {
userId: string;
onUpdate?: () => void;
isActive?: boolean;
children?: React.ReactNode;
className?: string;
}
Use appropriate template based on type:
Simple component:
Use template: templates/component-simple-template.tsx
Component with hooks:
Use template: templates/component-with-hooks-template.tsx
Container component:
Use template: templates/component-container-template.tsx
Use predefined function: functions/component_generator.py
python3 functions/component_generator.py \
--name "UserProfile" \
--type "simple" \
--props-interface "UserProfileProps" \
--template "templates/component-simple-template.tsx" \
--output "src/components/UserProfile/UserProfile.tsx"
Template substitutions:
${COMPONENT_NAME} → Component name (PascalCase)${PROPS_INTERFACE} → Generated props interface${STYLE_IMPORT} → CSS module import${DESCRIPTION} → Brief component descriptionUse predefined function: functions/test_generator.py
python3 functions/test_generator.py \
--component-name "UserProfile" \
--component-path "src/components/UserProfile/UserProfile.tsx" \
--template "templates/test-template.test.tsx" \
--output "src/components/UserProfile/UserProfile.test.tsx"
Test template includes:
Template substitutions:
${COMPONENT_NAME} → Component name${IMPORT_PATH} → Relative import path${TEST_CASES} → Generated test cases based on propsUse predefined function: functions/style_generator.py
python3 functions/style_generator.py \
--name "UserProfile" \
--approach "css-modules" \
--template "templates/style-template.module.css" \
--output "src/components/UserProfile/UserProfile.module.css"
CSS Modules template:
.container {
/* Component wrapper styles */
}
.title {
/* Title styles */
}
/* Add more classes as needed */
Styled Components alternative:
// Generated if --approach "styled-components"
import styled from 'styled-components';
export const Container = styled.div`
/* Component wrapper styles */
`;
export const Title = styled.h2`
/* Title styles */
`;
Create index.ts for clean imports:
Write(
file_path: "src/components/UserProfile/index.ts",
content: "export { UserProfile } from './UserProfile';\nexport type { UserProfileProps } from './UserProfile';\n"
)
Allows usage:
import { UserProfile } from '@/components/UserProfile';
Display generated files and usage:
✅ Component Created: UserProfile
Structure:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📁 src/components/UserProfile/
├── UserProfile.tsx (Component)
├── UserProfile.test.tsx (Tests)
├── UserProfile.module.css (Styles)
└── index.ts (Exports)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Props Interface:
interface UserProfileProps {
userId: string;
onUpdate?: () => void;
isActive?: boolean;
}
Usage:
import { UserProfile } from '@/components/UserProfile';
<UserProfile
userId="123"
onUpdate={() => console.log('Updated')}
isActive={true}
/>
Next Steps:
1. Customize component implementation
2. Run tests: npm test UserProfile
3. Import and use in your feature
Validates component naming conventions.
Usage:
python3 functions/name_validator.py --name "UserProfile"
Checks:
Returns: Valid name or error message
Generates TypeScript props interface from user input.
Usage:
python3 functions/props_interface_generator.py \
--name "UserProfile" \
--props "userId:string,onUpdate:function,isActive:boolean"
Supported types:
string, number, booleanfunction (becomes () => void)array (becomes any[])object (becomes Record<string, any>)react-node (becomes React.ReactNode)Returns: TypeScript interface string
Generates component file from template with substitutions.
Usage:
python3 functions/component_generator.py \
--name "UserProfile" \
--type "simple" \
--props-interface "UserProfileProps" \
--template "templates/component-simple-template.tsx" \
--output "src/components/UserProfile/UserProfile.tsx"
Parameters:
--name: Component name (PascalCase)--type: Component type (simple/with-hooks/container)--props-interface: Props interface name--template: Template file path--output: Output file pathReturns: Generated component code
Generates test file with React Testing Library.
Usage:
python3 functions/test_generator.py \
--component-name "UserProfile" \
--component-path "src/components/UserProfile/UserProfile.tsx" \
--template "templates/test-template.test.tsx" \
--output "src/components/UserProfile/UserProfile.test.tsx"
Generates tests for:
Returns: Generated test code
Generates style file (CSS Modules or Styled Components).
Usage:
python3 functions/style_generator.py \
--name "UserProfile" \
--approach "css-modules" \
--template "templates/style-template.module.css" \
--output "src/components/UserProfile/UserProfile.module.css"
Supported approaches:
css-modules (default)styled-componentstailwind (generates className utilities)Returns: Generated style code
Basic functional component template.
Placeholders:
${COMPONENT_NAME} - Component name${PROPS_INTERFACE} - Props interface definition${STYLE_IMPORT} - CSS import statement${DESCRIPTION} - Component descriptionComponent template with useState, useEffect examples.
Additional placeholders:
${HOOKS} - Hook declarations${HANDLERS} - Event handler functionsContainer component template with data fetching.
Additional placeholders:
${API_IMPORT} - API function import${DATA_TYPE} - Data type definition${FETCH_LOGIC} - Data fetching implementationReact Testing Library test template.
Placeholders:
${COMPONENT_NAME} - Component name${IMPORT_PATH} - Import path${TEST_CASES} - Generated test casesCSS Modules template.
Placeholders:
${COMPONENT_NAME_KEBAB} - Component name in kebab-case${BASE_STYLES} - Base container stylesSee examples/ directory for reference implementations:
Each example includes:
any type (use unknown if needed)Problem: Generated component throws errors
Solutions:
Problem: Generated tests don't pass
Solutions:
--verbose flagProblem: CSS modules not loading
Solutions:
This skill succeeds when:
Auto-invoke this skill when creating React components to ensure consistency and save time ⚛️