Watch the The Three Layers of Improv online guitar lesson by David Wallimann from Guitar DNA: CAGED Soloing
Let's consider three layers when improvising, each layer allowing for more complex musical ideas.
The first layer is made of chord tones. That layer is not very expressive, but very safe because the notes found in that layer are the exact notes found in the chord(s) you are playing over.
The second layer offers more possibilities. That layer is made of the 5 notes of the pentatonic scale. Although there are sometimes exceptions, we'll think of Major pentatonic scales for Major chords, minor pentatonic scales for minor chords.
The third layer is the most complex layer we'll use in this course. That layer is made of 7 notes. This is where we will find all the modes.