Bring a large pot of salted water to a boil. Cook the spaghetti or linguine according to package instructions until al dente, about 10-12 minutes. Drain and set aside, reserving 1/2 cup of pasta water.
Reduce the heat to medium-low. Add the butter and let it melt, then pour in the heavy cream. Stir constantly for 2-3 minutes until the mixture begins to simmer gently.
Add the grated Parmesan cheese, stirring until it melts and the sauce thickens, about 3-4 minutes. Season with salt, black pepper, and red pepper flakes (if using). If the sauce is too thick, add a splash of reserved pasta water to adjust the consistency.
Add the cooked pasta to the skillet and toss until fully coated in the creamy garlic sauce. Cook for an additional 1-2 minutes to let the flavors meld.
Remove from heat and transfer to serving plates. Garnish with fresh parsley or basil if desired. Serve your creamy garlic pasta hot and enjoy a simple, indulgent dinner!