Toast the pine nuts or walnuts in a dry skillet over medium-low heat for 3-5 minutes until fragrant and light golden, then transfer to a plate to cool.
Rinse and thoroughly pat dry the basil and spinach leaves, removing any thick basil stems.
Add garlic to the food processor and pulse 5-6 times until finely chopped, then add toasted nuts and pulse 5-6 more times until broken down but not pulverized.
Add the basil, spinach, and grated Parmesan cheese to the food processor on top of the garlic and nut mixture.
Drizzle in olive oil, vegetable broth, lemon juice, salt, pepper, and red pepper flakes if using.
Pulse 8-10 times, scrape down sides with a rubber spatula, then process continuously for 15-20 seconds until smooth but slightly textured.
Taste and adjust seasoning with salt, lemon juice, or Parmesan as desired, adding more broth if too thick.
Serve immediately or transfer to an airtight container, pressing plastic wrap directly onto the surface before sealing.