[revised 31 Dec 2020]
Gaines Mill, fought correctly, should be one of the easiest CSA victories in the game.
Prepare three corps. Two will have 20 brigades/units, one will have just 10. Mostly infantry plus maybe one or two cav units is good. Artillery is not needed.
For each of these corps, the last division (5 units) enters the map with only an hour or hour and a half left in the battle. These divisions can still be useful, mainly in blocking the escape of routing Union brigades, but they are far less likely than the other divisions to engage in battle, so use relatively cheap infantry, cav, or skirmishers for these unless you have enough men and money to fill out the slots normally.
Assign one of the 20-unit corps and the 10-unit corps to the head-on attack, entering from the NW corner of the map. The remaining 20-unit corps should be assigned to enter from the NE late in the day.
Use your NW-corner units to wrap the Union line from W of the line down to S of the line. Keep these units well out of sight of the Union line until ready to advance.
Bring your NE-corner units, which will appear late in the day, immediately in a roughly SW direction toward the Boatswain Woods position.
As your NE force approaches Boatswain Woods, use your NW units to wrap the Union position at Boatswain Hill more tightly. Six to ten units should march up the slope of the hill S of the Boatswain Hill flag and start the Union defenders routing towards the other flag. At this time, the NE force should wrap and engage with the Boatswain Woods position from N around to NW and rout the main defending brigade. You should soon establish a continuous, curved line of attack forcing Federal brigades east from Boatswain Hill and south/east from Boatswain Woods.
Pause near the McGhee Hill flag—don’t start the contested timer on it until 1900-1930, as taking it (while possessing either one of the other flags) will end the battle. Annihilate as many Union units as possible.
Two things I really dislike about this battle are (1) the end time of 1930 (730 pm) seems fake; at that time of year there should have been enough light for at least another hour or two of fighting; (2) even when you destroy virtually every visible Federal unit on the map, the final score will show the Union with no more than about 50 percent casualties.
The basic strategy I have outlined above also works for Gaines Mill when using the J&P Rebalance Mod. However, in the version I have tried (1.27.1a) CSA can bring 36 brigades (24 + 12?) from the NW and 30 from the NE, and due to the mod’s artificial slowing of unit movement, it is more difficult to achieve a full annihilation of the Union force.