codemap_move
Move or rename a file or directory to a new location
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
source | string | ✅ Required | Source file or directory path |
destination | string | ✅ Required | Destination file or directory path |
Usage Examples
MCP Usage (for AI Agents like Claude)
json
{
"name": "codemap_move",
"arguments": {
"source": "src/oldName.ts",
"destination": "src/newName.ts"
}
}Example Output
JSON Response
json
{
"success": true,
"message": "Directory moved successfully",
"source": "src/legacy/authentication",
"destination": "archive/auth-old",
"filesmoved": 8,
"timestamp": "2026-04-11T14:32:10.456Z"
}When to Use This Tool
-
Use
- Rename files to better reflect their purpose or updated functionality
- Reorganize project structure by moving files between directories
- Archive deprecated or legacy code to keep active codebase clean
- Migrate files to new locations as part of a refactoring effort
- Consolidate related files into more logical directory groupings
codemap_move when you need to:
Common Patterns
Safe Refactoring Pattern
Always check dependencies before moving files to understand the impact on your codebase.
Directory Reorganization Pattern
Move directories systematically rather than all at once to minimize breakage.
1. codemap_get_dependencies to check what imports the file
2. codemap_move to relocate the file
3. Update all import statements in dependent files
4. Run tests to verify nothing brokeAlways check dependencies before moving files to understand the impact on your codebase.
Directory Reorganization Pattern
1. Plan new structure on paper
2. codemap_move directories one at a time
3. Update import paths after each move
4. Test incrementally to catch issues earlyMove directories systematically rather than all at once to minimize breakage.
Pro Tips
- Modern naming:
codemap_moveis the modern, explicit name - it works identically to the legacycodemap_renametool - Check dependencies first: Use
codemap_get_dependenciesto see what files import the one you're about to move - Update imports: Remember that moving files breaks import paths - update them manually or use find-and-replace tools
- Automatic backup: CodeMap creates automatic backups before move operations, so you can rollback if needed using
codemap_rollback - Search impact: Use
codemap_search_in_fileswith the old file path to find all files that reference it
Best Practices
- Always check dependencies before moving files with
codemap_get_dependencies - Update import paths immediately after moving files to prevent build errors
- Run tests after reorganizing to catch any broken references
- Move related files together to maintain logical groupings
- Use descriptive directory names that reflect the purpose of files within them
- Consider using search-and-replace to batch update import statements
Common Mistakes
❌ Mistake: Moving files without checking what imports them first
✅ Instead: Run
❌ Mistake: Moving many files at once without testing
✅ Instead: Move files incrementally, test after each move, and fix imports immediately to prevent accumulating errors
❌ Mistake: Forgetting that move operations are permanent (source is deleted)
✅ Instead: If you want to keep both versions, use
❌ Mistake: Moving files with relative paths that depend on their location
✅ Instead: Review the file's imports and exports - relative paths like
❌ Mistake: Not updating tests that reference the old file path
✅ Instead: Search your test files for references to the old path and update them alongside your source code imports
✅ Instead: Run
codemap_get_dependencies to see all files that reference the one you're moving, then update those import paths❌ Mistake: Moving many files at once without testing
✅ Instead: Move files incrementally, test after each move, and fix imports immediately to prevent accumulating errors
❌ Mistake: Forgetting that move operations are permanent (source is deleted)
✅ Instead: If you want to keep both versions, use
codemap_copy first, then delete the original manually after verification❌ Mistake: Moving files with relative paths that depend on their location
✅ Instead: Review the file's imports and exports - relative paths like
../utils will break when the file moves to a different directory depth❌ Mistake: Not updating tests that reference the old file path
✅ Instead: Search your test files for references to the old path and update them alongside your source code imports