Xiao sam21 keeps ejecting

Am I the only one who feels like they have to unplug USB ports and double tweezer the reset pins over and over again just to program this chip? I’m using the arduino IDE and it seems like different variants of my code seem more or less likely to cause the serial port to reject the device, but the pattern isn’t clear at all. I don’t know how I am supposed to test and debug a thing that disconnects every time something goes wrong. My success rate in getting it uploads to succeed feels like it’s less than 20% today, I’ve been doing this for hours and it’s completely maddening. The issue is made slightly worse by uploads saying they’re successful until 30s later when the serial reports being closed. Can I get some guidance?

Swapped out the chip. The new one does the same thing.