In a keyboard macro, you can create an effect similar to that of
query-replace, in that the macro asks you each time around
whether to make a change.
When this point is reached during macro execution, ask for confirmation
While defining the macro, type C-x q at the point where you want the query to occur. During macro definition, the C-x q does nothing, but when you run the macro later, C-x q asks you interactively whether to continue.
The valid responses when C-x q asks are:
Continue executing the keyboard macro.
Skip the remainder of this repetition of the macro, and start right away with the next repetition.
Skip the remainder of this repetition and cancel further repetitions.
Enter a recursive editing level, in which you can perform editing which is not part of the macro. When you exit the recursive edit using C-M-c, you are asked again how to continue with the keyboard macro. If you type a SPC at this time, the rest of the macro definition is executed. It is up to you to leave point and the text in a state such that the rest of the macro will do what you want.
C-u C-x q, which is C-x q with a prefix argument, performs a completely different function. It enters a recursive edit reading input from the keyboard, both when you type it during the definition of the macro, and when it is executed from the macro. During definition, the editing you do inside the recursive edit does not become part of the macro. During macro execution, the recursive edit gives you a chance to do some particularized editing on each repetition. See Recursive Editing Levels.