Component Splitter
This Skill provides Claude Code with specific guidance for normalizing component size and extracting reusable hooks.
When to use this skill
- •When a component exceeds 300 lines
- •When extracting complex state logic into custom hooks
- •When separating concerns (UI, state, business logic)
- •When implementing component composition patterns
- •When reducing component complexity through decomposition
- •When creating reusable sub-components
- •When maintaining API stability during refactoring
Instructions
For detailed implementation guidance, refer to: Component Splitter Agent
Workflow Integration
This skill is part of the normalize-components workflow:
- •Component Analysis: Identify composition opportunities, calculate complexity metrics
- •Hook Extraction: Extract custom hooks for state, effects, event handlers
- •Component Decomposition: Create modular sub-components with composition patterns
- •Validation & Testing: Validate functionality preserved, test composition
Quality Standards
Code Quality
- •✅ Max 300 lines per component (excluding imports/comments)
- •✅ Max 5 parameters per function
- •✅ Max 3 nesting levels
- •✅ Single responsibility principle
- •✅ Clear composition patterns
Backward Compatibility
- •✅ Props interface stable
- •✅ Component behavior preserved
- •✅ Styling maintained
- •✅ Event handlers work identically
Example Usage
code
"Split src/presentation/components/knowledge/KnowledgePage.tsx (658 lines) using the normalize-components workflow"
This will:
- •Analyze the component for composition opportunities
- •Extract custom hooks for complex logic (e.g., useKnowledgeSource, useRAGPipeline)
- •Create sub-components (e.g., SourceList, DocumentPreview, EmbeddingProgress)
- •Maintain API compatibility (same props, same behavior)
- •Validate with tests and TypeScript checking
Validation Commands
bash
# TypeScript check
pnpm tsc --noEmit --incremental
# Test suite
pnpm test
# Component size verification
find src/presentation/components -name "*.tsx" -exec wc -l {} \; | awk '$1 > 300 {print $2, $1, "lines"}'
Success Criteria
- •✅ All components ≤300 lines
- •✅ Zero TypeScript errors
- •✅ 100% test pass rate
- •✅ Props interface stable
- •✅ Component behavior preserved
- •✅ Custom hooks tested independently