First, make the pesto. In a food processor, pulse the basil, whole garlic cloves, pine nuts, the juice of half the lemon and some seasoning, gradually adding most of the oil. Taste and adjust the seasoning.
Heat oven to 180C/160C fan/ gas 4 and line a roasting tin with foil. Season the cod on both sides and coat each fillet in the pesto. Cook for 8-10 mins until a crust has formed and the cod is cooked through.
Meanwhile, heat the remaining oil in a small saucepan. Add the crushed garlic and the chillies, and cook for a couple of mins to release the flavour. Add the tomatoes and cook for 1 min more. Tip in the lentils, squeeze over the other half of the lemon, then season. Cook until piping hot and serve with the pesto cod.