It looks like the cities in Scotland are at level 6:
Edinburgh: Relation: City of Edinburgh (1920901) | OpenStreetMap
Glasgow: Relation: Glasgow City (1906767) | OpenStreetMap
Aberdeen: Relation: Aberdeen City (1900654) | OpenStreetMap
Dundee: Relation: Dundee City (1921173) | OpenStreetMap
Stirling: Relation: Stirling (1905258) | OpenStreetMap
Perth: Relation: Perth and Kinross (1915429) | OpenStreetMap
Inverness: I can’t find a city boundary for Inverness. The level 6 boundary surrounding it is for Highland, but it’s a big area https://www.openstreetmap.org/relation/1433249
A lot of the towns and cities seem to be admin level 6 only, so large counties comprising multiple towns and villages.
Dunfermline: the town is at Way: Dunfermline (459086413) | OpenStreetMap - however it’s a way, rather than a boundary in OSM - I’m not sure if that means it can’t be extracted with all its streets or not? I’m not sure, but I think that James is pulling the data for towns from within boundary lines, and the enclosing boundary for Dunfermline is the county of Fife at admin level 6 , which includes loads of other boundaries Relation: Fife (1905841) | OpenStreetMap
Hamilton: within South Lanarkshire county - Relation: South Lanarkshire (1921241) | OpenStreetMap
Glenrothes: also within Fife
I’m inclined to think that the OSM town boundary data is a bit variable across Scotland, but I’m not sure enough of my OSM skills to be sure of that.