export of pending undo / safe mode commands

Safe mode is great to check if something immediately breaks your system (lock out protection).

But often issues arise later one, and one would like to remove the changes made earlier (revert back)
on the fly, without flashing an older backup file (service disruption).

For this it would be create to be able to get the script/export of whatever will be executed by undo or safe mode
when you do undo or trigger safe mode. This to create your own “downgrade” script in case you notice later
on some side effects and you want to revert easily back.

Has someone been able to find that kind of information or a solution to this?
The /history command gives as everybody knows not enough information for this and I could
not find anything else in Wiki or on the forum.