Thinly slice the shallots and garlic, keeping them separate for better control during cooking. Cut the yellow squash into thin, uniform strips using a mandoline or sharp knife—uniform thickness ensures even cooking. Chop the fresh Italian parsley and cut the basil into thin ribbons (chiffonade). Fill a large pot with water and bring it to a rolling boil; this will be ready for the pasta in the next step.
Pour the olive oil into a large skillet and add the sliced shallots with a pinch of kosher salt. Heat on medium-high until the oil shimmers and the shallots begin to soften, about 2-3 minutes. Add the sliced garlic and stir constantly for 30 seconds until fragrant, then immediately cover the pan and reduce heat to low. Cook covered for 10 minutes to gently infuse the oil with flavor without browning the aromatics—this gentle approach creates a silky, sweet base rather than harsh, burnt notes.
While the oil infuses, add 2 tablespoons of kosher salt to the boiling water and cook the spaghetti according to package directions until al dente. Reserve 1 cup of pasta water before draining. In the final 2 minutes of pasta cooking, place the squash strips in a colander and carefully pour the hot pasta water over them to gently blanch the squash—this softens it slightly while keeping it fresh and tender. I like to reserve the pasta water first so I don't forget it, as it's crucial for creating the right sauce consistency.
Uncover the pan with the infused oil and stir in the crushed red pepper flakes, cooking for just 15 seconds to toast them slightly. Add the blanched squash and cooked spaghetti from Step 3 to the pan, then pour in the reserved 1 cup of pasta water. Toss everything together over medium-low heat for 1-2 minutes, allowing the starchy pasta water to create a light, silky sauce that coats the noodles and squash.
Remove the pan from heat and add the freshly cracked black pepper and grated Parmigiano-Reggiano, tossing gently until the cheese melts into the pasta and creates a cohesive sauce. Stir in the lemon zest, fresh lemon juice, chopped parsley, and basil chiffonade, tossing once more to distribute the fresh flavors throughout. I always add the fresh herbs at the end off heat to preserve their bright, delicate flavor—heat would diminish their freshness.
Divide the spaghetti and squash among serving bowls or plates. Top each portion with the toasted pine nuts for a delicate crunch and nutty flavor that complements the light, fresh dish.