renamify apply
The apply
command executes a previously generated plan, making all the planned changes to your codebase atomically.
renamify apply [ID] [OPTIONS]
Arguments
Section titled “Arguments”[ID]
- Plan ID, file path, or “latest” (optional - defaults to .renamify/plan.json)
Options
Section titled “Options”--atomic
- Apply changes atomically (default: true)--commit
- Create a git commit after applying--force-with-conflicts
- Apply even if conflicts are detected
How It Works
Section titled “How It Works”When you run apply
, Renamify:
- Loads the plan from the specified file
- Validates the plan and checks for conflicts
- Creates backups of all files to be modified
- Applies content changes to files atomically
- Renames files and directories in dependency order
- Records the operation in history for undo support
- Optionally commits to git if requested
Examples
Section titled “Examples”Basic Apply
Section titled “Basic Apply”# Apply the default plan at .renamify/plan.jsonrenamify apply
# Explicitly apply the latest/default planrenamify apply latest
Apply by Plan ID
Section titled “Apply by Plan ID”# Apply a specific plan from historyrenamify apply abc123def456
# Apply from a file pathrenamify apply ./my-rename-plan.json
# Apply from a custom locationrenamify apply ./backups/old-plan.json
Apply with Git Commit
Section titled “Apply with Git Commit”# Apply changes and create a git commitrenamify apply --commit
# Apply specific plan with commitrenamify apply abc123def456 --commit
Force Apply (Dangerous)
Section titled “Force Apply (Dangerous)”# Apply even if conflicts are detectedrenamify apply --force-with-conflicts
Atomic Operations
Section titled “Atomic Operations”By default, apply
uses atomic operations:
What “Atomic” Means
Section titled “What “Atomic” Means”- All or nothing: Either all changes succeed or none are applied
- Temporary files: Changes are written to temporary files first
- Atomic rename: Files are moved into place atomically
- Rollback on failure: If any step fails, all changes are reverted
Benefits
Section titled “Benefits”- No partial states: Your codebase is never left in a half-modified state
- Safe interruption: You can safely Ctrl+C during application
- Consistency: All files are updated simultaneously
Example Atomic Process
Section titled “Example Atomic Process”$ renamify apply
📋 Loading plan: .renamify/plan.json🔍 Validating 23 file modifications, 5 renames...💾 Creating backups...✏️ Applying content changes...📁 Renaming files and directories...✅ Applied successfully! Operation ID: def456-20241201-150322
Backups stored in: .renamify/backups/def456-20241201-150322/
Conflict Detection
Section titled “Conflict Detection”Before applying, Renamify checks for various conflicts:
File Modification Conflicts
Section titled “File Modification Conflicts”❌ Conflict: File 'src/utils.js' has been modified since plan was created Plan checksum: abc123... Current checksum: def456...
Resolve by:1. Recreating the plan: renamify plan old new2. Or force apply: renamify apply --force-with-conflicts
File Rename Conflicts
Section titled “File Rename Conflicts”❌ Conflict: Multiple files would be renamed to 'components/Utils.js': - components/old_utils.js - components/oldUtils.js
Resolve by recreating plan with --exclude patterns.
Missing Files
Section titled “Missing Files”❌ Conflict: File 'src/missing.js' in plan no longer exists
The plan may be outdated. Consider recreating it.
Git Integration
Section titled “Git Integration”Automatic Commits
Section titled “Automatic Commits”renamify apply --commit
Creates a commit message like:
Renamify: getUserName → fetchUserProfile
Applied renaming operation def456-20241201-150322:- Modified 23 files- Renamed 5 files- Renamed 2 directories
Operation can be undone with: renamify undo def456-20241201-150322
Pre-commit Requirements
Section titled “Pre-commit Requirements”If using --commit
, ensure:
- Git working directory is clean (or you’re okay with a mixed commit)
- You have appropriate git configuration (user.name, user.email)
Backup System
Section titled “Backup System”Every apply operation creates comprehensive backups:
Backup Structure
Section titled “Backup Structure”.renamify/backups/def456-20241201-150322/├── src/│ ├── auth.js # Original file content│ └── utils.js├── components/│ └── UserProfile.tsx├── checksums.json # File integrity checksums└── operation-info.json # Operation metadata
Backup Contents
Section titled “Backup Contents”- Original file contents: Exact copies before modification
- Checksums: SHA-256 hashes for integrity verification
- Operation metadata: Plan details, timestamps, file paths
- Rename records: Original → new path mappings
Error Handling
Section titled “Error Handling”Partial Application Failures
Section titled “Partial Application Failures”If any step fails during application:
❌ Error applying changes to 'src/readonly.js': Permission denied
Rolling back all changes...✅ All changes have been rolled back successfully.
To fix:1. Check file permissions: ls -la src/readonly.js2. Make writable: chmod +w src/readonly.js3. Retry: renamify apply
Recovery Steps
Section titled “Recovery Steps”- Check file permissions - Ensure you can write to all files
- Free disk space - Ensure adequate space for operations
- Close editors - Some editors may lock files
- Retry application - Most errors are temporary
Force Application
Section titled “Force Application”Use --force-with-conflicts
only when you understand the risks:
# This bypasses safety checks - use carefully!renamify apply --force-with-conflicts
After Application
Section titled “After Application”Verify Changes
Section titled “Verify Changes”# Check what was actually appliedrenamify history --limit 1
# Test your codenpm test # or cargo test, etc.
Undo if Needed
Section titled “Undo if Needed”# Undo the last operationrenamify undo def456-20241201-150322
# Or see all operations and pick onerenamify historyrenamify undo <operation-id>
Clean Up
Section titled “Clean Up”The plan file remains after application for reference:
# Remove the plan file if donerm .renamify/plan.json
# Or keep it for documentation
Performance Considerations
Section titled “Performance Considerations”Large Applications
Section titled “Large Applications”For very large renaming operations:
- Disk space: Ensure you have space for backups (roughly 2x the size of modified files)
- Memory usage: Large plans may require significant RAM
- Time: Atomic operations on thousands of files can take time
Optimization Tips
Section titled “Optimization Tips”- Close unnecessary programs to free system resources
- Use SSD storage for faster file operations
- Ensure stable power for long operations
Exit Codes
Section titled “Exit Codes”0
- Applied successfully1
- Conflicts detected (use--force-with-conflicts
to override)2
- Invalid plan file or arguments3
- Internal error or system issue
Integration with Other Commands
Section titled “Integration with Other Commands”Typical Workflow
Section titled “Typical Workflow”# 1. Plan the changesrenamify plan old_name new_name --preview table
# 2. Review the plancat .renamify/plan.json | jq '.stats'
# 3. Apply the planrenamify apply --commit
# 4. Verify and testgit log --oneline -1npm test
Alternative: Use rename
Section titled “Alternative: Use rename”For simpler cases, consider using renamify rename
which combines planning and applying:
# This does plan + apply in one step with confirmationrenamify rename old_name new_name --preview table --commit