My wife, Phyllis, found this idea on Pinterest. Of course I had to modify the ideas a little to my satisfaction.
I ripped a 1 x 4 down to 2 ¾” wide. Then I drilled holes for pocket hole screws. To keep the screws out of sight, on the bottom shelf I drilled the holes on the bottom of the shelf. On the next two shelves I drilled the holes on the top. Next I plowed a ¼”deep dado 1 5/8” wide, leaving ¼” lip at the front of the shelf.
I used a laser light to mark the wall for a perfectly straight line for the lower shelf. For the next two shelves I made a jig by installing a T-nut in the bottom of a 2 x 4. This made it easy to hold down on the shelf firmly while drilling in the pocket hole screw. Then with a wrench you just turn in the bolt enough to remove the 2 x 4 without scratching the newly painted wood.