Automatically rollback changes from failed workflow phases using changes log files...
Rollback failed workflow phases by reading changes log and reversing tracked modifications.
{
"changes_log_path": ".bug-changes.json",
"phase": "bug-fixing",
"confirmation_required": true
}
{
"phase": "bug-fixing",
"timestamp": "2025-10-18T14:30:00Z",
"files_modified": [{"path": "src/app.ts", "backup": ".rollback/src-app.ts.backup"}],
"files_created": ["src/new-file.ts"],
"commands_executed": ["pnpm install", "pnpm build"],
"git_commits": ["abc123"],
"artifacts": [".bug-fixing-plan.json"]
}
Use Read tool to load JSON. Validate required fields: phase, timestamp, files_modified, files_created, commands_executed, git_commits.
Show summary of changes to revert. If user declines, return dry run result.
cp "{backup}" "{path}" # For each {path, backup} in files_modified
rm -f "{file}" # For each file in files_created
pnpm install → re-run to restore lockfilegit add * → git restore --staged .pnpm build → rm -rf dist/git revert --no-edit {sha} # In reverse order
Remove plan files and temporary artifacts.
{
"success": true,
"phase": "bug-fixing",
"actions_taken": ["Restored src/app.ts", "Deleted src/new-file.ts", "Reverted abc123"],
"files_restored": 1,
"files_deleted": 1,
"git_commits_reverted": 1,
"errors": [],
"warnings": ["Backup not found: .rollback/file.backup (skipped)"]
}
Workers should track changes during operations:
.{domain}-changes.json before modifications.rollback/ for modified files