Cooke also participated in the Gettysburg Campaign with Stuart. Soon after the start of the Stuart's ride around the Union Army of the Potomac, Cooke was nearly shot or captured during the Battle of Fairfax Court House (June 1863). He was eating breakfast with two other staff officers and a courier at the home of a blacksmith while the blacksmith shoed their horses. The Confederate officers were about a half mile from the main body of Brig. Gen. Wade Hampton III's cavalry division when advance riders from the 11th Regiment New York Volunteer Cavalry rode by in pursuit of the advance guard of Hampton's division. The other three Confederates quickly fled toward their main body but Cooke was intent on finishing his breakfast and having his horse shoed. He barely escaped when a second group of Union riders became suspicious of the nature of activity at the farm and rode up to check.