Heat oven to 375°F and position a rack in the center.
Bring a large pot of salted water to a boil. Cook spaghetti until al dente, then drain well.
Whisk eggs, milk, Parmesan, salt, black pepper, red pepper flakes, and parsley in a large bowl until smooth.
Warm olive oil and butter in a 10- to 12-inch oven-safe skillet over medium heat.
Sauté onion until translucent, about 3–4 minutes. Stir in garlic and cook 30 seconds until fragrant.
Add drained spaghetti to the skillet and toss to coat, spreading it evenly over the pan.
Pour the egg mixture over the pasta. Sprinkle mozzarella evenly on top.
Cook on the stovetop without stirring until edges set and the bottom lightly browns, 5–6 minutes.
Transfer skillet to the oven and bake until the center is just set and puffed, 8–10 minutes.
Rest 5 minutes. Loosen edges, slice into wedges, and serve warm.