Cook the spaghetti according to the package directions. Drain the spaghetti, reserving about 1/2 cup of the cooking water. Return the spaghetti to the pot and add about 1/3 cup of the reserved cooking water and 1/2 the cheese. Toss until the spaghetti is coated and a creamy sauce forms, adding more cooking water if necessary. Season with 1/2 teaspoon of the salt and 1/2 teaspoon of the pepper. Divide the spaghetti among individual bowls and sprinkle with the remaining cheese.
Heat a large nonstick skillet over medium heat. Add the butter and swirl to coat the skillet. Add the rosemary and heat until fragrant, 1 to 2 minutes. Remove and discard the rosemary. Crack the eggs into the skillet. Season with the remaining salt and pepper. Reduce heat to medium-low and cover. Cook just until the whites are set but the yolks are still runny, 2 to 3 minutes. Separate the individual eggs with a spatula. Arrange an egg on top of each mound of spaghetti. Sprinkle with the parsley (if using). Serve immediately, instructing your guests to break the yolk and toss the egg with the spaghetti.
Tip: You can easily scale this recipe down to a single serving if you’re on your own for dinner.