'Slender to slender and broad to broad' or 'caol ri caol is leathann ri leathann' is the basic spelling rule in Scottish Gaelic.
It's based on the fact that Gaelic consonants are either broad or slender, which is shown by the quality of the vowel preceding or following them. The slender vowels are e and i and the broad vowels are a, o and u. As a consonant cannot be both slender and broad at the same time, it means that when there is a vowel immediately before and after it, both vowels have to be either slender or broad.
For example, in the word pìobaireachd ('pibroch, piping'), b is preceded by o and followed by a, both of which are broad while r is preceded by i and followed by e, both of of which are slender.
You can see this spelling rule at work in almost every Gaelic word, as it has very few exceptions. It's also used when an English word is represented in the Gaelic orthography. One of my personal favourites is seagsaidh, which is the Gaelic way of spelling the word 'sexy'. As expected, it follows the 'slender to slender and broad to broad' rule: broad gs (there's no x in the Gaelic alphabet hence the digraph) is preceded by broad a, and therefore it has to be followed by another broad vowel, in this case another a.
Pretty seagsaidh, huh?