Pat the cod fillets dry with paper towels and season both sides with salt and black pepper.
Heat the olive oil in a large skillet over medium-high heat.
Add the cod to the hot pan and cook 3–4 minutes on the first side without moving, until lightly golden.
Flip the fillets and cook another 2–3 minutes until the fish is nearly cooked through; remove to a plate.
Reduce heat to medium and add the butter to the same skillet.
Once the butter has melted, stir in the minced garlic and cook 30–45 seconds until fragrant (don’t let it burn).
Pour in the broth, scraping any brown bits from the bottom of the pan.
Stir in the drained white beans and simmer gently for 3–4 minutes, letting the beans warm and the sauce slightly thicken.
Add lemon zest and juice, then return the cod fillets to the skillet.
Spoon sauce over the fish and simmer another minute to finish cooking.
Remove from heat and sprinkle with fresh parsley and optional red pepper flakes before serving.