write_files_atomic
Write multiple files atomically with automatic backup and rollback. Ensures all changes succeed together or none are applied.
Instructions
Write a batch of files in a single atomic operation with automatic backup. All files succeed or all roll back on any failure. Use this when several file writes must land together (config changes across modules, multi-file generation output). For natural-language edits to a single file, use modify_file instead. For appending to a log or accumulator file, use the append operation here. Each overwrite produces a <path>.backup.<timestamp> file when create_backup is true (default). ⚠️ DESTRUCTIVE: every operation writes (or appends to) a real file on disk. The rollback path runs only when a LATER operation in the same batch fails — earlier successful writes are reverted from their backups, but if every operation succeeds, the new files stand and the backups remain on disk. Returns: {success, files_written, results:[{path, operation, success, size}], backups_created, backups:[{original, backup}]}. On a mid-batch failure the call throws after restoring earlier files (rollback is not reflected in a success response).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_operations | Yes | Array of write operations to apply atomically. If any operation fails, all previously written files are restored from their backups. | |
| create_backup | No | When true, each file that would be overwritten is first copied to `<path>.backup.<timestamp>`. Set false only when you know the prior content is recoverable from version control. |