Courthouses certainly are not auto-build. Whether you want them depends on trait and how much maintenance you're paying on the city. The maintenance itself varies wildly too. Toroidal maps have the most distance modifier, colonial maintenance can get insane (but is capped at 2x distance, so forbidden palace can be massive before state property in some scenarios). If you're in position to pick up a lot of cities before state property, they certainly have enough of a place that avoiding them just to prevent spy specialist is an extreme measure.
That said, I'm not as down on spy specialists, espionage, or great spy as others seem to be here. It's a small pain to micro it, but espionage can amount to a fair haul in techs stolen. Early great spy that overwhelms AI generation in particular. If you really stack modifiers for it (open borders, stationary spy, possibly religious), tech stealing can be much less expensive than researching, with the caveat that you can only match the AI this way. There is also the abusive trick of gifting a complete trash city enveloped in your culture to tech leader, who won't be able to make a security bureau in it any time in the next 100+ turns, and thus you can continue stealing into late game w/o significant distance penalty. The mid game espionage buildings generate passive espionage too, which scales with having recently conquered a bunch of stuff.
Admittedly, it's at its best when you're catching up in tech from a bad position, you're not getting nearly so much value if you're at the front of tech curve and selling techs to bankroll deficit research. That said, you can still leverage such a tech lead by using rando great spy + possibly slider to take away city defenses and capture cities with cuirassers/cavalry/etc. Can also make a medieval timing push less painful, as you ignore the issue of walls/castles hurting bombardment speed.
Basically, if you want to piece together a functional empire after rushing down the AI like a belligerent ape, espionage is one the tools to make it easier.