Skip to content

renamify apply

The apply command executes a previously generated plan, making all the planned changes to your codebase atomically.

Terminal window
renamify apply [ID] [OPTIONS]
  • [ID] - Plan ID, file path, or “latest” (optional - defaults to .renamify/plan.json)
  • --atomic - Apply changes atomically (default: true)
  • --commit - Create a git commit after applying
  • --force-with-conflicts - Apply even if conflicts are detected

When you run apply, Renamify:

  1. Loads the plan from the specified file
  2. Validates the plan and checks for conflicts
  3. Creates backups of all files to be modified
  4. Applies content changes to files atomically
  5. Renames files and directories in dependency order
  6. Records the operation in history for undo support
  7. Optionally commits to git if requested
Terminal window
# Apply the default plan at .renamify/plan.json
renamify apply
# Explicitly apply the latest/default plan
renamify apply latest
Terminal window
# Apply a specific plan from history
renamify apply abc123def456
# Apply from a file path
renamify apply ./my-rename-plan.json
# Apply from a custom location
renamify apply ./backups/old-plan.json
Terminal window
# Apply changes and create a git commit
renamify apply --commit
# Apply specific plan with commit
renamify apply abc123def456 --commit
Terminal window
# Apply even if conflicts are detected
renamify apply --force-with-conflicts

By default, apply uses atomic operations:

  • 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
  • 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
Terminal window
$ 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/

Before applying, Renamify checks for various 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 new
2. Or force apply: renamify apply --force-with-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.
❌ Conflict: File 'src/missing.js' in plan no longer exists
The plan may be outdated. Consider recreating it.
Terminal window
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

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)

Every apply operation creates comprehensive backups:

.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
  • 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

If any step fails during application:

Terminal window
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.js
2. Make writable: chmod +w src/readonly.js
3. Retry: renamify apply
  1. Check file permissions - Ensure you can write to all files
  2. Free disk space - Ensure adequate space for operations
  3. Close editors - Some editors may lock files
  4. Retry application - Most errors are temporary

Use --force-with-conflicts only when you understand the risks:

Terminal window
# This bypasses safety checks - use carefully!
renamify apply --force-with-conflicts
Terminal window
# Check what was actually applied
renamify history --limit 1
# Test your code
npm test # or cargo test, etc.
Terminal window
# Undo the last operation
renamify undo def456-20241201-150322
# Or see all operations and pick one
renamify history
renamify undo <operation-id>

The plan file remains after application for reference:

Terminal window
# Remove the plan file if done
rm .renamify/plan.json
# Or keep it for documentation

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
  • Close unnecessary programs to free system resources
  • Use SSD storage for faster file operations
  • Ensure stable power for long operations
  • 0 - Applied successfully
  • 1 - Conflicts detected (use --force-with-conflicts to override)
  • 2 - Invalid plan file or arguments
  • 3 - Internal error or system issue
Terminal window
# 1. Plan the changes
renamify plan old_name new_name --preview table
# 2. Review the plan
cat .renamify/plan.json | jq '.stats'
# 3. Apply the plan
renamify apply --commit
# 4. Verify and test
git log --oneline -1
npm test

For simpler cases, consider using renamify rename which combines planning and applying:

Terminal window
# This does plan + apply in one step with confirmation
renamify rename old_name new_name --preview table --commit