Cook the pasta in a large saucepan of lightly salted boiling water for 10–12 minutes, or according to the packet instructions, until al dente. Drain, reserving 4 tablespoons of the cooking water, and return the pasta to the pan.
Meanwhile, cook the beans in a separate saucepan of salted boiling water for 3–4 minutes. Drain well.
While the pasta and beans are cooking, heat the oil in a frying pan, add the garlic, chilli flakes, lemon rind and salt and pepper and cook over a low heat, stirring, for 3–4 minutes until the garlic is soft but not browned.
Scrape the oil mixture into the pasta with the beans, reserved pasta cooking water, lemon juice and basil and stir over a medium heat until heated through. Serve with grated Parmesan or pecorino.