The #8Cu UF cable is rated for only 40 amps. This is plainly stated in NEC 310.15(B)(16) - UF is clearly marked as rated only 60C thermal.
The subpanel lug is not rated for double-tapping, unless it says it is in the instructions or labeling.
You have 4-wire feeder, and that means you must separate neutral and ground in the subpanels. Completely. There needs to be a ground bar in that second one.
Outdoor subpanels need grounding rods.
These are all trivial fixes, and I would say you are code cpmpliant. Optional upgrades? The first thing I would do is replace the 2-space panel with something slightly larger, like a 30-space lol. Then you don't have to double-lug, you can just use a <=60A breaker to give you 2 more lugs. (Effectively using it as a subfeed lug kit; price both and you'll see why you'd use a breaker).
And by the way, Square D breakers do allow double-tapping up to a certain size of copper wire. (Ironically if the 2-space panel had been back-fed, it might be legal lol. Unfortunately it can't be, because you can't get tie-down kits for a 20 and a 15 breaker.)
Anyway, if you are sanguine with 40A and the feeder is installed properly, you are good to go. However, and particularly if either subpanel is near where someone might park a car, then I for one would upgrade that feeder to 2-2-2-4 aluminum. (90A). That will amply cover what you are powering now, and give about 60A of headroom for electric vehicle charging. You might not want, but your home-buyer might... and we're seeing them pay thousands extra for a house that is ready for level 2 charging.
The new gold standard for EV charging is 80-90A shared among all EVs using Charge2 technology. So if you are an EV maven, you might go bigger!