@ Paul M: It only checks for cost of components on the ship to be built that aren't on the ship the yard is tooled for, not the other way round. In non-cheaty use, this often means you can build analogous freighters in yards tooled for your colony ships, but not the reverse. Or you can build a fighting ship in a yard tooled for its command version (with a sophisticated sensor package but less weaponry), but not the other way round.
Making the ship consist almost entirely of the most expensive electronics (hardened beam fire controls, applicable sensors for commercial yards) enables you to build just about anything. I don't like going quite as far, but when I build some sensor pods (to be tugged around) I'll happily reuse the shipyard for anything of the appropriate size.