ln-721-frontend-restructure

from levnikolaevich/claude-code-skills

Greate Claude Code skills collection. Production-ready skills that cover the full delivery workflow — from research and discovery to epic planning, task breakdown, implementation, testing, code review, and quality gates.

65 stars13 forksUpdated Jan 25, 2026
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-721-frontend-restructure

SKILL.md

ln-721-frontend-restructure

Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-720-structure-migrator

Restructures monolithic React frontend code into component-based architecture using AST-based analysis methodology.


Purpose & Scope

AspectDescription
InputMonolithic React frontend source
OutputComponent-based architecture with co-located feature folders
FrameworkReact only

Scope boundaries:

  • Restructures existing code, does not add new functionality
  • Works with React + TypeScript projects
  • Applies transformation rules from reference files

Workflow

PhaseNameActionsOutput
1AnalyzeScan source, detect component types, measure complexityFile inventory, complexity metrics
2PlanApply split thresholds, calculate file moves, detect conflictsMigration plan
3ExecuteCreate folders, extract content, update importsRestructured files
4VerifyRun build, check imports, validate structureBuild success report

Phase 1: Analyze

Scan current frontend structure and classify components.

StepActionReference
1.1Scan all .tsx and .ts files in source
1.2Measure file complexity (lines, hooks, types)transformation_rules.md
1.3Classify components by categorycomponent_patterns.md
1.4Build import dependency graphimport_strategy.md

Output: Component inventory with classifications and metrics.


Phase 2: Plan

Generate migration plan based on analysis.

StepActionReference
2.1Apply split thresholds to identify files to restructuretransformation_rules.md
2.2Calculate target paths for each filereact_folder_structure.md
2.3Identify import updates neededimport_strategy.md
2.4Detect potential conflicts (name collisions, circular deps)

Output: Migration plan with Before/After mapping.


Phase 3: Execute

Apply transformations in correct order.

StepActionNotes
3.1Create directory structureAll target folders
3.2Extract types to types.tsTypes have no dependencies
3.3Extract constants to constants.tsConstants depend only on types
3.4Extract hooks to hooks.tsHooks depend on types, constants
3.5Extract sub-componentsComponents use all above
3.6Create barrel exports (index.ts)For clean imports
3.7Update all import pathsFix references

Order is critical: Execute in sequence to avoid broken imports.


Phase 4: Verify

Validate restructured project.

CheckCommandExpected
TypeScript compilationnpx tsc --noEmitNo errors
Buildnpm run buildSuccess
No orphan filesManual checkSource location empty
Imports resolveBuild successNo module not found errors

Transformation Summary

TransformationBefore StateAfter State
Component SplitSingle file >300 linesFeature folder with co-located files
Type ExtractionInline interfacesSeparate types.ts
Constant ExtractionInline magic valuesSeparate constants.ts
Hook ExtractionInline useState/useEffectSeparate hooks.ts or shared hooks
UI Component MoveScattered in featuresCentralized in components/ui/
Layout Component MoveMixed with featuresCentralized in components/layout/

Critical Rules

  • Single Responsibility: Handle only frontend restructuring, no backend changes
  • Idempotent: Can re-run without duplicate files or corruption
  • Build Verification: Must verify npm run build passes after changes
  • Preserve Functionality: No behavioral changes, only structural
  • Backup Strategy: Do not delete source files until verification passes
  • Import Consistency: Use path aliases for shared, relative for co-located

Definition of Done

  • All source files analyzed and classified
  • Migration plan generated with Before/After mapping
  • Directory structure created per template
  • All extractions completed (types, constants, hooks, components)
  • Import paths updated throughout project
  • npm run build passes successfully
  • No orphan imports or missing files
  • Barrel exports created for shared folders

Risk Mitigation

RiskDetectionMitigation
Build failure after restructurenpm run build failsRollback: restore from source, investigate specific error
Missing importsModule not found errorsScan all imports before/after, update missed paths
Circular dependenciesBuild warning or runtime errorAnalyze dependency graph, break cycles by extr

...

Read full content

Repository Stats

Stars65
Forks13
LicenseMIT License