How do I update an OTA while retaining TWRP and Magisk, only with my phone? I have a OnePlus 6 that uses the A/B partition schema.

Previously with my OnePlus 5  with TWRP, I normally download the OTA package, reboot into TWRP to install it, and then TWRP img and Magisk ZIP afterwards. Then I have a fully updated system with TWRP and Magisk.

Now with A/B partition, the OTA gets installed immediately after downloading. I can only flash Magisk before rebooting, by manually extracting the boot image using command-line tools and Magisk's "Patch Boot Image" function, before flashing the patched boot image back. However, I see no option to install TWRP in this way (I'm currently not able to apply the ZIP using CLI tools). Any ideas?

Some good points for OnePlus over AOSP: OnePlus detects Magisk root and downloads full image instead of incremental OTA image, which saves the time for boot restoration, and also allows installing OTA even if /system is modified. 

However, there's no "Disable Auto OTA Installation" in Developer Settings, so OTA installation may not be avoidable to some extents.
This answer is more applicable to AOSP and not One Plus 6 as I realized post edit by OP. Retaining for general info



You can't ATM

Welcome to the convenience and complications of A/B partitions 


Firstly, A/B devices don't have /recovery partition as recovery is included in the /boot partition. Which means everytime you update custom recovery is replaced by the stock recovery. For more details, see the second link in my answer here `Wipe Cache` option in Google Pixel 2!
For retaining root,that is Magisk, the developer has recommended a method for OTA installation which doesn't entail extracting / patching boot images
For custom ROM's too Gapps don't survive OTA updates unless the Gapps are modified (as in the case of official Lineage OS for my device MiA1 as an example)


It may be possible if the custom recovery is also modded to survive OTA like Gapps. AFAIK, this is the current state for A/B devices which means you can't update OTA on the go and have custom recovery without having a PC (reason for me to delay OTA updates)