Bring a large pot of salted water to boil for spaghetti. Cook according to package instructions.
While pasta is cooking, cook bacon until crispy. If there is an excessive amount of bacon grease, as in more than 2 tablespoons drain the excess. Add smashed garlic cloves and cook for 1 minute and then remove them. You want to cook it just long enough to release the garlic flavor into the bacon.
In a small bowl mix together egg yolks, parmesan cheese and black pepper.
Once pasta has finished cooking, reserve about 1 1/2 cups pasta water. Drain pasta and return it back to the pot.
Working quickly add 1 cup of the reserved pasta water into the egg yolk mixture and whisk together. Add this mixture to the pasta. The residual heat from the pan and the hot pasta will cook the egg yolks gently without scrambling them. The sauce should be rich and creamy, but not overly thick. Add more of the reserved pasta water if needed to thin out the sauce (see note). Add salt to taste if needed, but the parmesan cheese and bacon should be enough to season it.
Serve immediately with additional black pepper, parmesan cheese and garnish with red pepper flakes, if desired.