This is a riff I “heard in my head”; after finalizing it, I realized that it was in the key of C Major, and as a result realized you could play a major scale like so:
Play any note, then the next one two steps up on the same string, then another two steps up on the same string. Do the same thing on the two adjacent strings, and … voila! For this riff, I start on the F on the third fret of the D string, go up to the G, then the A. Then, one string lower (A string), the C on the third fret (root/tonic), the D, and E. Finally down on the E string, I play the G, A, and B. You can start anywhere and add the two strings above, the two strings below (as I did), or one on each side of your beginning string. The first (lowest) note you play on the middle string will be the root/tonic/nominal.
If that’s confusing to you (or even if it’s not, but if it’s not there’s no need to look at the image below), czech this out — the notes I play are circled in red (except for the tonic [C1], which is circled in gold):
So the upper string of the three starts on the major scale’s fourth, the middle string starts on the root/tonic, and the lower string starts on the fifth. Another way to think about or play this arrangement of notes is as two overlapping box shapes:
…where you can anchor your index finger on the third fret for the lower box shape and then move up two frets to anchor on the fifth fret — whatever floats your rubber ducky. Of course, these shapes can be moved up and down the neck, they’re not restricted to C.