it's completely based on the refit cost, and it costs nothing to *remove* components. So, if you have a cryo-ship and a freighter that use mostly the same components, the cryoship tooling will be able to build both because removing cryo-pods cost nothing and adding freight bays cost almost nothing. But vice versa is not true, because adding cryo-pods costs alot.
so the easy way to do it is to make one design, copy it, remove expensive components and add cheap components. For military vessels, i generally find that trying to maintain flexible shipyards isnt usually worth it, although it can be a good idea to try to retain design similarities in order to keep retooling costs down. The only military refit compatibilities i maintain are for updated versions of older vessels, so that a shipyard might refit older ships as well as make new ones of the same purpose.
One narrow category where it can be easy to make a multi-tool compatible version is military vessels equipped with commercial jump drives. These components are cheap but large; as long as you only remove components to make room you are virtually guaranteed to be tooling compatible. For example:
Adamant class Command Carrier 30 000 tons 590 Crew 3469.4 BP TCS 600 TH 900 EM 0
1500 km/s Armour 5-86 Shields 0-0 Sensors 50/80/0/0 Damage Control Rating 30 PPV 24
Maint Life 3.77 Years MSP 2168 AFR 240% IFR 3.3% 1YR 239 5YR 3579 Max Repair 192 MSP
Intended Deployment Time: 24 months Flight Crew Berths 190
Hangar Deck Capacity 9000 tons
ASPD Naval Flux Turbine (3) Power 300 Fuel Use 6.19% Signature 300 Exp 5%
Fuel Capacity 1 200 000 Litres Range 116.3 billion km (897 days at full power)
2Gen Heavy Pulse Cannon (6) Range 180 000km TS: 3000 km/s Power 6-3 RM 3 ROF 10 6 6 6 4 3 3 2 2 2 1
Point Defense Cannons (4x6) Range 1000 km TS: 12000 km/s ROF 5 Base 50% To Hit
M03 Predictive Target Lock (2) Max Range: 192 000 km TS: 6000 km/s 95 90 84 79 74 69 64 58 53 48
Flux Reactor (5) Total Power Output 22.5 Armour 0 Exp 5%
Capital DRAEDIS (1) GPS 57600 Range 266.0m km Resolution 300
Heritage Collision Sensor (2) GPS 32 Range 2.6m km MCR 279k km Resolution 1
Telescope Array (1) Sensitivity 50 Detect Sig Strength 1000: 50m km
PKT Surveillance Grid (1) Sensitivity 80 Detect Sig Strength 1000: 80m km
STARCOM Suite (1) Sensitivity 8 Detect Sig Strength 1000: 8m km
Strike Group
27x Z29 Striker Speed: 9487 km/s Size: 6.64
Ascendant class Command Carrier 30 000 tons 455 Crew 2530.4 BP TCS 600 TH 900 EM 0
1500 km/s JR 1-25(C) Armour 3-86 Shields 0-0 Sensors 50/80/0/0 Damage Control Rating 28 PPV 12
Maint Life 4.65 Years MSP 1476 AFR 257% IFR 3.6% 1YR 111 5YR 1668 Max Repair 86 MSP
Intended Deployment Time: 36 months Flight Crew Berths 165
Hangar Deck Capacity 6000 tons
Heritage Capital Hetch Drive Max Ship Size 31500 tons Distance 25k km Squadron Size 1
Heritage Flux Turbine (3) Power 300 Fuel Use 7.07% Signature 300 Exp 5%
Fuel Capacity 1 500 000 Litres Range 127.3 billion km (982 days at full power)
2Gen Heavy Pulse Cannon (3) Range 180 000km TS: 3000 km/s Power 6-3 RM 3 ROF 10 6 6 6 4 3 3 2 2 2 1
Point Defense System (1x6) Range 1000 km TS: 12000 km/s ROF 5 Base 50% To Hit
M03 Predictive Target Lock (1) Max Range: 192 000 km TS: 6000 km/s 95 90 84 79 74 69 64 58 53 48
Flux Reactor (2) Total Power Output 9 Armour 0 Exp 5%
Heritage Collision Sensor (2) GPS 32 Range 2.6m km MCR 279k km Resolution 1
Telescope Array (1) Sensitivity 50 Detect Sig Strength 1000: 50m km
PKT Surveillance Grid (1) Sensitivity 80 Detect Sig Strength 1000: 80m km
It's also the case that commercial vessels are often compatible with military vessels of the same tonnage,simply because the military vessels cost so much more.
Lojistik m.4 class Freighter 39 000 tons 124 Crew 427.4 BP TCS 780 TH 900 EM 0
1153 km/s Armour 1-102 Shields 0-0 Sensors 1/8/0/0 Damage Control Rating 1 PPV 0
MSP 7 Max Repair 27 MSP
Intended Deployment Time: 3 months Spare Berths 0
Cargo 25000 Cargo Handling Multiplier 15
ASPD Efficient Flux Turbine (5) Power 180 Fuel Use 1.73% Signature 180 Exp 3%
Fuel Capacity 150 000 Litres Range 40.0 billion km (401 days at full power)
Navigational Transponder (1) GPS 2400 Range 15.7m km Resolution 150
STARCOM Suite (1) Sensitivity 8 Detect Sig Strength 1000: 8m km
This design is classed as a Commercial Vessel for maintenance purposes
Bastion class Command Carrier 40 000 tons 735 Crew 4402.8 BP TCS 800 TH 1200 EM 0
1500 km/s Armour 6-104 Shields 0-0 Sensors 50/80/0/0 Damage Control Rating 41 PPV 28.8
Maint Life 5.05 Years MSP 2820 AFR 312% IFR 4.3% 1YR 184 5YR 2767 Max Repair 192 MSP
Intended Deployment Time: 24 months Flight Crew Berths 201
Flag Bridge Hangar Deck Capacity 9000 tons Troop Capacity: 1 Battalion Cryogenic Berths 1000
ASPD Naval Flux Turbine (4) Power 300 Fuel Use 6.19% Signature 300 Exp 5%
Fuel Capacity 1 600 000 Litres Range 116.3 billion km (897 days at full power)
Triple 2Gen Heavy Pulse Turret (2x3) Range 180 000km TS: 6500 km/s Power 18-9 RM 3 ROF 10 6 6 6 4 3 3 2 2 2 1
Point Defense Cannons (8x6) Range 1000 km TS: 12000 km/s ROF 5 Base 50% To Hit
M03 Predictive Target Lock (2) Max Range: 192 000 km TS: 6000 km/s 95 90 84 79 74 69 64 58 53 48
Flux Reactor (6) Total Power Output 27 Armour 0 Exp 5%
Capital DRAEDIS (1) GPS 57600 Range 266.0m km Resolution 300
Heritage Collision Sensor (2) GPS 32 Range 2.6m km MCR 279k km Resolution 1
Telescope Array (1) Sensitivity 50 Detect Sig Strength 1000: 50m km
STARCOM Suite (1) Sensitivity 8 Detect Sig Strength 1000: 8m km
PKT Surveillance Grid (1) Sensitivity 80 Detect Sig Strength 1000: 80m km
Strike Group
27x Z29 Striker Speed: 9487 km/s Size: 6.64
This design is classed as a Military Vessel for maintenance purposes
The freighter can be manufactured by the carrier's shipyard, even though they have minimal part commonality; the freighters cost is only 10% of the carrier's to begin with, so it falls within the permitted range.