relocation
ย้ายไฟล์และโฟลเดอร์ไปยังตำแหน่งที่เหมาะสมตาม domain และ responsibility
SKILL.mdrelocation/SKILL.md
GitHubGoal
Move files and folders to appropriate locations by domain and responsibility along with updating all import paths
Scope
Covers moving files/folders and updating all references
Execute
1. Identify File Responsibilities
Goal: Identify File Responsibilities
- Analyze the domain or responsibility of each file:
domain: business logic and entitiesui: components and layoutsutils: helper functions and utilitiestypes: type definitions and interfacesapi: API endpoints and handlers
- Check the dependencies of each file
- Identify files that are in an inappropriate location
2. Plan Relocation Strategy
Goal: Plan Relocation Strategy
- Determine the target folder for each file by responsibility
- Check the dependency direction before moving:
- high-level modules depend on low-level modules
- domain depends on shared types, not the other way around
- Plan the move order to avoid circular dependencies
- Record the mapping of old path → new path
3. Execute File Relocation
Goal: Execute File Relocation
- Run
use-scriptsto move files to the appropriate folders - Move files in the planned order
- Check that no files are left behind in the original location
- Run
/deep-reviewto create barrel exports and configure import aliases for the new folders if necessary
4. Update Import Paths
Goal: Update Import Paths
- Run
/update-referencesto update all references - Search for import paths that reference the moved files
- Update import paths to match the new locations
- Check that all import paths are correct
5. Validate Changes
Goal: Validate Changes
- Run type check to confirm the import paths are correct
- Run build to check that there are no errors
- Check that there are no new circular dependencies
- Run
/deep-review(architecture dimension) to confirm the new structure
Rules
1. Responsibility-Based Relocation
Move files by domain or responsibility:
- Move by business domain, not by file type alone
- Group by a clear feature or module
- Keep the dependency direction correct
- Avoid moving files across layers unnecessarily
2. Dependency Direction
Keep the dependency direction correct:
- high-level modules depend on low-level modules
- domain layers depend on shared types, not the other way around
- UI layers depend on domain layers, not the other way around
- Avoid circular dependencies between folders
3. Import And Export Strategy
Update import paths and barrel exports correctly:
- Update import paths immediately after moving files
- Use barrel exports and import aliases to simplify import paths
- Avoid complex deep imports
- Check every import path that references the moved files
- Create
index.tsfor folders that have multiple files - Use
/deep-reviewto handle barrel exports and import aliases
Expected Outcome
- Files are in appropriate locations according to responsibility
- Concise and correct import paths
- Correct dependency direction
- No circular dependencies
- Consistent and well-organized structure
Common Mistakes
Common mistakes:
- Not updating import paths after moving files
- Moving files without analyzing dependencies
- Creating circular dependencies between folders
- Not using barrel exports and import aliases for new folders
- Moving files across layers unnecessarily
Anti-Patterns
Patterns that should not be done:
- ❌ Moving files without updating import paths
- ❌ Moving files randomly without criteria
- ❌ Creating circular dependencies between folders
- ❌ Not checking dependencies before moving
- ❌ Leaving orphan files behind after moving