Connecting 74HC165 to 74HC595
If your purpose is simply to be able to detect which output is connected to which input, you should be able to add a resistor up to 100K or perhaps more in series with each input or output without affecting operation.  If you want somewhat more protection, you could add some small capacitors on the inputs to the 74HC595.  Adding capacitance will significantly increase the time required for signals to propagate; the approximate time in seconds will be twice the resistance value in ohms, times the capacitor value in farads (or if you prefer, resistance value in megohms times the capacitor value in microfarads).  Using 100K resistors and 0.1uF capacitors would mean that you'd have to wait about 0.02 seconds for signals to propagate, but your board would be extremely robust.  Reducing the caps to 0.001uF cap would cut the time by a factor of 100 but your board would still be pretty robust (connecting to AC120 would probably not faze it).  If you want to be robust against AC240, that could be achieved if you use half-watt resistors but otherwise leave the circuit as-is.