It looks like the cities in Scotland are at level 6:
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 https://www.openstreetmap.org/way/459086413 - 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 https://www.openstreetmap.org/relation/1905841
Hamilton: within South Lanarkshire county - https://www.openstreetmap.org/relation/1921241
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.