For all his strengths, Ryouma is dependent on either CEs or plug in order to loop. His NP gain is sadly just not quite where it would need to be to tri-loop with just Castoria and the 2004 Mystic Code. He’s close enough with enough different setups, though, that I fully believe there are circumstances in which it’ll be doable depending on event CE properties and enemy wave compositions. He should be able to swing it versus Casters with the help of Mana Loading, for instance, by using his battery and both Castorias’ second skills on turn 1, letting him refund to 70% on each subsequent turn, which the Castorias’ first skills can cover—but against neutral classes (including, most importantly, Archers) he’s just short of the NP gain he needs.
As such, for meaningful general-purpose farming, it’s safe to assume Ryouma will be using plug—and ideally plug Oberon. With Castoria/Castoria/Oberon, Ryouma can loop NP-neutral classes assuming there are at least four enemies across the first two waves. He has a little more trouble with 3/1/x nodes—he needs an extra hit of overkill on wave 1, and his damage will be lower on wave 2 than it would otherwise be, but he can do it, provided his damage is high enough.
In order to do this, Ryouma needs his Mana Loading maxed. With Castoria’s help, Ryouma refunds roughly 17% per enemy. With Mana Loading, you use the Castorias’ charismas and one of their Avalon le Fae skills on the first turn. This leaves you with two 50% batteries (Ryouma’s and Oberon’s) and two 20% batteries (Castoria’s and Oberon’s) available. Ryouma will need one of the 50% batteries each turn, and he then uses the 20% batteries to make up whatever difference remains. You’ll want to use Castoria’s first, as Ryouma’s NP gain is slightly lower without it—this is why he needs more overkill for 3/1/x nodes, as his refund versus the wave of 3 is lower without having used both Castorias’ batteries first—but all in all this gives Ryouma more flexibility than you might expect given his NP’s low refund. As tends to be the case these days, damage issues are most likely on waves 1 and 2, especially in the case of waves of 1 enemy, but Ryouma’s heavy investment in NP damage buffs means End of the Dream skyrockets Ryouma’s damage, letting him down the third wave without much trouble.
It’s also worth noting that, while Ryouma can’t farm 2/1/x or 1/2/x waves on his own, he does have a party damage buff and a 50% battery, which positions him well for supporting a secondary ST damage dealer in those types of nodes. He can’t farm difficult 90+ enemy formations without help, but he has a nice kit for putting together the sorts of teams that usually can farm those nodes.
For CQs, much of the same logic applies. Two Castorias and an Oberon is going to maximize Ryouma’s 3-turn damage output. You can also run Tamamo in place of Oberon for better sustained buffs in exchange for more reliance on cards and no ability to spike damage with End of the Dream. Sherlock, too, is a nice partner in CQ contexts, as he negates the danger of defensive buffs and he provides nice general damage buffs for Ryouma. He also boosts crit damage for the party, which plays well with Ryouma’s tools.
Ryouma transitions naturally into slower-moving teams as well. Ryouma’s overcharge buff pairs quite well with Castoria in particular, and he also synergizes nicely with Merlin. Merlin/Ryouma/Castoria is a remarkably solid team—on top of the team’s natural defensive benefits, Merlin provides flat charges that help the whole team move faster, and Ryouma appreciates and can take advantage of Merlin’s crit tools. This is an especially good team for fights that like to spam debuffs, as Ryouma can keep those debuffs from interrupting his damage, and Castoria can remove them from the supports as needed.
Outside of top-end setups, Ryouma plays well with lower-end supports as well. Lanling in particular is a great partner, packing star gen buffs that synergize nicely with Ryouma’s hit-counts and a strong Overcharge effect Ryouma can boost. Sherlock/Ryouma/Lanling is a more classical Arts Crit team that could be fun to use, especially if you don’t have the more optimized Arts supports. Mozart is also a great partner for Ryouma due to his Arts buffs and his ability to force crits, and Ruler Da Vinci provides generally-useful tools.
It’s also worth considering Waver, Reines, and base Mash. Ryouma’s defense-up-on-NP effect means teams that focus on stacking defense buffs can be deceptively bulky. Also notably, all three of these Servants provide attack buffs, which is the one buff type Ryouma doesn’t get innately, making them particularly strong partners for him.
The Black Grail is always a great CE for pushing damage output, though Ryouma can also benefit from CEs that make it easier for him to spam his NP: Painting Summer or Ocean Flyer for starting NP charge and other useful benefits, or Mark on a Smiling Face for better damage and NP gain, but no starting charge.
Ryouma benefits from crit-focused command codes. Any of star gen, crit damage up, and star weight up can go a long way towards securing and strengthening Ryouma’s crits, so I’d recommend picking command codes based on whether you want Ryouma’s crits to be more consistent or more powerful.