save mode script

can I send ctrl-x to set save-mode per script?

No.

But you could build tests in to the script that detect whether whatever changes you made worked, and revert if they didn’t.

do you have sample for me?

(sorry for my bad english)

Since the tests and revert would be completely dependent on what your script does, I do not. Post the script to get more specific help.