Thats what the interlock kit does. Prevents backfeeding to the power grid and keeps the generator from blowing to bits when the power is restored.
"basically a permanent extension cord inside the wall" NEC violation. No cords permitted inside walls, for permanent use and not accesible. I assume you mean permitted cable or conduit?