You mean, during the Mexican War and at Harper’s Ferry, he turned on his own troops? His brilliance as a general was already established long before the Civil War.
The Union wanted him as a general, and the Confederacy also wanted him. He ended up throwing in with the Confederacy, because he felt greater loyalty to his native Virginia. But regardless, his brilliance as a general is based on the fact that he won battles, sometimes with bloodshed and sometimes with bluff and bravado. Ironically, he suffered a resounding defeat at Gettysburg against General Meade, who was anything but brilliant.
Except that Lee wasn't a general during either of those, and wouldn't be a general until the confederates made him one. In the War with Mexico, he was an aide to Winfield Scott and performed a couple of valuable reconnaissance missions. And Harper's Ferry isn't exactly a brilliant piece of military leadership. By the time Lee and his troops arrived, Brown and his 21 men were already surrounded and holed up up in the engine house. After demanding Brown's surrender, they battered down the door and killed or captured everyone inside in the space of three minutes.
Lee was blessed with a string of incompetent opponents. It's noteworthy that once Grant took command of the Army of the Potomac and begin his offensive, the vaunted Lee was trapped in Petersburg within 9 weeks, and the rest of the war was just endgame delaying the inevitable.