What is the theory behind these extensions?
Music theories are organized or established ways of talking about a part of human culture: music-making. Theories are not behind music. Theories describe musical activities. Depending on what the activities are and in which culture, and from which culture the talkers-about-music are, different theories i.e. ways of talking might be appropriate. One way to talk about chord extensions is that they feel different, they taste different. Every extension and its sharp/flat modified version has a specific taste and feeling to it.
Another way to talk about these chords is: I play a regular major or minor chord and move one of the notes a bit. Or even, I move a finger along the fretboard.
Try the following chord.
It could be said to contain a Gdim chord in the middle strings, or a "flat 9th" (if you insist that everything is a stack of thirds), but I'm quite sure that's not what flamenco players are thinking about. It's more like an F# major, with a twist.
A third way of looking at chords and notes in Reflejo de Luna: I play this chord, and then I play a melody over it using the high strings. In the melody, I use tones which add to the chords in some way and lines which land on important tones of the chords. For example in the melody line A - G# - D, the G# is the tone between my root and third, and pathological everything-must-be-a-stack-of-thirds thinkers would call it a "9th". It adds a melancholic feeling. The D note lands on the third of the next chord, Bm.
I see all these as plausible frameworks. Reasoning about music does not have to follow the conventions of functional harmony and stacks-of-thirds.
How does he know what
extensions to play, if they should be flat/sharp or not?
He has played with them, listened to the music and developed a taste. It's a matter of artistic choice and availability. You see things in terms of what you already know.
So far I have only figured out that if you sharpen or flatten a
extension it will always sound dissonant as a rule of thumb. b9, b11,
b13, or #9, #11, or #13 all are dissonant sounding. Since diminished
chords are dissonant too I assume that it would make sense that you
could replace diminished chords with just natural minor or major
chords except with a bunch of sharpened or flattened extensions on top
of it, if you’re going for a dissonant sound. Am I wrong?
That's wrong. Take a song that uses a diminished chord and substitute it with one of your "dissonant" extended chords, it shouldn't do a similar thing at all. Except in the flamenco dominant chord (my made-up name) I showed above, there happens to be a dim chord inside. Maybe you stumbled on that by accident? But it's not about a level of dissonance, whatever "dissonance" really even means to different people.
Pat Metheny said in an interview that all possible extensions are something sensible and non-dissonant to him. (Don't remember where, but maybe it was the recent The Pat Metheny interview with Rick Beato)
How do you master extensions, as well as flattened and sharpened
extensions?
First you build a foundation on something that you can use without further explanations. When you have a known foundation, you can see other things in terms of those basic elements. You could even learn the flamenco chord above as a basic chord that doesn't need explaining, but for some reason you want to "understand" it.
A good foundation for the flamenco thing is to know basic minor and major harmony, in terms of three chords of minor, and three chords of major. And to be able to find the key center. For example in E minor and G major, these would be
- E minor: Em (tonic), Am (subdominant), B7 (dominant)
- G major: G (tonic), C (subdominant), D (dominant)
The foundation means being able to:
- Find the chords on your instrument.
- Listen and find the key center on your instrument.
- Listen and play by ear songs which utilize the 3+3 chords. (I, IV and V of major, and same for the relative minor)
- Listen to other more advanced music and feel that this sounds familiar, somehow similar to what you already know from the simpler 3+3 chord world.
- Assign some kind of names or symbols to the chords, so you can make notes, retrieve the notes later and reproduce the music. If you cannot read and write, remembering locations on the instrument can work as symbols, but being able to talk with other people is nice. (Though if they have their foundation in order, you could also show the locations on your instrument or play the chords and they will get the idea.)
When you have the foundation, you can build on it. And then you can for example
- learn what it feels like to make the subdominant a 6 chord.
- learn what it feels like to make one of the major chords a maj7
- learn what it feels like to make the major's subdominant chord a seventh, like the D7 in Reflejo de Luna
- learn to make substitutions like instead of a dominant chord, play a dim or dim7 rooted on the dominant's third. Or a tritone substitution.
- learn to see chord sequences from other keys being temporarily used, like in a song that's in F# minor, there can be a G#7 - C#7 motion,
- learn tunes by listening, instead of relying on unreliable sources like the internet and "apps"
If I understood correctly, one of the fundamental problems behind this question was not being able to hear that the flamenco tune is in a minor key, and instead accepting bogus information from online "tools".